Skip to content

Commit 345d39d

Browse files
committed
added dummy url when scripting, needed for webdriver scripts
1 parent aa1cc94 commit 345d39d

6 files changed

Lines changed: 11 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ $ npm test
670670

671671
## Changelog
672672

673+
* 0.3.1: Added dummy url when scripting, needed for webdriver scripting on mobbile agents
673674
* 0.3.0: Replaced xmlResult.php by jsonResult.php WPT API endpoint for fetching test results
674675
* 0.2.5: Added test options: custom, chrometrace, callstack, tester; Added chrometrace command (`getChromeTraceData` method)
675676
* 0.2.4: Added test options: clearcerts, medianvideo, datareduction, useragent and tsview; HTTPS support to listen/proxy server

lib/webpagetest.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ function runTest(what, options, callback) {
300300

301301
// testing url or script?
302302
query[reSpace.test(what) ? 'script' : 'url'] = what;
303+
// set dummy url when scripting, needed when webdriver script
304+
if (query.script) {
305+
query.url = 'http://www.webpagetest.org';
306+
}
303307
helper.setQuery(mapping.commands.test, options, query);
304308

305309
// connectivity

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.3.0",
3+
"version": "0.3.1",
44
"description": "WebPageTest API wrapper for NodeJS",
55
"author": "Marcel Duran <github@marcelduran.com> (http://github.com/marcelduran)",
66
"homepage": "http://github.com/marcelduran/webpagetest-api",

test/command-line-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ describe('WebPageTest Command Line', function() {
126126
exec(mock('test ' + encodeURIComponent(script)), function(err, data) {
127127
if (err) return done(err);
128128
data = JSON.parse(data);
129-
assert.equal(data.url, wptServer + 'runtest.php?script=logData%090%0Anavigate%09http%3A%2F%2Ffoo.com%2Flogin%0A%2F%2F%20log%20some%20data%0AlogData%091%0AsetValue%09name%3Dusername%09johndoe%0AsetValue%09name%3Dpassword%0912345%0AsubmitForm%09action%3Dhttp%3A%2F%2Ffoo.com%2Fmain%0AwaitForComplete&f=json');
129+
assert.equal(data.url, wptServer + 'runtest.php?script=logData%090%0Anavigate%09http%3A%2F%2Ffoo.com%2Flogin%0A%2F%2F%20log%20some%20data%0AlogData%091%0AsetValue%09name%3Dusername%09johndoe%0AsetValue%09name%3Dpassword%0912345%0AsubmitForm%09action%3Dhttp%3A%2F%2Ffoo.com%2Fmain%0AwaitForComplete&url=http%3A%2F%2Fwww.webpagetest.org&f=json');
130130
done();
131131
});
132132
});
@@ -137,7 +137,7 @@ describe('WebPageTest Command Line', function() {
137137
exec(mock('test ' + filename), function(err, data) {
138138
if (err) return done(err);
139139
data = JSON.parse(data);
140-
assert.equal(data.url, wptServer + 'runtest.php?script=logData%090%0Anavigate%09http%3A%2F%2Ffoo.com%2Flogin%0A%2F%2F%20log%20some%20data%0AlogData%091%0AsetValue%09name%3Dusername%09johndoe%0AsetValue%09name%3Dpassword%0912345%0AsubmitForm%09action%3Dhttp%3A%2F%2Ffoo.com%2Fmain%0AwaitForComplete%0A&f=json');
140+
assert.equal(data.url, wptServer + 'runtest.php?script=logData%090%0Anavigate%09http%3A%2F%2Ffoo.com%2Flogin%0A%2F%2F%20log%20some%20data%0AlogData%091%0AsetValue%09name%3Dusername%09johndoe%0AsetValue%09name%3Dpassword%0912345%0AsubmitForm%09action%3Dhttp%3A%2F%2Ffoo.com%2Fmain%0AwaitForComplete%0A&url=http%3A%2F%2Fwww.webpagetest.org&f=json');
141141
done();
142142
});
143143
});

test/dryrun-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ describe('Dry Run', function() {
151151

152152
wpt.runTest(script, {dryRun: true}, function (err, data) {
153153
if (err) return done(err);
154-
assert.equal(data.url, wptServer + 'runtest.php?script=logData%090%0Anavigate%09http%3A%2F%2Ffoo.com%2Flogin%0A%2F%2F%20log%20some%20data%0AlogData%091%0AsetValue%09name%3Dusername%09johndoe%0AsetValue%09name%3Dpassword%0912345%0AsubmitForm%09action%3Dhttp%3A%2F%2Ffoo.com%2Fmain%0AwaitForComplete&f=json');
154+
assert.equal(data.url, wptServer + 'runtest.php?script=logData%090%0Anavigate%09http%3A%2F%2Ffoo.com%2Flogin%0A%2F%2F%20log%20some%20data%0AlogData%091%0AsetValue%09name%3Dusername%09johndoe%0AsetValue%09name%3Dpassword%0912345%0AsubmitForm%09action%3Dhttp%3A%2F%2Ffoo.com%2Fmain%0AwaitForComplete&url=http%3A%2F%2Fwww.webpagetest.org&f=json');
155155
done();
156156
});
157157
});

test/helpers/nock-server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var reqResMap = {
1717
'/getTesters.php': 'testers.xml',
1818
'/runtest.php?url=http%3A%2F%2Ftwitter.com%2Fmarcelduran&f=json': 'runTest.json',
1919
'/runtest.php?url=http%3A%2F%2Ftwitter.com%2Fmarcelduran&location=Local_Firefox_Chrome%3AChrome&runs=3&fvonly=1&label=test%20123&timeline=1&netlog=1&pngss=1&f=json': 'runTest.json',
20-
'/runtest.php?script=logData%090%0Anavigate%09http%3A%2F%2Ffoo.com%2Flogin%0A%2F%2F%20log%20some%20data%0AlogData%091%0AsetValue%09name%3Dusername%09johndoe%0AsetValue%09name%3Dpassword%0912345%0AsubmitForm%09action%3Dhttp%3A%2F%2Ffoo.com%2Fmain%0AwaitForComplete&f=json': 'runTest.json',
20+
'/runtest.php?script=logData%090%0Anavigate%09http%3A%2F%2Ffoo.com%2Flogin%0A%2F%2F%20log%20some%20data%0AlogData%091%0AsetValue%09name%3Dusername%09johndoe%0AsetValue%09name%3Dpassword%0912345%0AsubmitForm%09action%3Dhttp%3A%2F%2Ffoo.com%2Fmain%0AwaitForComplete&url=http%3A%2F%2Fwww.webpagetest.org&f=json': 'runTest.json',
2121
'/getgzip.php?test=120816_V2_2&file=1_pagespeed.txt': 'pageSpeed.json',
2222
'/export.php?test=120816_V2_2': 'har.json',
2323
'/getgzip.php?test=120816_V2_2&file=1_progress.csv': 'utilization.csv',
@@ -55,7 +55,7 @@ var reqResMap = {
5555
'/testStatus.php?test=120816_V2_3': 'testStatusNotFound.json',
5656
'/jsonResult.php?test=120816_V2_3': 'testResultsNotFound.json',
5757
'/runtest.php?url=&f=json': 'runTestInvalid.json',
58-
'/runtest.php?script=&f=json': 'runTestInvalid.json',
58+
'/runtest.php?script=&url=http%3A%2F%2Fwww.webpagetest.org&f=json': 'runTestInvalid.json',
5959
'/getgzip.php?test=120816_V2_3&file=1_pagespeed.txt': '',
6060
'/export.php?test=120816_V2_3': 'harNotFound.json',
6161
'/waterfall.php?test=120816_V2_3&run=1&cached=0': 'waterfallNotFound.png',

0 commit comments

Comments
 (0)