Skip to content

Commit 69a7cf0

Browse files
committed
added missing aliases
1 parent 79dbe57 commit 69a7cf0

4 files changed

Lines changed: 51 additions & 22 deletions

File tree

lib/helper.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ function setQuery(map, options, query) {
214214
if (param.array) {
215215
value = [].concat(value).join(' ');
216216
}
217-
query[param.api] = param.bool ? (value ? 1 : 0) : value;
217+
query[param.api] = param.bool ? param.invert ?
218+
(value ? 0 : 1) : (value ? 1 : 0) : value;
218219
}
219220
});
220221
});

lib/mapping.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ var options = {
452452
},
453453
'requests': {
454454
name: 'requests',
455+
api: 'requests',
455456
key: 'R',
456457
param: 'items',
457458
info: 'filter requests (e.g.:1,2,3,4-9,8) [all]'

lib/webpagetest.js

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,9 @@ function setFilename(input, options) {
182182

183183
options = options || {};
184184

185-
run = parseInt(options.run, 10) || 1;
186-
cached = options.repeatView ? filenames.cached : '';
185+
run = parseInt(options.run || options.r, 10) || 1;
186+
cached = (options.repeatView || options.cached || options.c) ?
187+
filenames.cached : '';
187188

188189
if (typeof input === 'string') {
189190
return run + cached + '_' + input;
@@ -496,37 +497,29 @@ function getTestInfo(id, options, callback) {
496497
}
497498

498499
function getWaterfallImage(id, options, callback) {
499-
var params,
500+
var query,
500501
pathname = paths.waterfall;
501502

502503
callback = callback || options;
503504
options = options === callback ? {} : options;
504-
params = setFilename({test: id}, options),
505+
query = setFilename({test: id}, options),
505506
options.encoding = options.encoding || 'binary';
507+
options.dataURI = options.dataURI || options.uri || options.u;
506508
options.parser = options.parser ||
507509
(options.dataURI ? helper.dataURI : undefined);
508510
options.args = options.args || {
509511
type: 'image/png',
510512
encoding: options.dataURI ? 'utf8' : options.encoding
511513
};
512514

513-
if (options.thumbnail) {
515+
if (options.thumbnail || options.t) {
514516
pathname = paths.thumbnail;
515-
params.file = setFilename(filenames.waterfall, options);
517+
query.file = setFilename(filenames.waterfall, options);
516518
}
517519

518-
Object.keys(mapping.options.waterfall).forEach(function wfParamsEach(key) {
519-
var param = mapping.options.waterfall[key],
520-
name = param.name,
521-
value = options[name] || options[key];
522-
523-
if (value !== undefined) {
524-
params[param.api || name] =
525-
param.bool ? param.invert ? (value ? 0 : 1) : (value ? 1 : 0) : value;
526-
}
527-
});
520+
helper.setQuery(mapping.commands.waterfall, options, query);
528521

529-
return api.call(this, pathname, callback, params, options);
522+
return api.call(this, pathname, callback, query, options);
530523
}
531524

532525
function getScreenshotImage(id, options, callback) {
@@ -538,14 +531,15 @@ function getScreenshotImage(id, options, callback) {
538531
callback = callback || options;
539532
options = options === callback ? {} : options;
540533
options.encoding = options.encoding || 'binary';
534+
options.dataURI = options.dataURI || options.uri || options.u;
541535
options.parser = options.parser ||
542536
(options.dataURI ? helper.dataURI : undefined);
543537

544-
if (options.startRender) {
538+
if (options.startRender || options.render || options.n) {
545539
filename = filenames.screenshotStartRender;
546-
} else if (options.documentComplete) {
540+
} else if (options.documentComplete || options.complete || options.p) {
547541
filename = filenames.screenshotDocumentComplete;
548-
} else if (options.fullResolution) {
542+
} else if (options.fullResolution || options.full || options.f) {
549543
filename = filenames.screenshotFullResolution;
550544
type = 'png';
551545
}
@@ -556,7 +550,7 @@ function getScreenshotImage(id, options, callback) {
556550

557551
params.file = setFilename(filename, options);
558552

559-
if (options.thumbnail) {
553+
if (options.thumbnail || options.t) {
560554
pathname = paths.thumbnail;
561555
params = setFilename(params, options);
562556
}

test/dryrun-test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,5 +299,38 @@ describe('Dry Run', function() {
299299
});
300300
});
301301

302+
it('gets a customized waterfall image request with aliases', function(done) {
303+
wpt.waterfall('120816_V2_2', {
304+
type: 'connection',
305+
mime: true,
306+
width: 640,
307+
max: 9,
308+
R: '1,2,4,6-8',
309+
C: true,
310+
b: true,
311+
noellipsis: true,
312+
l: true,
313+
dryRun: true
314+
}, function (err, data) {
315+
if (err) return done(err);
316+
assert.equal(data.url, wptServer + 'waterfall.php?test=120816_V2_2&run=1&cached=0&type=connection&mime=1&width=640&max=9&dots=0&requests=1%2C2%2C4%2C6-8&cpu=0&bw=0&labels=0');
317+
done();
318+
});
319+
});
320+
321+
it('gets a screenshot thumbnail request with aliases', function(done) {
322+
wpt.screenshot('120816_V2_2', {
323+
cached: true,
324+
r: 2,
325+
t: true,
326+
complete: true,
327+
dryRun: true
328+
}, function (err, data) {
329+
if (err) return done(err);
330+
assert.equal(data.url, wptServer + 'thumbnail.php?test=120816_V2_2&file=2_Cached_screen_doc.jpg&run=2&cached=1');
331+
done();
332+
});
333+
});
334+
302335
});
303336
});

0 commit comments

Comments
 (0)