browsertime 16.7.0 → 16.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/bin/browsertime.js +3 -0
- package/lib/chrome/webdriver/setupChromiumOptions.js +4 -0
- package/lib/core/engine/command/debug.js +47 -0
- package/lib/core/engine/iteration.js +19 -3
- package/lib/firefox/webdriver/builder.js +10 -2
- package/lib/support/cli.js +25 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
# Browsertime changelog (we do [semantic versioning](https://semver.org))
|
|
2
2
|
|
|
3
|
+
## 16.8.0 - 2022-06-06
|
|
4
|
+
### Added
|
|
5
|
+
* Add `--debug` mode. Debug mode will run your tests and open devtools in Chrome/Edge/Firefox on desktop and will stop after each iteration so you can inspect the page. You can add your own breakpoint in your script with the `breakpoint(name)` command. To continue after your breakpoint, add the following code in the developer console in your browser: `window.browsertime.pause=false;` [#1798](https://github.com/sitespeedio/browsertime/pull/1798).
|
|
6
|
+
* Use Selenium WebDriver 4.2.0 [#1801](https://github.com/sitespeedio/browsertime/pull/1801).
|
|
7
|
+
* Updated to Firefox 101, Edge 102 in the Docker container.
|
|
8
|
+
|
|
9
|
+
### Tech
|
|
10
|
+
* Added tests using NodeJS 18 [#1772](https://github.com/sitespeedio/browsertime/pull/1772).
|
|
3
11
|
## 16.7.0 - 2022-05-20
|
|
4
12
|
### Added
|
|
5
|
-
*
|
|
13
|
+
* Include last CPU long task in the HAR file so we can show when it happens [#1793](https://github.com/sitespeedio/browsertime/pull/1793).
|
|
6
14
|
* Inlclude TTFB and INP in the Google Web Vital namespace [#1792](https://github.com/sitespeedio/browsertime/pull/1792).
|
|
7
15
|
## 16.6.0 - 2022-05-20
|
|
8
16
|
### Added
|
package/bin/browsertime.js
CHANGED
|
@@ -99,6 +99,10 @@ module.exports = function (seleniumOptions, browserOptions, options, baseDir) {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
if (options.debug) {
|
|
103
|
+
seleniumOptions.addArguments('--auto-open-devtools-for-tabs');
|
|
104
|
+
}
|
|
105
|
+
|
|
102
106
|
const perfLogConf = { enableNetwork: true, enablePage: true };
|
|
103
107
|
seleniumOptions.setPerfLoggingPrefs(perfLogConf);
|
|
104
108
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const log = require('intel').getLogger('browsertime.command.debug');
|
|
4
|
+
const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
5
|
+
|
|
6
|
+
class Debug {
|
|
7
|
+
constructor(browser, options) {
|
|
8
|
+
this.browser = browser;
|
|
9
|
+
this.options = options;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Add a breakpoint to script. The browser will wait at the breakpoint for user input.
|
|
14
|
+
* @returns {Promise} Promise object that is fulfilled when the user move on from the breakpoint.
|
|
15
|
+
*/
|
|
16
|
+
async breakpoint(name) {
|
|
17
|
+
if (this.options.debug) {
|
|
18
|
+
const logMessage = `Pausing for breakpoint ${
|
|
19
|
+
name || ''
|
|
20
|
+
}, set browsertime.pause = false; to continue`;
|
|
21
|
+
|
|
22
|
+
await this.browser.runScript(
|
|
23
|
+
`console.log('${logMessage}');`,
|
|
24
|
+
'CONSOLE_LOG'
|
|
25
|
+
);
|
|
26
|
+
log.info(logMessage);
|
|
27
|
+
let debug = true;
|
|
28
|
+
await this.browser.runScript(
|
|
29
|
+
'window.browsertime = {}; window.browsertime.pause = true',
|
|
30
|
+
'PAUSE_SCRIPT'
|
|
31
|
+
);
|
|
32
|
+
while (debug === true) {
|
|
33
|
+
debug = await this.browser.runScript(
|
|
34
|
+
'return window.browsertime.pause',
|
|
35
|
+
'GET_PAUSE_STATUS'
|
|
36
|
+
);
|
|
37
|
+
await delay(1000);
|
|
38
|
+
}
|
|
39
|
+
return this.browser.runScript(
|
|
40
|
+
'window.browsertime.pause = false',
|
|
41
|
+
'SET_PAUSE_STATUS'
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = Debug;
|
|
@@ -22,6 +22,7 @@ const Cache = require('./command/cache.js');
|
|
|
22
22
|
const Meta = require('./command/meta.js');
|
|
23
23
|
const StopWatch = require('./command/stopWatch.js');
|
|
24
24
|
const Select = require('./command/select.js');
|
|
25
|
+
const Debug = require('./command/debug.js');
|
|
25
26
|
const AndroidCommand = require('./command/android.js');
|
|
26
27
|
const ChromeDevToolsProtocol = require('./command/chromeDevToolsProtocol.js');
|
|
27
28
|
const { addConnectivity, removeConnectivity } = require('../../connectivity');
|
|
@@ -148,7 +149,7 @@ class Iteration {
|
|
|
148
149
|
|
|
149
150
|
const cdp = new ChromeDevToolsProtocol(engineDelegate, options.browser);
|
|
150
151
|
const android = new Android(options);
|
|
151
|
-
|
|
152
|
+
const debug = new Debug(browser, options);
|
|
152
153
|
const commands = {
|
|
153
154
|
click: new Click(browser, this.pageCompleteCheck),
|
|
154
155
|
scroll: new Scroll(browser, options),
|
|
@@ -172,6 +173,7 @@ class Iteration {
|
|
|
172
173
|
screenshot: new Screenshot(screenshotManager, browser, index),
|
|
173
174
|
cdp,
|
|
174
175
|
android: new AndroidCommand(options),
|
|
176
|
+
debug: debug,
|
|
175
177
|
mouse: {
|
|
176
178
|
moveTo: new MouseMove(browser),
|
|
177
179
|
contextClick: new ContextClick(browser),
|
|
@@ -244,7 +246,17 @@ class Iteration {
|
|
|
244
246
|
}
|
|
245
247
|
|
|
246
248
|
await engineDelegate.beforeBrowserStop(browser, index, result);
|
|
247
|
-
|
|
249
|
+
|
|
250
|
+
// if we are in debig mode we wait on a continue command
|
|
251
|
+
if (options.debug) {
|
|
252
|
+
await debug.breakpoint('End-of-iteration');
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (options.browser === 'firefox' && options.debug) {
|
|
256
|
+
log.info('Firefox is kept open in debug mode');
|
|
257
|
+
} else {
|
|
258
|
+
await browser.stop();
|
|
259
|
+
}
|
|
248
260
|
// Give the browsers some time to stop
|
|
249
261
|
await delay(2000);
|
|
250
262
|
await engineDelegate.afterBrowserStopped();
|
|
@@ -329,7 +341,11 @@ class Iteration {
|
|
|
329
341
|
if (options.connectivity.variance) {
|
|
330
342
|
await removeConnectivity(options);
|
|
331
343
|
}
|
|
332
|
-
|
|
344
|
+
if (options.browser === 'firefox' && options.debug) {
|
|
345
|
+
log.info('Firefox is kept open in debug mode');
|
|
346
|
+
} else {
|
|
347
|
+
await browser.stop();
|
|
348
|
+
}
|
|
333
349
|
} catch (e) {
|
|
334
350
|
// Most cases the browser been stopped already
|
|
335
351
|
}
|
|
@@ -103,6 +103,12 @@ module.exports.configureBuilder = function (builder, baseDir, options) {
|
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
if (options.debug) {
|
|
107
|
+
ffOptions.addArguments('--devtools');
|
|
108
|
+
// Mozilla use detach to make sure you can inspect the browser
|
|
109
|
+
ffOptions.setPreference('detach', true);
|
|
110
|
+
}
|
|
111
|
+
|
|
106
112
|
if (!options.skipHar) {
|
|
107
113
|
if (options.android) {
|
|
108
114
|
log.info('Skip install HAR trigger on Android');
|
|
@@ -110,8 +116,10 @@ module.exports.configureBuilder = function (builder, baseDir, options) {
|
|
|
110
116
|
// Hack for opening the toolbar
|
|
111
117
|
// In Firefox 61 we need to have devtools open but do not need to choose netmonitor
|
|
112
118
|
// ffOptions.setPreference('devtools.toolbox.selectedTool', 'netmonitor');
|
|
113
|
-
|
|
114
|
-
|
|
119
|
+
if (!options.debug) {
|
|
120
|
+
ffOptions.setPreference('devtools.toolbox.footer.height', 0);
|
|
121
|
+
ffOptions.addArguments('-devtools');
|
|
122
|
+
}
|
|
115
123
|
|
|
116
124
|
ffOptions.addExtensions(
|
|
117
125
|
path.resolve(
|
package/lib/support/cli.js
CHANGED
|
@@ -75,6 +75,18 @@ function validateInput(argv) {
|
|
|
75
75
|
return 'You need to specify the --safari.deviceUDID when you run the simulator.';
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
if (argv.debug && argv.browser === 'safari') {
|
|
79
|
+
return 'Debug mode do not work in Safari. Please try with Firefox/Chrome or Edge';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (argv.debug && argv.android) {
|
|
83
|
+
return 'Debug mode do not work on Android. Please run debug mode on Desktop.';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (argv.debug && argv.docker) {
|
|
87
|
+
return 'There is no benefit running debug mode inside a Docker container.';
|
|
88
|
+
}
|
|
89
|
+
|
|
78
90
|
if (argv.tcpdump) {
|
|
79
91
|
if (!hasbin.all.sync(['tcpdump'])) {
|
|
80
92
|
return 'You need to have tcpdump in your path to be able to record a tcpdump.';
|
|
@@ -1159,6 +1171,12 @@ module.exports.parseCommandLine = function parseCommandLine() {
|
|
|
1159
1171
|
describe:
|
|
1160
1172
|
'The wait time before you start the real testing after your pre-cache request.'
|
|
1161
1173
|
})
|
|
1174
|
+
.option('debug', {
|
|
1175
|
+
type: 'boolean',
|
|
1176
|
+
default: false,
|
|
1177
|
+
describe: 'Run Browsertime in debug mode.',
|
|
1178
|
+
group: 'debug'
|
|
1179
|
+
})
|
|
1162
1180
|
|
|
1163
1181
|
.count('verbose')
|
|
1164
1182
|
.config(config)
|
|
@@ -1253,6 +1271,13 @@ module.exports.parseCommandLine = function parseCommandLine() {
|
|
|
1253
1271
|
set(argv, 'visualMetrics', get(argv, 'visualMetrics', true));
|
|
1254
1272
|
}
|
|
1255
1273
|
|
|
1274
|
+
// Set the timeouts to a maximum while debugging
|
|
1275
|
+
if (argv.debug) {
|
|
1276
|
+
set(argv, 'timeouts.pageload', 2147483647);
|
|
1277
|
+
set(argv, 'timeouts.script', 2147483647);
|
|
1278
|
+
set(argv, 'timeouts.pageCompleteCheck', 2147483647);
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1256
1281
|
return {
|
|
1257
1282
|
urls: argv._,
|
|
1258
1283
|
options: argv
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "Browsertime",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.8.0",
|
|
4
4
|
"bin": "./bin/browsertime.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@cypress/xvfb": "1.2.4",
|
|
7
7
|
"@devicefarmer/adbkit": "2.11.3",
|
|
8
|
-
"@sitespeed.io/chromedriver": "
|
|
8
|
+
"@sitespeed.io/chromedriver": "102.0.5005-27",
|
|
9
9
|
"@sitespeed.io/edgedriver": "101.0.1210-32",
|
|
10
10
|
"@sitespeed.io/geckodriver": "0.31.0",
|
|
11
11
|
"@sitespeed.io/throttle": "3.1.1",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"lodash.merge": "4.6.2",
|
|
27
27
|
"lodash.pick": "4.4.0",
|
|
28
28
|
"lodash.set": "4.3.2",
|
|
29
|
-
"selenium-webdriver": "4.
|
|
29
|
+
"selenium-webdriver": "4.2.0",
|
|
30
30
|
"yargs": "17.4.1"
|
|
31
31
|
},
|
|
32
32
|
"optionalDependencies": {
|