Skip to content

Commit 5889c0d

Browse files
committed
add support for injectScript
1 parent 0d4681e commit 5889c0d

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ _The default WPT server can also be specified via environment variable `WEBPAGET
105105
* **-K, --keepua**: do not add PTST to the original browser User Agent string
106106
* **-m, --dom** _\<element\>_: DOM element to record for sub-measurement
107107
* **-N, --duration** _\<seconds\>_: minimum test duration in seconds
108+
* **--injectScript** _\<string\>_: JavaScript to run on the page as soon as the document exists
108109
* **-E, --tester** _\<name\>_: run the test on a specific PC (name must match exactly or the test will not run)
109110
* **-W, --mobile**: (experimental) emulate mobile browser: Chrome mobile user agent, 640x960 screen, 2x scaling and fixed viewport (Chrome only)
110111
* **--device** _\<string\>_: device name from mobile_devices.ini to use for mobile emulation (only when mobile=1 is specified to enable emulation and only for Chrome)

lib/mapping.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ var options = {
153153
param: 'name',
154154
info: 'run the test on a specific PC (name must match exactly or the test will not run)'
155155
},
156+
'injectScript': {
157+
name: "injectScript",
158+
api: "injectScript",
159+
param: "script",
160+
info: "JavaScript to run after the document has started loading",
161+
},
156162

157163
// Chrome tab
158164
'mobile': {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpagetest",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"description": "WebPageTest API wrapper for NodeJS",
55
"author": "WebPageTest <[email protected]> (http://github.com/WebPageTest)",
66
"homepage": "http://github.com/WebPageTest/webpagetest-api",

test/fixtures/command-line/help-test.txt

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Options:
3232
-N, --duration <seconds> minimum test duration in seconds
3333
-E, --tester <name> run the test on a specific PC (name must
3434
match exactly or the test will not run)
35+
--injectScript <script> JavaScript to run after the document has
36+
started loading
3537
-W, --mobile (experimental) emulate mobile browser:
3638
Chrome mobile user agent, 640x960 screen,
3739
2x scaling and fixed viewport (Chrome
@@ -90,14 +92,24 @@ Options:
9092
-bh, --browserheight <pixels> Browser window height (in display pixels)
9193
-vh, --viewportheight <pixels> Viewport Height in css pixels
9294
-vw, --viewportwidth <pixels> Viewport Width in css pixels
93-
-dpr, --devicetopixelratio <ratio> Device To Pixel Ratio
94-
-au, --appendua <string> String to append to the user agent string. This is in addition to the default PTST/ver string
95-
-tt, --testtype <string> For running alternative test types, can specify traceroute or lighthouse
96-
-pr, --profiler <number> Set to 1 to enable the V8 sampling profiler (Chromium only)
97-
-avif, --disableAVIF <number> Set to 1 to disable AVIF support (Chromium 88+)
98-
-webp, --disableWEBP <number> Set to 1 to disable WEBP support (Chromium 88+)
99-
-jxl, --disableJXL <number> Set to 1 to disable JpegXL support (Chromium 88+)
100-
-dts, --dtShaper <number> Set to 1 to use Chrome's built-in traffic-shaping instead of the packet-level netem shaping usually used by the test agents
95+
-dpr, --devicetopixelratio <ratio> Device To Pixel Ratio
96+
-au, --appendua <string> String to append to the user agent
97+
string. This is in addition to the
98+
default PTST/ver string
99+
-tt, --testtype <string> For running alternative test types, can
100+
specify traceroute or lighthouse
101+
-pr, --profiler <number> Set to 1 to enable the V8 sampling
102+
profiler (Chromium only)
103+
-avif, --disableAVIF <number> Set to 1 to disable AVIF support
104+
(Chromium 88+)
105+
-webp, --disableWEBP <number> Set to 1 to disable WEBP support
106+
(Chromium 88+)
107+
-jxl, --disableJXL <number> Set to 1 to disable JpegXL support
108+
(Chromium 88+)
109+
-dts, --dtShaper <number> Set to 1 to use Chrome's built-in
110+
traffic-shaping instead of the
111+
packet-level netem shaping usually used
112+
by the test agents
101113
-Y, --latency <time> first-hop Round Trip Time in ms (used
102114
when specifying a custom connectivity
103115
profile)

0 commit comments

Comments
 (0)