Skip to content

Commit 5e68097

Browse files
authored
Merge pull request #145 from abdulsuhail/issue-142-fix
added missing api parameters
2 parents 1b6c221 + efc2bb8 commit 5e68097

File tree

4 files changed

+156
-38
lines changed

4 files changed

+156
-38
lines changed

README.md

Lines changed: 55 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
## WebPageTest API Wrapper for NodeJS
22

3-
[![Build Status](https://secure.travis-ci.org/marcelduran/webpagetest-api.svg?branch=master)](https://travis-ci.org/marcelduran/webpagetest-api)
3+
[![Build Status](https://travis-ci.com/WebPageTest/webpagetest-api.svg?branch=master)](https://travis-ci.com/WebPageTest/webpagetest-api)
44
[![NPM Version](https://img.shields.io/npm/v/webpagetest.svg?style=flat)](https://www.npmjs.org/package/webpagetest)
55
[![NPM Downloads](https://img.shields.io/npm/dm/webpagetest.svg?style=flat)](https://www.npmjs.org/package/webpagetest)
6-
[![Dependencies Status](https://david-dm.org/marcelduran/webpagetest-api.svg)](https://david-dm.org/marcelduran/webpagetest-api)
6+
[![Dependencies Status](https://david-dm.org/WebPageTest/webpagetest-api.svg)](https://david-dm.org/WebPageTest/webpagetest-api)
7+
8+
WebPageTest API Wrapper is a [NPM](https://npmjs.org) package that wraps [WebPageTest](https://github.com/WPO-Foundation/webpagetest) API for [NodeJS](https://nodejs.org) as a module and a command-line tool.
79

8-
[WebPageTest API Wrapper](https://marcelduran.com/webpagetest-api) is a [NPM](https://npmjs.org) package that wraps [WebPageTest](https://github.com/WPO-Foundation/webpagetest) API for [NodeJS](https://nodejs.org) as a module and a command-line tool.
910

1011
## Getting started
1112

@@ -17,7 +18,7 @@ $ npm install webpagetest -g
1718

1819
### Command line
1920
```bash
20-
$ webpagetest test http://marcelduran.com/webpagetest-api
21+
$ webpagetest test https://docs.webpagetest.org/api/integrations/
2122
```
2223

2324
### Docker
@@ -27,23 +28,19 @@ $ docker build -t webpagetest-api .
2728
```
2829
#### Run
2930
```bash
30-
$ docker run -it --rm webpagetest-api -k YOURAPIKEY test http://marcelduran.com/webpagetest-api
31+
$ docker run -it --rm webpagetest-api -k YOURAPIKEY test https://docs.webpagetest.org/api/integrations/
3132
```
3233

3334
### Module
3435
```javascript
3536
const WebPageTest = require('webpagetest');
3637
const wpt = new WebPageTest('www.webpagetest.org');
3738

38-
wpt.runTest('http://marcelduran.com/webpagetest-api', (err, data) => {
39+
wpt.runTest('https://docs.webpagetest.org/api/integrations/', (err, data) => {
3940
console.log(err || data);
4041
});
4142
```
4243

43-
## API Console Demo
44-
45-
[marcelduran.com/webpagetest-api](http://marcelduran.com/webpagetest-api/console/)
46-
4744
## Command Line
4845

4946
### Help
@@ -128,6 +125,18 @@ _The default WPT server can also be specified via environment variable `WEBPAGET
128125
* **-B, --pingback** _\<url\>_: URL to ping when the test is complete (the test ID will be passed as an "id" parameter)
129126
* **-D, --bwdown** _\<bandwidth\>_: download bandwidth in Kbps (used when specifying a custom connectivity profile)
130127
* **-U, --bwup** _\<bandwidth\>_: upload bandwidth in Kbps (used when specifying a custom connectivity profile)
128+
* **-bw, --browserwidth** _\<pixels\>_: Browser window width (in display pixels)
129+
* **-bh, --browserheight** _\<pixels\>_: Browser window height (in display pixels)
130+
* **-vh, --viewportheight** _\<pixels\>_: Viewport Height in css pixels
131+
* **-vw, --viewportwidth** _\<pixels\>_: Viewport Width in css pixels
132+
* **-dpr, --devicetopixelratio** _\<ratio\>_: Device To Pixel Ratio
133+
* **-au, --appendua** _\<string\>_: String to append to the user agent string. This is in addition to the default PTST/ver string
134+
* **-tt, --testtype** _\<string\>_: For running alternative test types, can specify traceroute or lighthouse
135+
* **-pr, --profiler** _\<number\>_: Set to 1 to enable the V8 sampling profiler (Chromium only)
136+
* **-avif, --disableAVIF** _\<number\>_: Set to 1 to disable AVIF support (Chromium 88+)
137+
* **-webp, --disableWEBP** _\<number\>_: Set to 1 to disable WEBP support (Chromium 88+)
138+
* **-jxl, --disableJXL** _\<number\>_: Set to 1 to disable JXL support (Chromium 88+)
139+
* **-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
131140
* **-Y, --latency** _\<time\>_: first-hop Round Trip Time in ms (used when specifying a custom connectivity profile)
132141
* **-P, --plr** _\<percentage\>_: packet loss rate - percent of packets to drop (used when specifying a custom connectivity profile)
133142
* **-z, --noopt**: disable optimization checks (for faster testing)
@@ -257,9 +266,9 @@ $ webpagetest locations --key 1F2A3K4E5
257266
}
258267
```
259268

260-
#### 3. Run test on http://marcelduran.com/webpagetest-api from San Jose on IE9
269+
#### 3. Run test on https://docs.webpagetest.org/api/integrations/ from San Jose on IE9
261270
```bash
262-
$ webpagetest test http://marcelduran.com/webpagetest-api --key 1F2A3K4E5 --location SanJose_IE9
271+
$ webpagetest test https://docs.webpagetest.org/api/integrations/ --key 1F2A3K4E5 --location SanJose_IE9
263272
```
264273
```javascript
265274
{
@@ -307,7 +316,7 @@ $ webpagetest results 121025_PT_N8K
307316
"data": {
308317
"testId": "121025_PT_N8K",
309318
"summary": "https://www.webpagetest.org/result/121025_PT_N8K/",
310-
"testUrl": "http://marcelduran.com/webpagetest-api",
319+
"testUrl": "https://docs.webpagetest.org/api/integrations/",
311320
"location": "SanJose_IE9",
312321
"connectivity": "DSL",
313322
"bwDown": 1500, "bwUp": 384, "latency": 50, "plr": 0,
@@ -340,21 +349,21 @@ $ webpagetest waterfall 121025_PT_N8K --thumbnail --cached --uri
340349
}
341350
```
342351

343-
#### Run test on http://marcelduran.com/webpagetest-api and poll results every 5 seconds timing out in 60 seconds
352+
#### Run test on https://docs.webpagetest.org/api/integrations/ and poll results every 5 seconds timing out in 60 seconds
344353
```bash
345-
$ webpagetest test http://marcelduran.com/webpagetest-api --poll 5 --timeout 60
354+
$ webpagetest test https://docs.webpagetest.org/api/integrations/ --poll 5 --timeout 60
346355
```
347-
#### Or run test on http://marcelduran.com/webpagetest-api and wait for results listening on localhost\* port 8000\**
356+
#### Or run test on https://docs.webpagetest.org/api/integrations/ and wait for results listening on localhost\* port 8000\**
348357
```bash
349-
$ webpagetest test http://marcelduran.com/webpagetest-api --wait 8000
358+
$ webpagetest test https://docs.webpagetest.org/api/integrations/ --wait 8000
350359
```
351360
```javascript
352361
{
353362
"response": {
354363
"statusCode": 200, "statusText": "Ok",
355364
"data": {
356365
"testId": "121025_PT_N8K",
357-
"testUrl": "http://marcelduran.com/webpagetest-api",
366+
"testUrl": "https://docs.webpagetest.org/api/integrations/",
358367
...
359368
"median": {
360369
"firstView": {
@@ -484,6 +493,18 @@ wpt.runTest(script, (err, data) => {
484493
* **pingback**: _String_, URL to ping when the test is complete (the test ID will be passed as an "id" parameter)
485494
* **bandwidthDown**: _String_, download bandwidth in Kbps (used when specifying a custom connectivity profile)
486495
* **bandwidthUp**: _String_, upload bandwidth in Kbps (used when specifying a custom connectivity profile)
496+
* **browserwidth**: _String_, Browser window width (in display pixels)
497+
* **browserheight**: _String_, Browser window height (in display pixels)
498+
* **viewportheight**: _String_, Viewport Height in css pixels
499+
* **viewportwidth**: _String_, Viewport Width in css pixels
500+
* **devicetopixelratio**: _String_, Device To Pixel Ratio
501+
* **appendua**: _String_, String to append to the user agent string. This is in addition to the default PTST/ver string
502+
* **testtype**: _String_, For running alternative test types, can specify traceroute or lighthouse
503+
* **profiler**: _Number_, Set to 1 to enable the V8 sampling profiler (Chromium only)
504+
* **disableAVIF**: _Number_, Set to 1 to disable AVIF support (Chromium 88+)
505+
* **disableWEBP**: _Number_, Set to 1 to disable WEBP support (Chromium 88+)
506+
* **disableJXL**: _Number_, Set to 1 to disable JpegXL support (Chromium 88+)
507+
* **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
487508
* **latency**: _String_, first-hop Round Trip Time in ms (used when specifying a custom connectivity profile)
488509
* **packetLossRate**: _Number_, packet loss rate - percent of packets to drop (used when specifying a custom connectivity profile)
489510
* **disableOptimization**: _Boolean_, disable optimization checks (for faster testing)
@@ -574,9 +595,9 @@ wpt.getLocations((err, data) => {
574595
});
575596
```
576597

577-
#### 3. Run test on http://marcelduran.com/webpagetest-api from San Jose on IE9
598+
#### 3. Run test on https://docs.webpagetest.org/api/integrations/ from San Jose on IE9
578599
```javascript
579-
wpt.runTest('http://marcelduran.com/webpagetest-api', {location: 'SanJose_IE9'}, (err, data) => {
600+
wpt.runTest('https://docs.webpagetest.org/api/integrations/', {location: 'SanJose_IE9'}, (err, data) => {
580601
console.log(err || data);
581602
});
582603
```
@@ -606,16 +627,16 @@ wpt.getWaterfallImage('121025_PT_N8K', {
606627
});
607628
```
608629

609-
#### Run test on http://marcelduran.com/webpagetest-api and poll results every 5 seconds timing out in 60 seconds
630+
#### Run test on https://docs.webpagetest.org/api/integrations/ and poll results every 5 seconds timing out in 60 seconds
610631
```javascript
611-
wpt.runTest('http://marcelduran.com/webpagetest-api', {pollResults: 5, timeout: 60}, (err, data) => {
632+
wpt.runTest('https://docs.webpagetest.org/api/integrations/', {pollResults: 5, timeout: 60}, (err, data) => {
612633
console.log(err || data);
613634
});
614635
```
615636

616-
#### Or run test on http://marcelduran.com/webpagetest-api and wait results listening on localhost\* port 8000\*\*
637+
#### Or run test on https://docs.webpagetest.org/api/integrations/ and wait results listening on localhost\* port 8000\*\*
617638
```javascript
618-
wpt.runTest('http://marcelduran.com/webpagetest-api', {waitResults: 'localhost:8000'}, (err, data) => {
639+
wpt.runTest('https://docs.webpagetest.org/api/integrations/', {waitResults: 'localhost:8000'}, (err, data) => {
619640
console.log(err || data);
620641
});
621642
```
@@ -636,7 +657,7 @@ http://localhost:8080
636657
```
637658
```bash
638659
$ curl http://localhost:8080/help
639-
$ curl http://localhost:8080/test/marcelduran.com/?location=SanJose_IE9
660+
$ curl http://localhost:8080/test/webpagetest.org/?location=SanJose_IE9
640661
```
641662
```bash
642663
$ webpagetest listen 8443 --key key.pem --cert cert.pem --server wpt.foo.com
@@ -674,8 +695,8 @@ $ webpagetest batch commands.txt
674695
```
675696
where `commands.txt` contains:
676697
```
677-
test marcelduran.com --first --location foo
678-
test marcelduran.com --first --location bar
698+
test https://docs.webpagetest.org/api/integrations/ --first --location foo
699+
test https://docs.webpagetest.org/api/integrations/ --first --location bar
679700
```
680701
It schedules the 2 tests above returning an array of size 2 in the same order as in `commands.txt` file:
681702
```javascript
@@ -706,15 +727,15 @@ By running multiple sync tests, i.e. with either `--poll` or `--wait`, all tests
706727

707728
`commands.txt`:
708729
```
709-
test marcelduran.com --first --location foo --poll --timeout 60
710-
test marcelduran.com --first --location bar --poll --timeout 60
730+
test https://docs.webpagetest.org/api/integrations/ --first --location foo --poll --timeout 60
731+
test https://docs.webpagetest.org/api/integrations/ --first --location bar --poll --timeout 60
711732
```
712733

713734
## Test Specs (Continuous Integration)
714735

715736
WebPageTest API Wrapper provides a simple seamless way to integrate WebPageTest with Continuous Integration tools.
716737

717-
[See dedicated page](https://github.com/marcelduran/webpagetest-api/wiki/Test-Specs)
738+
[See dedicated page](https://github.com/WebPageTest/webpagetest-api/wiki/Test-Specs)
718739

719740
## Tests
720741
```bash
@@ -725,18 +746,18 @@ $ npm test
725746

726747
Have a bug/feature request? Please create an issue here on GitHub!
727748

728-
https://github.com/marcelduran/webpagetest-api/issues
749+
https://github.com/WebPageTest/webpagetest-api/issues
729750

730751
## Author
731752

732-
**Marcel Duran**
753+
**WebPageTest**
733754

734-
+ https://github.com/marcelduran
755+
+ https://github.com/WebPageTest
735756

736757
## License
737758

738759
Copyright 2013 Twitter Inc.
739760
Copyright 2020 Google Inc.
740761
Copyright 2020 Marcel Duran and other contributors
741762

742-
Licensed under the [MIT License](https://github.com/marcelduran/webpagetest-api/raw/master/LICENSE)
763+
Licensed under the [MIT License](https://github.com/WebPageTest/webpagetest-api/raw/master/LICENSE)

lib/mapping.js

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,91 @@ var options = {
328328
param: 'bandwidth',
329329
info: 'upload bandwidth in Kbps (used when specifying a custom connectivity profile)'
330330
},
331+
'browserwidth': {
332+
name: 'browserwidth',
333+
key: 'bw',
334+
api: 'browser_width',
335+
param: 'pixels',
336+
info: 'Browser window width (in display pixels)'
337+
},
338+
'browserheight': {
339+
name: 'browserheight',
340+
key: 'bh',
341+
api: 'browser_height',
342+
param: 'pixels',
343+
info: 'Browser window height (in display pixels)'
344+
},
345+
'viewportheight': {
346+
name: 'viewportheight',
347+
key: 'vh',
348+
api: 'height',
349+
param: 'pixels',
350+
info: 'Viewport Height in css pixels'
351+
},
352+
'viewportwidth': {
353+
name: 'viewportwidth',
354+
key: 'vw',
355+
api: 'width',
356+
param: 'pixels',
357+
info: 'Viewport Width in css pixels'
358+
},
359+
'devicetopixelratio' : {
360+
name : 'devicetopixelratio',
361+
key : 'dpr',
362+
api : 'dpr',
363+
param : 'ratio',
364+
info : 'Device To Pixel Ratio'
365+
366+
},
367+
'appendua' : {
368+
name : 'appendua',
369+
key : 'au',
370+
api : 'appendua',
371+
param : 'string',
372+
info : 'String to append to the user agent string. This is in addition to the default PTST/ver string'
373+
},
374+
'testtype' : {
375+
name : 'testtype',
376+
key : 'tt',
377+
api : 'type',
378+
param : 'string',
379+
info : 'For running alternative test types, can specify traceroute or lighthouse'
380+
},
381+
'profiler' : {
382+
name : 'profiler',
383+
key : 'pr',
384+
api : 'profiler',
385+
param : 'number',
386+
info : 'Set to 1 to enable the V8 sampling profiler (Chromium only)'
387+
},
388+
'disableAVIF' : {
389+
name : 'disableAVIF',
390+
key : 'avif',
391+
api : 'disableAVIF',
392+
param : 'number',
393+
info : 'Set to 1 to disable AVIF support (Chromium 88+)'
394+
},
395+
'disableWEBP' : {
396+
name : 'disableWEBP',
397+
key : 'webp',
398+
api : 'disableWEBP',
399+
param : 'number',
400+
info : 'Set to 1 to disable WEBP support (Chromium 88+)'
401+
},
402+
'disableJXL' : {
403+
name : 'disableJXL',
404+
key : 'jxl',
405+
api : 'disableJXL',
406+
param : 'number',
407+
info : 'Set to 1 to disable JpegXL support (Chromium 88+)'
408+
},
409+
'dtShaper' : {
410+
name : 'dtShaper',
411+
key : 'dts',
412+
api : 'dtShaper',
413+
param : 'number',
414+
info : "Set to 1 to use Chrome's built-in traffic-shaping instead of the packet-level netem shaping usually used by the test agents"
415+
},
331416
'latency': {
332417
name: 'latency',
333418
key: 'Y',

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"name": "webpagetest",
33
"version": "0.4.0",
44
"description": "WebPageTest API wrapper for NodeJS",
5-
"author": "Marcel Duran <github@marcelduran.com> (http://github.com/marcelduran)",
6-
"homepage": "http://github.com/marcelduran/webpagetest-api",
5+
"author": "WebPageTest <github@WebPageTest.com> (http://github.com/WebPageTest)",
6+
"homepage": "http://github.com/WebPageTest/webpagetest-api",
77
"keywords": [
88
"webpagetest",
99
"api",
@@ -14,10 +14,10 @@
1414
"license": "MIT",
1515
"repository": {
1616
"type": "git",
17-
"url": "git://github.com/marcelduran/webpagetest-api.git"
17+
"url": "git://github.com/WebPageTest/webpagetest-api.git"
1818
},
1919
"bugs": {
20-
"url": "http://github.com/marcelduran/webpagetest-api/issues"
20+
"url": "http://github.com/WebPageTest/webpagetest-api/issues"
2121
},
2222
"main": "lib/webpagetest.js",
2323
"bin": "bin/webpagetest",

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ Options:
8686
specifying a custom connectivity profile)
8787
-U, --bwup <bandwidth> upload bandwidth in Kbps (used when
8888
specifying a custom connectivity profile)
89+
-bw, --browserwidth <pixels> Browser window width (in display pixels)
90+
-bh, --browserheight <pixels> Browser window height (in display pixels)
91+
-vh, --viewportheight <pixels> Viewport Height in css pixels
92+
-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
89101
-Y, --latency <time> first-hop Round Trip Time in ms (used
90102
when specifying a custom connectivity
91103
profile)

0 commit comments

Comments
 (0)