Update browsertime 17.0.0 beta (#3747)

This commit is contained in:
Peter Hedenskog 2022-10-31 21:58:11 +01:00 committed by GitHub
parent 91e99f03e0
commit 84a3498d50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 756 additions and 514 deletions

View File

@ -4,4 +4,7 @@ assets/*
sitespeed-result/* sitespeed-result/*
lib/plugins/yslow/scripts/* lib/plugins/yslow/scripts/*
lib/plugins/html/assets/js/* lib/plugins/html/assets/js/*
lib/plugins/browsertime/index.js
lib/plugins/browsertime/analyzer.js
bin/browsertimeWebPageReplay.js
test/data/* test/data/*

View File

@ -5,7 +5,7 @@
"es6": true "es6": true
}, },
"parserOptions": { "parserOptions": {
"ecmaVersion": 8 "ecmaVersion": 2018
}, },
"plugins": ["prettier"], "plugins": ["prettier"],
"extends": "eslint:recommended", "extends": "eslint:recommended",

View File

@ -1,4 +1,4 @@
FROM sitespeedio/webbrowsers:chrome-106.0-firefox-106.0-edge-106.0 FROM sitespeedio/webbrowsers:chrome-107.0-firefox-106.0-edge-106.0-b
ARG TARGETPLATFORM=linux/amd64 ARG TARGETPLATFORM=linux/amd64

View File

@ -3,7 +3,6 @@
'use strict'; 'use strict';
const yargs = require('yargs'); const yargs = require('yargs');
const browsertime = require('browsertime');
const merge = require('lodash.merge'); const merge = require('lodash.merge');
const getURLs = require('../lib/cli/util').getURLs; const getURLs = require('../lib/cli/util').getURLs;
const get = require('lodash.get'); const get = require('lodash.get');
@ -140,8 +139,15 @@ async function runBrowsertime() {
} }
}; };
const {BrowsertimeEngine, configureLogging} = await import ('browsertime');
const btOptions = merge({}, parsed.argv.browsertime, defaultConfig); const btOptions = merge({}, parsed.argv.browsertime, defaultConfig);
browsertime.logging.configure(parsed.argv); // hack to keep backward compability to --android
if (parsed.argv.android[0] === true) {
set(btOptions, 'android.enabled', true);
}
configureLogging(parsed.argv);
// We have a special hack in sitespeed.io when you set --mobile // We have a special hack in sitespeed.io when you set --mobile
if (parsed.argv.mobile) { if (parsed.argv.mobile) {
@ -171,7 +177,7 @@ async function runBrowsertime() {
); );
} }
} }
const engine = new browsertime.Engine(btOptions); const engine = new BrowsertimeEngine(btOptions);
const urls = getURLs(parsed.argv._); const urls = getURLs(parsed.argv._);
try { try {

View File

@ -276,13 +276,13 @@ module.exports.parseCommandLine = function parseCommandLine() {
describe: 'Send only limited metrics from one run to the datasource.', describe: 'Send only limited metrics from one run to the datasource.',
group: 'Browser' group: 'Browser'
}) })
.option('browsertime.gnirehtet', { .option('browsertime.android.gnirehtet', {
alias: 'gnirehtet', alias: ['gnirehtet', 'browsertime.gnirehtet'],
type: 'boolean', type: 'boolean',
default: false, default: false,
describe: describe:
'Start gnirehtet and reverse tethering the traffic from your Android phone.', 'Start gnirehtet and reverse tethering the traffic from your Android phone.',
group: 'Browser' group: 'Android'
}) })
.option('browsertime.connectivity.profile', { .option('browsertime.connectivity.profile', {
alias: 'c', alias: 'c',
@ -811,32 +811,42 @@ module.exports.parseCommandLine = function parseCommandLine() {
describe: describe:
'Short key to use Android. Will automatically use com.android.chrome for Chrome and stable Firefox. If you want to use another Chrome version, use --chrome.android.package' 'Short key to use Android. Will automatically use com.android.chrome for Chrome and stable Firefox. If you want to use another Chrome version, use --chrome.android.package'
}) })
.option('browsertime.androidRooted', { .option('browsertime.android.rooted', {
alias: 'androidRooted', alias: ['androidRooted', 'browsertime.androidRooted'],
type: 'boolean', type: 'boolean',
default: false, default: false,
describe: describe:
'If your phone is rooted you can use this to set it up following Mozillas best practice for stable metrics.' 'If your phone is rooted you can use this to set it up following Mozillas best practice for stable metrics.',
group: 'Android'
}) })
.option('browsertime.androidBatteryTemperatureLimit', { .option('browsertime.android.batteryTemperatureLimit', {
alias: 'androidBatteryTemperatureLimit', alias: [
'androidBatteryTemperatureLimit',
'browsertime.androidBatteryTemperatureLimit'
],
type: 'integer', type: 'integer',
describe: describe:
'Do the battery temperature need to be below a specific limit before we start the test?' 'Do the battery temperature need to be below a specific limit before we start the test?',
group: 'Android'
}) })
.option('browsertime.androidBatteryTemperatureWaitTimeInSeconds', { .option('browsertime.android.batteryTemperatureWaitTimeInSeconds', {
alias: 'androidBatteryTemperatureWaitTimeInSeconds', alias: [
'androidBatteryTemperatureWaitTimeInSeconds',
'browsertime.androidBatteryTemperatureWaitTimeInSeconds'
],
type: 'integer', type: 'integer',
default: 120, default: 120,
describe: describe:
'How long time to wait (in seconds) if the androidBatteryTemperatureWaitTimeInSeconds is not met before the next try' 'How long time to wait (in seconds) if the androidBatteryTemperatureWaitTimeInSeconds is not met before the next try',
group: 'Android'
}) })
.option('browsertime.androidVerifyNetwork', { .option('browsertime.android.verifyNetwork', {
alias: 'androidVerifyNetwork', alias: ['androidVerifyNetwork', 'browsertime.androidVerifyNetwork'],
type: 'boolean', type: 'boolean',
default: false, default: false,
describe: describe:
'Before a test start, verify that the device has a Internet connection by pinging 8.8.8.8 (or a configurable domain with --androidPingAddress)' 'Before a test start, verify that the device has a Internet connection by pinging 8.8.8.8 (or a configurable domain with --androidPingAddress)',
group: 'Android'
}) })
.option('browsertime.chrome.android.deviceSerial', { .option('browsertime.chrome.android.deviceSerial', {
alias: 'chrome.android.deviceSerial', alias: 'chrome.android.deviceSerial',
@ -1669,6 +1679,10 @@ module.exports.parseCommandLine = function parseCommandLine() {
const aliases = parsed.getOptions().alias, const aliases = parsed.getOptions().alias,
argv = parsed.argv; argv = parsed.argv;
// hack to keep backward compability to --android
if (argv.android[0] === true) {
set(argv, 'browsertime,android.enabled', true);
}
// aliases are long options -> short option // aliases are long options -> short option
const aliasLookup = reduce( const aliasLookup = reduce(
aliases, aliases,

View File

@ -3,14 +3,11 @@
const merge = require('lodash.merge'); const merge = require('lodash.merge');
const forEach = require('lodash.foreach'); const forEach = require('lodash.foreach');
const path = require('path'); const path = require('path');
const browsertime = require('browsertime');
const set = require('lodash.set'); const set = require('lodash.set');
const get = require('lodash.get'); const get = require('lodash.get');
const coach = require('coach-core'); const coach = require('coach-core');
const log = require('intel').getLogger('plugin.browsertime'); const log = require('intel').getLogger('plugin.browsertime');
const browserScripts = browsertime.browserScripts;
const defaultBrowsertimeOptions = { const defaultBrowsertimeOptions = {
statistics: true statistics: true
}; };
@ -55,7 +52,8 @@ async function preWarmServer(urls, options, scriptOrMultiple) {
} }
} }
const engine = new browsertime.Engine(preWarmOptions); const {BrowsertimeEngine} = await import ('browsertime');
const engine = new BrowsertimEngine(preWarmOptions);
await engine.start(); await engine.start();
log.info('Start pre-testing/warming' + urls); log.info('Start pre-testing/warming' + urls);
@ -70,6 +68,7 @@ async function preWarmServer(urls, options, scriptOrMultiple) {
} }
async function parseUserScripts(scripts) { async function parseUserScripts(scripts) {
const {browserScripts} = await import ('browsertime');
if (!Array.isArray(scripts)) scripts = [scripts]; if (!Array.isArray(scripts)) scripts = [scripts];
const allUserScripts = {}; const allUserScripts = {};
for (let script of scripts) { for (let script of scripts) {
@ -142,7 +141,8 @@ module.exports = {
btOptions.userAgent = iphone6UserAgent; btOptions.userAgent = iphone6UserAgent;
} }
} }
const scriptCategories = await browserScripts.allScriptCategories; const {BrowsertimeEngine, browserScripts } = await import ('browsertime');
const scriptCategories = await browserScripts.allScriptCategories();
let scriptsByCategory = await browserScripts.getScriptsForCategories( let scriptsByCategory = await browserScripts.getScriptsForCategories(
scriptCategories scriptCategories
); );
@ -161,7 +161,7 @@ module.exports = {
await preWarmServer(url, btOptions, scriptOrMultiple); await preWarmServer(url, btOptions, scriptOrMultiple);
} }
const engine = new browsertime.Engine(btOptions); const engine = new BrowsertimeEngine(btOptions);
const asyncScript = const asyncScript =
pluginAsyncScripts.length > 0 pluginAsyncScripts.length > 0

View File

@ -1,6 +1,5 @@
'use strict'; 'use strict';
const browsertime = require('browsertime');
const aggregator = require('./aggregator'); const aggregator = require('./aggregator');
const api = require('coach-core'); const api = require('coach-core');
const log = require('intel').getLogger('plugin.browsertime'); const log = require('intel').getLogger('plugin.browsertime');
@ -38,7 +37,6 @@ module.exports = {
this.postChromeTrace = options.postChromeTrace; this.postChromeTrace = options.postChromeTrace;
this.pluginScripts = []; this.pluginScripts = [];
this.pluginAsyncScripts = []; this.pluginAsyncScripts = [];
browsertime.logging.configure(options);
this.screenshotType = get( this.screenshotType = get(
options, options,
'browsertime.screenshotParams.type', 'browsertime.screenshotParams.type',
@ -73,6 +71,8 @@ module.exports = {
this.axeAggregatorTotal = new AxeAggregator(this.options); this.axeAggregatorTotal = new AxeAggregator(this.options);
}, },
async processMessage(message, queue) { async processMessage(message, queue) {
const {configureLogging} = await import ('browsertime');
configureLogging(this.options);
const make = this.make; const make = this.make;
const options = this.options; const options = this.options;
switch (message.type) { switch (message.type) {

1189
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -80,7 +80,7 @@
"@tgwf/co2": "0.11.3", "@tgwf/co2": "0.11.3",
"aws-sdk": "2.1121.0", "aws-sdk": "2.1121.0",
"axe-core": "4.4.3", "axe-core": "4.4.3",
"browsertime": "16.17.0", "browsertime": "17.0.0-beta.2",
"coach-core": "7.1.2", "coach-core": "7.1.2",
"cli-color": "2.0.2", "cli-color": "2.0.2",
"concurrent-queue": "7.0.2", "concurrent-queue": "7.0.2",