Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
launchChrome(headless = this.flags.headless) {
Log.log('Lighthouse runner:', 'Launching Chrome');
const opts = {
chromeFlags: [
'--window-position=40,100',
'--window-size=412,732', // Nexus 5x
headless ? '--headless' : ''
]
};
if (this.flags.chromePath) {
opts.chromePath = this.flags.chromePath;
}
return chromeLauncher.launch(opts);
}
async function launchChrome(port) {
return await launch({
port: port,
chromeFlags: [
'--headless',
'--disable-gpu',
'--disable-extensions',
'--disable-speech-api',
'--disable-signin-scoped-device-id',
'--disable-component-extensions-with-background-pages',
]
});
}
function run(url, flags = {}) {
const config = flags.security
? pageSecurityConfig
: Object.assign({extends: 'lighthouse:default'}, pageSecurityConfig);
return chromeLauncher.launch().then(chrome => {
const resultsPromise = lighthouse(url, Object.assign(flags, {port: chrome.port}), config);
resultsPromise.then(() => chrome.kill());
return resultsPromise;
});
}