From 305c76008294ba844655c1cced196f620abd265c Mon Sep 17 00:00:00 2001 From: Siddhant Shukla <70441430+Siddhantshukla814@users.noreply.github.com> Date: Fri, 4 Mar 2022 22:00:20 +0530 Subject: [PATCH] Updated package.json & help-test.txt --- lib/webpagetest.js | 689 ++++++++++++++--------- package.json | 12 +- test/fixtures/command-line/help-test.txt | 2 +- 3 files changed, 424 insertions(+), 279 deletions(-) diff --git a/lib/webpagetest.js b/lib/webpagetest.js index 8d53504..d098d95 100644 --- a/lib/webpagetest.js +++ b/lib/webpagetest.js @@ -5,158 +5,163 @@ * Released under the MIT License */ -var http = require('http'), - https = require('https'), - url = require('url'), - path = require('path'), - zlib = require('zlib'), - specs = require('./specs'), - helper = require('./helper'), - server = require('./server'), - mapping = require('./mapping'); +var http = require("http"), + https = require("https"), + url = require("url"), + path = require("path"), + zlib = require("zlib"), + specs = require("./specs"), + helper = require("./helper"), + server = require("./server"), + mapping = require("./mapping"); var reSpace = /\s/, - reConnectivity = /^(?:Cable|DSL|3GSlow|3G|3GFast|4G|LTE|Edge|2G|Dial|FIOS|Native|custom)$/, - reHTMLOutput = /([^<]+)<\/h\d>/; // for H3 on cancelTest.php + reConnectivity = + /^(?:Cable|DSL|3GSlow|3G|3GFast|4G|LTE|Edge|2G|Dial|FIOS|Native|custom)$/, + reHTMLOutput = /([^<]+)<\/h\d>/; // for H3 on cancelTest.php var paths = { - testStatus: 'testStatus.php', - testResults: 'jsonResult.php', - locations: 'getLocations.php', - testers: 'getTesters.php', - testBalance: 'testBalance.php', - test: 'runtest.php', - gzip: 'getgzip.php', - har: 'export.php', - waterfall: 'waterfall.php', - thumbnail: 'thumbnail.php', - cancel: 'cancelTest.php', - history: 'testlog.php', - videoCreation: 'video/create.php', - videoView: 'video/view.php', - googleCsi: 'google/google_csi.php', - responseBody: 'response_body.php', - timeline: 'getTimeline.php' + testStatus: "testStatus.php", + testResults: "jsonResult.php", + locations: "getLocations.php", + testers: "getTesters.php", + testBalance: "testBalance.php", + test: "runtest.php", + gzip: "getgzip.php", + har: "export.php", + waterfall: "waterfall.php", + thumbnail: "thumbnail.php", + cancel: "cancelTest.php", + history: "testlog.php", + videoCreation: "video/create.php", + videoView: "video/view.php", + googleCsi: "google/google_csi.php", + responseBody: "response_body.php", + timeline: "getTimeline.php", }; var filenames = { - pageSpeed: 'pagespeed.txt', - utilization: 'progress.csv', - request: 'IEWTR.txt', - netLog: 'netlog.txt', - chromeTrace: 'trace.json', - consoleLog: 'console_log.json', - testInfo: 'testinfo.json', - history: 'history.csv', - waterfall: 'waterfall.png', - screenshot: 'screen.jpg', - screenshotStartRender: 'screen_render.jpg', - screenshotDocumentComplete: 'screen_doc.jpg', - screenshotFullResolution: 'screen.png', - cached: '_Cached' + pageSpeed: "pagespeed.txt", + utilization: "progress.csv", + request: "IEWTR.txt", + netLog: "netlog.txt", + chromeTrace: "trace.json", + consoleLog: "console_log.json", + testInfo: "testinfo.json", + history: "history.csv", + waterfall: "waterfall.png", + screenshot: "screen.jpg", + screenshotStartRender: "screen_render.jpg", + screenshotDocumentComplete: "screen_doc.jpg", + screenshotFullResolution: "screen.png", + cached: "_Cached", }; // GET helper function function get(config, pathname, proxy, agent, callback, encoding) { - var protocol, - options; + var protocol, options; if (proxy) { var proxyUrl = url.parse(proxy); - var pathForProxy = config.protocol + '//'; + var pathForProxy = config.protocol + "//"; if (config.auth) { - pathForProxy += config.auth + '@'; + pathForProxy += config.auth + "@"; } - pathForProxy += config.hostname + ':' + config.port + pathname; - protocol = (proxyUrl.protocol === 'https:' ? https : http); + pathForProxy += config.hostname + ":" + config.port + pathname; + protocol = proxyUrl.protocol === "https:" ? https : http; options = { host: proxyUrl.hostname, port: proxyUrl.port, path: pathForProxy, headers: { - Host: config.hostname - } + Host: config.hostname, + }, }; } else { - protocol = (config.protocol === 'https:' ? https : http); + protocol = config.protocol === "https:" ? https : http; options = { path: pathname, host: config.hostname, auth: config.auth, port: config.port, - headers: {} + headers: {}, }; } - if (encoding !== 'binary') { - options.headers['accept-encoding'] = 'gzip,deflate'; + if (encoding !== "binary") { + options.headers["accept-encoding"] = "gzip,deflate"; } if (agent) { options.agent = agent; } - return protocol.get(options, function getResponse(res) { - var data, length, + return protocol + .get(options, function getResponse(res) { + var data, + length, statusCode = res.statusCode; - if (statusCode !== 200) { - callback( - new helper.WPTAPIError(statusCode, http.STATUS_CODES[statusCode]) - ); - } else { - data = []; - length = 0; + if (statusCode !== 200) { + callback( + new helper.WPTAPIError(statusCode, http.STATUS_CODES[statusCode]) + ); + } else { + data = []; + length = 0; - encoding = res.headers['content-encoding'] || encoding || 'uft8'; + encoding = res.headers["content-encoding"] || encoding || "uft8"; - res.on('data', function onData(chunk) { - data.push(chunk); - length += chunk.length; - }); + res.on("data", function onData(chunk) { + data.push(chunk); + length += chunk.length; + }); - res.on('end', function onEnd() { - var i, len, pos, + res.on("end", function onEnd() { + var i, + len, + pos, buffer = new Buffer.alloc(length), - type = (res.headers['content-type'] || '').split(';')[0]; + type = (res.headers["content-type"] || "").split(";")[0]; - for (i = 0, len = data.length, pos = 0; i < len; i += 1) { - data[i].copy(buffer, pos); - pos += data[i].length; - } + for (i = 0, len = data.length, pos = 0; i < len; i += 1) { + data[i].copy(buffer, pos); + pos += data[i].length; + } - if (encoding === 'gzip' || encoding === 'deflate') { - // compressed response (gzip,deflate) - zlib.unzip(buffer, function unzip(err, buffer) { - if (err) { - callback(err); - } else { - callback(undefined, buffer.toString(), { - type: type, - encoding: encoding - }); - } - }); - } else { - // uncompressed response - callback(undefined, buffer, { - type: type, - encoding: encoding - }); - } - }); - } - }).on('error', function onError(err) { - callback(err); - }); + if (encoding === "gzip" || encoding === "deflate") { + // compressed response (gzip,deflate) + zlib.unzip(buffer, function unzip(err, buffer) { + if (err) { + callback(err); + } else { + callback(undefined, buffer.toString(), { + type: type, + encoding: encoding, + }); + } + }); + } else { + // uncompressed response + callback(undefined, buffer, { + type: type, + encoding: encoding, + }); + } + }); + } + }) + .on("error", function onError(err) { + callback(err); + }); } // execute callback properly normalizing optional args function callbackYield(callback, err, data, options) { - if (typeof callback === 'function') { + if (typeof callback === "function") { callback.apply(callback, [err, data].concat(options.args)); } } @@ -181,54 +186,60 @@ function api(pathname, callback, query, options) { pathname = url.format({ pathname: url.resolve(config.pathname, pathname), - query: query + query: query, }); if (options.dryRun) { - // dry run: return the API url (string) only - if (typeof callback === 'function') { - callback.apply(callback, - [undefined, helper.dryRun(config, pathname)] - ); + if (typeof callback === "function") { + callback.apply(callback, [undefined, helper.dryRun(config, pathname)]); } - } else { - // make the real API call - get.call(this, config, pathname, options.proxy, options.agent, function apiCallback(err, data, info) { - if (!err) { - try { - if (options.parser) { - // async parser - if (options.parser.async) { - return options.parser(data, - asyncParserCallback.bind(callback, options)); + get.call( + this, + config, + pathname, + options.proxy, + options.agent, + function apiCallback(err, data, info) { + if (!err) { + try { + if (options.parser) { + // async parser + if (options.parser.async) { + return options.parser( + data, + asyncParserCallback.bind(callback, options) + ); + } else { + data = options.parser(data); + } } else { - data = options.parser(data); - } - } else { - if (!data) { - data = {}; - } else if (info.type === 'application/json') { - data = JSON.parse(data); - } else if (info.type === 'text/xml') { - return helper.xmlToObj(data, - asyncParserCallback.bind(callback, options)); - } else if (info.type === 'text/html') { - data = {result: (reHTMLOutput.exec(data) || [])[1]}; - } else if (info.type === 'text/plain') { - data = {result: data.toString()}; + if (!data) { + data = {}; + } else if (info.type === "application/json") { + data = JSON.parse(data); + } else if (info.type === "text/xml") { + return helper.xmlToObj( + data, + asyncParserCallback.bind(callback, options) + ); + } else if (info.type === "text/html") { + data = { result: (reHTMLOutput.exec(data) || [])[1] }; + } else if (info.type === "text/plain") { + data = { result: data.toString() }; + } } + } catch (ex) { + err = ex; } - } catch (ex) { - err = ex; } - } - - callbackYield(callback, err, data, options); - }.bind(this), options.encoding); + callbackYield(callback, err, data, options); + }.bind(this), + options.encoding + ); } // chaining @@ -242,19 +253,21 @@ function setFilename(input, options, doNotDefault) { options = options || {}; // set run and cached with or without defaults - run = parseInt(options.run || options.r, 10) || - (doNotDefault ? undefined : 1); - cached = (options.repeatView || options.cached || options.c) ? - filenames.cached : ''; + run = + parseInt(options.run || options.r, 10) || (doNotDefault ? undefined : 1); + cached = + options.repeatView || options.cached || options.c ? filenames.cached : ""; // when falsy, check set default accordingly if (doNotDefault && !cached) { - cached = ['repeatView', 'cached', 'c'].some(function(key) { + cached = ["repeatView", "cached", "c"].some(function (key) { return key in options; - }) ? '' : undefined; + }) + ? "" + : undefined; } - if (typeof input === 'string') { - return run + cached + '_' + input; + if (typeof input === "string") { + return run + cached + "_" + input; } else { if (run !== undefined) { input.run = run; @@ -269,7 +282,7 @@ function setFilename(input, options, doNotDefault) { // Methods function getTestStatus(id, options, callback) { - var query = {test: id}; + var query = { test: id }; callback = callback || options; options = options === callback ? undefined : options; @@ -279,17 +292,20 @@ function getTestStatus(id, options, callback) { } function getTestResults(id, options, callback) { - var query = {test: id}; + var query = { test: id }; - callback = callback || typeof options === 'function' && options; + callback = callback || (typeof options === "function" && options); options = options === callback ? {} : helper.deepClone(options) || {}; helper.setQuery(mapping.commands.results, options, query); // specs if (options.specs && !options.dryRun) { - return api.call(this, paths.testResults, + return api.call( + this, + paths.testResults, specs.bind(this, options.specs, options.reporter, callback), - query, options + query, + options ); } @@ -328,26 +344,28 @@ function getTestBalance(options, callback) { } function runTest(what, options, callback) { + console.log(options); //remove this + var query = {}; callback = callback || options; options = options === callback ? {} : helper.deepClone(options); - + // testing url or script? - query[reSpace.test(what) ? 'script' : 'url'] = what; + query[reSpace.test(what) ? "script" : "url"] = what; // set dummy url when scripting, needed when webdriver script if (query.script) { - query.url = 'https://www.webpagetest.org'; + query.url = "https://www.webpagetest.org"; } helper.setQuery(mapping.commands.test, options, query); // connectivity if (reConnectivity.test(options.connectivity) && query.location) { - query.location += ('.' + options.connectivity); + query.location += "." + options.connectivity; } // json output format - query.f = 'json'; + query.f = "json"; // API key if (!query.k && this.config.key) { @@ -355,8 +373,12 @@ function runTest(what, options, callback) { } // synchronous tests with results - var testId, polling, server, listen, timerout, - resultsOptions = {}; + var testId, + polling, + server, + listen, + timerout, + resultsOptions = {}; function resultsCallback(err, data) { clearTimeout(timerout); @@ -370,14 +392,18 @@ function runTest(what, options, callback) { function poll(err, data) { // poll again when test started but not complete // and not when specs are done testing - if (!err && (!data || data && data.data && - data.statusCode !== 200) && - !(typeof err === 'number' && data === undefined)) { - polling = setTimeout(getTestResults.bind(this, testId, - resultsOptions, poll.bind(this)), options.pollResults); + if ( + !err && + (!data || (data && data.data && data.statusCode !== 200)) && + !(typeof err === "number" && data === undefined) + ) { + polling = setTimeout( + getTestResults.bind(this, testId, resultsOptions, poll.bind(this)), + options.pollResults + ); } else { if (!data) { - data = {testId: testId}; + data = { testId: testId }; } resultsCallback(err, data); } @@ -406,19 +432,19 @@ function runTest(what, options, callback) { clearTimeout(polling); callback({ error: { - code: 'TIMEOUT', + code: "TIMEOUT", testId: testId, - message: 'timeout' - } + message: "timeout", + }, }); } function listener() { query.pingback = url.format({ - protocol: 'http', + protocol: "http", hostname: options.waitResults.hostname, port: options.waitResults.port, - pathname: '/testdone' + pathname: "/testdone", }); api.call(this, paths.test, testCallback.bind(this, null), query, options); @@ -437,7 +463,7 @@ function runTest(what, options, callback) { // poll|wait results options Object.keys(mapping.options.results).forEach(function resultsOpts(key) { var name = mapping.options.results[key].name, - value = options[name] || options[key]; + value = options[name] || options[key]; if (value !== undefined) { resultsOptions[name] = value; @@ -448,40 +474,57 @@ function runTest(what, options, callback) { if (options.pollResults && !options.dryRun) { options.pollResults = parseInt(options.pollResults * 1000, 10) || 5000; - return api.call(this, paths.test, testCallback.bind(this, poll), - query, options); + return api.call( + this, + paths.test, + testCallback.bind(this, poll), + query, + options + ); } // wait results if (options.waitResults && !options.dryRun) { - - options.waitResults = helper.localhost(options.waitResults, - WebPageTest.defaultWaitResultsPort); + options.waitResults = helper.localhost( + options.waitResults, + WebPageTest.defaultWaitResultsPort + ); listen = listener.bind(this); - server = http.createServer(function(req, res) { - var uri = url.parse(req.url, true); - - res.statusCode = 204; - res.end(); + server = http.createServer( + function (req, res) { + var uri = url.parse(req.url, true); + + res.statusCode = 204; + res.end(); + + if (uri.pathname === "/testdone" && uri.query.id === testId) { + server.close( + getTestResults.bind( + this, + uri.query.id, + resultsOptions, + resultsCallback + ) + ); + } + }.bind(this) + ); - if (uri.pathname === '/testdone' && uri.query.id === testId) { - server.close(getTestResults.bind(this, uri.query.id, - resultsOptions, resultsCallback)); - } - }.bind(this)); - - server.on('error', function(err) { - if (['EACCES', 'EADDRINUSE'].indexOf(err.code) > -1) { - // remove old unused listener and bump port for next attempt - server.removeListener('listening', listen); - options.waitResults.port++; - wait.call(this); - } else { - callback(err); - } - }.bind(this)); + server.on( + "error", + function (err) { + if (["EACCES", "EADDRINUSE"].indexOf(err.code) > -1) { + // remove old unused listener and bump port for next attempt + server.removeListener("listening", listen); + options.waitResults.port++; + wait.call(this); + } else { + callback(err); + } + }.bind(this) + ); return wait.call(this); } @@ -490,7 +533,7 @@ function runTest(what, options, callback) { } function restartTest(id, options, callback) { - var query = {resubmit: id}; + var query = { resubmit: id }; callback = callback || options; options = options === callback ? undefined : helper.deepClone(options); @@ -501,7 +544,7 @@ function restartTest(id, options, callback) { } function cancelTest(id, options, callback) { - var query = {test: id}; + var query = { test: id }; callback = callback || options; options = options === callback ? undefined : helper.deepClone(options); @@ -515,17 +558,23 @@ function getPageSpeedData(id, options, callback) { callback = callback || options; options = options === callback ? undefined : options; - return api.call(this, paths.gzip, callback, { - test: id, - file: setFilename(filenames.pageSpeed, options) - }, options); + return api.call( + this, + paths.gzip, + callback, + { + test: id, + file: setFilename(filenames.pageSpeed, options), + }, + options + ); } function getHARData(id, options, callback) { callback = callback || options; options = options === callback ? undefined : options; - return api.call(this, paths.har, callback, {test: id}, options); + return api.call(this, paths.har, callback, { test: id }, options); } function getUtilizationData(id, options, callback) { @@ -533,33 +582,107 @@ function getUtilizationData(id, options, callback) { options = options === callback ? {} : options; options.parser = options.parser || helper.csvToObj; - return api.call(this, paths.gzip, callback, { - test: id, - file: setFilename(filenames.utilization, options) - }, options); + return api.call( + this, + paths.gzip, + callback, + { + test: id, + file: setFilename(filenames.utilization, options), + }, + options + ); } function getRequestData(id, options, callback) { callback = callback || options; options = options === callback ? {} : options; - options.parser = options.parser || helper.tsvToObj.bind(null, [ - '', '', '', 'ip_addr', 'method', 'host', 'url', 'responseCode', 'load_ms', - 'ttfb_ms', 'load_start', 'bytesOut', 'bytesIn', 'objectSize', '', '', - 'expires', 'cacheControl', 'contentType', 'contentEncoding', 'type', - 'socket', '', '', '', '', '', '', '', '', '', '', '', '', '', - 'score_cache', 'score_cdn', 'score_gzip', 'score_cookies', - 'score_keep-alive', '', 'score_minify', 'score_combine', 'score_compress', - 'score_etags', '', 'is_secure', 'dns_ms', 'connect_ms', 'ssl_ms', - 'gzip_total', 'gzip_save', 'minify_total', 'minify_save', 'image_total', - 'image_save', 'cache_time', '', '', '', 'cdn_provider', 'dns_start', - 'dns_end', 'connect_start', 'connect_end', 'ssl_start', 'ssl_end', - 'initiator', 'initiator_line', 'initiator_column']); - - return api.call(this, paths.gzip, callback, { - test: id, - file: setFilename(filenames.request, options) - }, options); + options.parser = + options.parser || + helper.tsvToObj.bind(null, [ + "", + "", + "", + "ip_addr", + "method", + "host", + "url", + "responseCode", + "load_ms", + "ttfb_ms", + "load_start", + "bytesOut", + "bytesIn", + "objectSize", + "", + "", + "expires", + "cacheControl", + "contentType", + "contentEncoding", + "type", + "socket", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "score_cache", + "score_cdn", + "score_gzip", + "score_cookies", + "score_keep-alive", + "", + "score_minify", + "score_combine", + "score_compress", + "score_etags", + "", + "is_secure", + "dns_ms", + "connect_ms", + "ssl_ms", + "gzip_total", + "gzip_save", + "minify_total", + "minify_save", + "image_total", + "image_save", + "cache_time", + "", + "", + "", + "cdn_provider", + "dns_start", + "dns_end", + "connect_start", + "connect_end", + "ssl_start", + "ssl_end", + "initiator", + "initiator_line", + "initiator_column", + ]); + + return api.call( + this, + paths.gzip, + callback, + { + test: id, + file: setFilename(filenames.request, options), + }, + options + ); } function getTimelineData(id, options, callback) { @@ -567,7 +690,7 @@ function getTimelineData(id, options, callback) { callback = callback || options; options = options === callback ? undefined : options; - query = setFilename({test: id}, options, true); + query = setFilename({ test: id }, options, true); return api.call(this, paths.timeline, callback, query, options); } @@ -577,10 +700,16 @@ function getNetLogData(id, options, callback) { options = options === callback ? {} : options; options.parser = options.parser || helper.netLogParser; - return api.call(this, paths.gzip, callback, { - test: id, - file: setFilename(filenames.netLog, options) - }, options); + return api.call( + this, + paths.gzip, + callback, + { + test: id, + file: setFilename(filenames.netLog, options), + }, + options + ); } function getChromeTraceData(id, options, callback) { @@ -588,10 +717,16 @@ function getChromeTraceData(id, options, callback) { options = options === callback ? {} : options; options.parser = options.parser || helper.netLogParser; - return api.call(this, paths.gzip, callback, { - test: id, - file: setFilename(filenames.chromeTrace, options) - }, options); + return api.call( + this, + paths.gzip, + callback, + { + test: id, + file: setFilename(filenames.chromeTrace, options), + }, + options + ); } function getConsoleLogData(id, options, callback) { @@ -599,10 +734,16 @@ function getConsoleLogData(id, options, callback) { options = options === callback ? {} : options; options.parser = options.parser || JSON.parse; - return api.call(this, paths.gzip, callback, { - test: id, - file: setFilename(filenames.consoleLog, options) - }, options); + return api.call( + this, + paths.gzip, + callback, + { + test: id, + file: setFilename(filenames.consoleLog, options), + }, + options + ); } function getTestInfo(id, options, callback) { @@ -610,10 +751,16 @@ function getTestInfo(id, options, callback) { options = options === callback ? {} : options; options.parser = options.parser || JSON.parse; - return api.call(this, paths.gzip, callback, { - test: id, - file: filenames.testInfo - }, options); + return api.call( + this, + paths.gzip, + callback, + { + test: id, + file: filenames.testInfo, + }, + options + ); } function getHistory(days, options, callback) { @@ -623,9 +770,9 @@ function getHistory(days, options, callback) { options = options === callback ? {} : options; options.parser = options.parser || helper.csvParser; query = { - all: 'on', - f: 'csv', - days: days ? parseInt(days, 10) : 1 + all: "on", + f: "csv", + days: days ? parseInt(days, 10) : 1, }; return api.call(this, paths.history, callback, query, options); @@ -637,7 +784,7 @@ function getGoogleCsiData(id, options, callback) { callback = callback || options; options = options === callback ? {} : options; options.parser = options.parser || helper.csvParser; - query = setFilename({test: id}, options, true); + query = setFilename({ test: id }, options, true); return api.call(this, paths.googleCsi, callback, query, options); } @@ -648,9 +795,9 @@ function getResponseBody(id, options, callback) { callback = callback || options; options = options === callback ? {} : options; options.args = options.args || { - type: 'text/plain' + type: "text/plain", }; - query = setFilename({test: id}, options); + query = setFilename({ test: id }, options); query.request = options.request || 1; return api.call(this, paths.responseBody, callback, query, options); @@ -658,18 +805,18 @@ function getResponseBody(id, options, callback) { function getWaterfallImage(id, options, callback) { var query, - pathname = paths.waterfall; + pathname = paths.waterfall; callback = callback || options; options = options === callback ? {} : options; - query = setFilename({test: id}, options), - options.encoding = options.encoding || 'binary'; + (query = setFilename({ test: id }, options)), + (options.encoding = options.encoding || "binary"); options.dataURI = options.dataURI || options.uri || options.u; - options.parser = options.parser || - (options.dataURI ? helper.dataURI : undefined); + options.parser = + options.parser || (options.dataURI ? helper.dataURI : undefined); options.args = options.args || { - type: 'image/png', - encoding: options.dataURI ? 'utf8' : options.encoding + type: "image/png", + encoding: options.dataURI ? "utf8" : options.encoding, }; if (options.thumbnail || options.t) { @@ -684,16 +831,16 @@ function getWaterfallImage(id, options, callback) { function getScreenshotImage(id, options, callback) { var pathname = paths.gzip, - filename = filenames.screenshot, - params = {test: id}, - type = 'jpeg'; + filename = filenames.screenshot, + params = { test: id }, + type = "jpeg"; callback = callback || options; options = options === callback ? {} : options; - options.encoding = options.encoding || 'binary'; + options.encoding = options.encoding || "binary"; options.dataURI = options.dataURI || options.uri || options.u; - options.parser = options.parser || - (options.dataURI ? helper.dataURI : undefined); + options.parser = + options.parser || (options.dataURI ? helper.dataURI : undefined); if (options.startRender || options.render || options.n) { filename = filenames.screenshotStartRender; @@ -701,11 +848,11 @@ function getScreenshotImage(id, options, callback) { filename = filenames.screenshotDocumentComplete; } else if (options.fullResolution || options.full || options.f) { filename = filenames.screenshotFullResolution; - type = 'png'; + type = "png"; } options.args = options.args || { - type: 'image/' + type, - encoding: options.dataURI ? 'utf8' : options.encoding + type: "image/" + type, + encoding: options.dataURI ? "utf8" : options.encoding, }; params.file = setFilename(filename, options); @@ -729,12 +876,12 @@ function listen(local, options, callback) { function getEmbedVideoPlayer(id, options, callback) { var params = { embed: 1, - id: id + id: id, }; options.args = options.args || { - type: 'text/html', - encoding: options.dataURI ? 'utf8' : options.encoding + type: "text/html", + encoding: options.dataURI ? "utf8" : options.encoding, }; options.parser = function (data) { @@ -748,8 +895,8 @@ function createVideo(tests, options, callback) { //prefer the json format because the xml format is buggy with wpt 2.11 var params = { tests: tests, - f: 'json', - end: options.comparisonEndPoint || 'visual' + f: "json", + end: options.comparisonEndPoint || "visual", }; api.call(this, paths.videoCreation, callback, params, options); @@ -768,13 +915,13 @@ function WebPageTest(server, key) { // Allow global config override WebPageTest.paths = paths; WebPageTest.filenames = filenames; -WebPageTest.defaultServer = 'https://www.webpagetest.org'; +WebPageTest.defaultServer = "https://www.webpagetest.org"; WebPageTest.defaultListenPort = 7791; WebPageTest.defaultWaitResultsPort = 8000; // Version -Object.defineProperty(WebPageTest, 'version', { - value: require('../package.json').version +Object.defineProperty(WebPageTest, "version", { + value: require("../package.json").version, }); // Exposed methods @@ -790,7 +937,7 @@ WebPageTest.prototype = { restartTest: restartTest, cancelTest: cancelTest, getPageSpeedData: getPageSpeedData, - getTestBalance : getTestBalance, + getTestBalance: getTestBalance, getHARData: getHARData, getUtilizationData: getUtilizationData, getRequestData: getRequestData, @@ -831,7 +978,7 @@ WebPageTest.prototype = { player: getEmbedVideoPlayer, video: createVideo, waterfall: getWaterfallImage, - screenshot: getScreenshotImage + screenshot: getScreenshotImage, }; module.exports = WebPageTest; diff --git a/package.json b/package.json index bda8f4b..9e97a01 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { - "name": "webpagetest-siddhant", + "name": "webpagetest", "version": "0.5.1", "description": "WebPageTest API wrapper for NodeJS", - "author": "Siddhantshukla814 (http://github.com/Siddhantshukla814)", - "homepage": "http://github.com/Siddhantshukla814/webpagetest-api", + "author": "WebPageTest (http://github.com/WebPageTest)", + "homepage": "http://github.com/WebPageTest/webpagetest-api", "keywords": [ "webpagetest", "api", @@ -14,12 +14,10 @@ "license": "MIT", "repository": { "type": "git", - "url": "git://github.com/WebPageTest/webpagetest-api.git", - "url": "http://github.com/Siddhantshukla814/webpagetest-api" + "url": "git://github.com/WebPageTest/webpagetest-api.git" }, "bugs": { - "url": "http://github.com/WebPageTest/webpagetest-api/issues", - "url": "http://github.com/Siddhantshukla814/webpagetest-api/issues" + "url": "http://github.com/WebPageTest/webpagetest-api/issues" }, "main": "lib/webpagetest.js", "bin": "bin/webpagetest", diff --git a/test/fixtures/command-line/help-test.txt b/test/fixtures/command-line/help-test.txt index fb81949..b6c35d7 100644 --- a/test/fixtures/command-line/help-test.txt +++ b/test/fixtures/command-line/help-test.txt @@ -88,7 +88,7 @@ Options: specifying a custom connectivity profile) -U, --bwup upload bandwidth in Kbps (used when specifying a custom connectivity profile) - -thc, --cputhrottle Custom cpu throttling + -thc, --throttleCPU Custom cpu throttling -bw, --browserwidth Browser window width (in display pixels) -bh, --browserheight Browser window height (in display pixels) -vh, --viewportheight Viewport Height in css pixels