From 5889c0d3ecdad071bfdde59b3c525548fe1acf38 Mon Sep 17 00:00:00 2001 From: Moshe Brevda Date: Tue, 4 Jan 2022 16:52:19 +0200 Subject: [PATCH 1/3] add support for injectScript --- README.md | 1 + lib/mapping.js | 6 +++++ package.json | 2 +- test/fixtures/command-line/help-test.txt | 28 +++++++++++++++++------- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 68b6e97..cdab2c8 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ _The default WPT server can also be specified via environment variable `WEBPAGET * **-K, --keepua**: do not add PTST to the original browser User Agent string * **-m, --dom** _\_: DOM element to record for sub-measurement * **-N, --duration** _\_: minimum test duration in seconds +* **--injectScript** _\_: JavaScript to run on the page as soon as the document exists * **-E, --tester** _\_: run the test on a specific PC (name must match exactly or the test will not run) * **-W, --mobile**: (experimental) emulate mobile browser: Chrome mobile user agent, 640x960 screen, 2x scaling and fixed viewport (Chrome only) * **--device** _\_: device name from mobile_devices.ini to use for mobile emulation (only when mobile=1 is specified to enable emulation and only for Chrome) diff --git a/lib/mapping.js b/lib/mapping.js index d1cc3dc..bc03feb 100644 --- a/lib/mapping.js +++ b/lib/mapping.js @@ -153,6 +153,12 @@ var options = { param: 'name', info: 'run the test on a specific PC (name must match exactly or the test will not run)' }, + 'injectScript': { + name: "injectScript", + api: "injectScript", + param: "script", + info: "JavaScript to run after the document has started loading", + }, // Chrome tab 'mobile': { diff --git a/package.json b/package.json index a2ca30d..9e97a01 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webpagetest", - "version": "0.5.0", + "version": "0.5.1", "description": "WebPageTest API wrapper for NodeJS", "author": "WebPageTest (http://github.com/WebPageTest)", "homepage": "http://github.com/WebPageTest/webpagetest-api", diff --git a/test/fixtures/command-line/help-test.txt b/test/fixtures/command-line/help-test.txt index d960b74..e32ee09 100644 --- a/test/fixtures/command-line/help-test.txt +++ b/test/fixtures/command-line/help-test.txt @@ -32,6 +32,8 @@ Options: -N, --duration minimum test duration in seconds -E, --tester run the test on a specific PC (name must match exactly or the test will not run) + --injectScript