Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
connectivity: {
profile: 'native',
downstreamKbps: undefined,
upstreamKbps: undefined,
latency: undefined,
engine: 'external'
},
viewPort: '1366x708',
delay: 0,
video: false,
visualMetrics: false,
resultDir: '/tmp/browsertime'
};
const btOptions = merge({}, parsed.argv.browsertime, defaultConfig);
browsertime.logging.configure(parsed.argv);
// We have a special hack in sitespeed.io when you set --mobile
if (parsed.argv.mobile) {
btOptions.viewPort = '360x640';
btOptions['view-port'] = '360x640';
if (btOptions.browser === 'chrome') {
const emulation = get(
btOptions,
'chrome.mobileEmulation.deviceName',
'iPhone 6'
);
btOptions.chrome.mobileEmulation = {
deviceName: emulation
};
} else {
btOptions.userAgent = iphone6UserAgent;
open(context, options) {
this.make = context.messageMaker('browsertime').make;
this.useAxe = options.axe && options.axe.enable;
this.options = merge({}, defaultConfig, options.browsertime);
this.allOptions = options;
merge(this.options, { verbose: options.verbose });
this.firstParty = options.firstParty;
this.options.mobile = options.mobile;
this.storageManager = context.storageManager;
this.resultUrls = context.resultUrls;
this.postChromeTrace = options.postChromeTrace;
this.pluginScripts = [];
this.pluginAsyncScripts = [];
browsertime.logging.configure(options);
this.screenshotType = get(
options,
'browsertime.screenshotParams.type',
defaultConfig.screenshotParams.type
);
this.scriptOrMultiple = options.multi;
// hack for disabling viewport on Android that's not supported
if (
this.options.chrome &&
this.options.chrome.android &&
this.options.chrome.android.package
) {
this.options.viewPort = undefined;
}
start: function(browser) {
bt.logging.configure({});
runner = new bt.SeleniumRunner({
browser: browser,
'timeouts': {
'browserStart': 20000
}
});
return runner.start();
},
stop: function() {
start: function(browser) {
bt.logging.configure({});
runner = new bt.SeleniumRunner({
browser: browser,
'timeouts': {
'browserStart': 20000
}
});
return runner.start();
},
stop: function() {
'use strict';
let Promise = require('bluebird'),
browsertime = require('browsertime'),
urlParser = require('url'),
fs = require('fs'),
webserver = require('./webserver'),
path = require('path');
Promise.promisifyAll(fs);
browsertime.logging.configure({});
function getScript(ruleFileName, category) {
const domPath = path.resolve(__dirname, '..', '..', 'lib', 'dom'),
utilPath = path.resolve(domPath, 'util.js'),
utilScript = fs.readFileAsync(utilPath, 'utf8'),
rulePath = path.resolve(domPath, category, ruleFileName),
ruleScript = fs.readFileAsync(rulePath, 'utf8');
return Promise.join(
utilScript,
ruleScript,
(utilScript, ruleScript) => utilScript + ' return ' + ruleScript
);
}
module.exports = {
async function runBrowsertime(url, script, options) {
function browsertimeify(script) {
return {
coach: {
domAdvice: script
}
};
}
browsertime.logging.configure(options);
options.resultDir = process.cwd();
const engine = new browsertime.Engine(options);
const scripts = await browsertimeify(script);
await engine.start();
try {
return engine.run(url, scripts);
} finally {
engine.stop();
}
}