browsertime 14.21.1 → 15.0.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 +12 -1
- package/README.md +5 -5
- package/lib/chrome/webdriver/chromium.js +0 -9
- package/lib/chrome/webdriver/setupChromiumOptions.js +0 -27
- package/lib/connectivity/index.js +0 -9
- package/lib/core/engine/index.js +40 -59
- package/lib/core/engine/iteration.js +5 -2
- package/lib/core/seleniumRunner.js +5 -15
- package/lib/firefox/webdriver/builder.js +0 -14
- package/lib/firefox/webdriver/firefox.js +20 -21
- package/lib/support/cli.js +2 -14
- package/lib/support/dns.js +44 -0
- package/package.json +34 -26
- package/browserscripts/browser/appConstants.js +0 -9
- package/browserscripts/browser/asyncAppConstants.js +0 -11
- package/lib/chrome/speedline.js +0 -84
- package/lib/connectivity/tsProxy.js +0 -108
- package/vendor/tsproxy.py +0 -842
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
# Browsertime changelog (we do [semantic versioning](https://semver.org))
|
|
2
2
|
|
|
3
|
+
## 15.0.0 - 2022-02-20
|
|
4
|
+
### Changed
|
|
5
|
+
* Removed the built in support for TSProxy [#1718](https://github.com/sitespeedio/browsertime/pull/1718). TSProxy only worked with Python 2.7 and we want to remove that dependency.
|
|
6
|
+
* Removed support for using speedline and the CLI arg `--chrome.visualMetricsUsingTrace` [#1727](https://github.com/sitespeedio/browsertime/pull/1727).
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
* Code cleanup: [#1720](https://github.com/sitespeedio/browsertime/pull/1720)
|
|
10
|
+
* Moved test to [Ava](https://avajs.dev) instead of mocha and moved most testing against a local HTTP server instead of internet [#1725](https://github.com/sitespeedio/browsertime/pull/1725).
|
|
3
11
|
|
|
12
|
+
### Added
|
|
13
|
+
* New alias for getting the Chrome trace log: `--chrome.trace` [#1728](https://github.com/sitespeedio/browsertime/pull/1728).
|
|
14
|
+
* On OS X and Linux the DNS will be flushed between runs. You can disable that with `--disableDNSFlush true` [#1732](https://github.com/sitespeedio/browsertime/pull/1732).
|
|
4
15
|
## 14.21.1 - 2022-02-09
|
|
5
16
|
### Fixed
|
|
6
|
-
* Always disable the new
|
|
17
|
+
* Always disable the new ChromeWhaxyNewUI splash screen in Chrome [#1717](https://github.com/sitespeedio/browsertime/pull/1717).
|
|
7
18
|
* Remove the Firefox persist log configuration that was needed for FF 94+ [#1716](https://github.com/sitespeedio/browsertime/pull/1716).
|
|
8
19
|
## 14.21.0 - 2022-02-08
|
|
9
20
|
### Added
|
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Browsertime - Your browser, your page, your scripts!
|
|
2
|
-

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
7
|
[![Downloads][downloads-image]][downloads-url]
|
|
8
8
|
[![Downloads total][downloads-total-image]][downloads-url]
|
|
9
9
|
[![Stars][stars-image]][stars-url]
|
|
@@ -7,7 +7,6 @@ const cpuMetrics = require('../longTaskMetrics');
|
|
|
7
7
|
const fs = require('fs');
|
|
8
8
|
const path = require('path');
|
|
9
9
|
const parseCpuTrace = require('../parseCpuTrace');
|
|
10
|
-
const speedline = require('../speedline');
|
|
11
10
|
const har = require('../har');
|
|
12
11
|
const harBuilder = require('../../support/har');
|
|
13
12
|
const webdriver = require('selenium-webdriver');
|
|
@@ -286,14 +285,6 @@ class Chromium {
|
|
|
286
285
|
const cpu = await parseCpuTrace(trace, result.url);
|
|
287
286
|
result.cpu = cpu;
|
|
288
287
|
|
|
289
|
-
if (
|
|
290
|
-
this.chrome.enableTraceScreenshots &&
|
|
291
|
-
this.chrome.visualMetricsUsingTrace &&
|
|
292
|
-
this.options.cpu
|
|
293
|
-
) {
|
|
294
|
-
result.visualMetrics = speedline(trace, result, index);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
288
|
// Collect render blocking info
|
|
298
289
|
const renderBlockingInfo = {};
|
|
299
290
|
const urlsWithBlockingInfo = trace.traceEvents.filter(
|
|
@@ -137,33 +137,6 @@ module.exports = function (seleniumOptions, browserOptions, options, baseDir) {
|
|
|
137
137
|
seleniumOptions.setMobileEmulation(browserOptions.mobileEmulation);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
const connectivity = options.connectivity || {};
|
|
141
|
-
|
|
142
|
-
if (
|
|
143
|
-
connectivity.engine === 'tsproxy' &&
|
|
144
|
-
connectivity.tsproxy &&
|
|
145
|
-
connectivity.profile !== 'native'
|
|
146
|
-
) {
|
|
147
|
-
if (!connectivity.tsproxy.bind) {
|
|
148
|
-
// If you run tsproxy on desktop instead of throttle or Docker networs
|
|
149
|
-
// Configure SOCKS proxy, see https://www.chromium.org/developers/design-documents/network-stack/socks-proxy
|
|
150
|
-
seleniumOptions.addArguments(
|
|
151
|
-
'--proxy-server=socks5://localhost:' + connectivity.tsproxy.port
|
|
152
|
-
);
|
|
153
|
-
seleniumOptions.addArguments(
|
|
154
|
-
'--host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE localhost"'
|
|
155
|
-
);
|
|
156
|
-
} else {
|
|
157
|
-
// If you run on Android and want to use TSProxy on your desktop
|
|
158
|
-
seleniumOptions.addArguments(
|
|
159
|
-
'--proxy-server=socks://' +
|
|
160
|
-
connectivity.tsproxy.bind +
|
|
161
|
-
':' +
|
|
162
|
-
connectivity.tsproxy.port
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
140
|
// See https://bugs.chromium.org/p/chromium/issues/detail?id=818483
|
|
168
141
|
// Coming again in Chrome 76
|
|
169
142
|
seleniumOptions.excludeSwitches('enable-automation');
|
|
@@ -4,10 +4,8 @@ const trafficShapeParser = require('./trafficShapeParser');
|
|
|
4
4
|
const get = require('lodash.get');
|
|
5
5
|
const throttle = require('@sitespeed.io/throttle');
|
|
6
6
|
const log = require('intel').getLogger('browsertime.connectivity');
|
|
7
|
-
const TSProxy = require('./tsProxy');
|
|
8
7
|
const Humble = require('./humble');
|
|
9
8
|
|
|
10
|
-
let tsProxyInstance = null;
|
|
11
9
|
let humble = null;
|
|
12
10
|
|
|
13
11
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
|
|
@@ -71,10 +69,6 @@ module.exports = {
|
|
|
71
69
|
});
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
|
-
case 'tsproxy': {
|
|
75
|
-
tsProxyInstance = new TSProxy(options);
|
|
76
|
-
return tsProxyInstance.start(profile);
|
|
77
|
-
}
|
|
78
72
|
case 'humble': {
|
|
79
73
|
humble = new Humble(options);
|
|
80
74
|
return humble.start(profile);
|
|
@@ -99,9 +93,6 @@ module.exports = {
|
|
|
99
93
|
const setOnLocalHost = get(connectivity, 'throttle.localhost', false);
|
|
100
94
|
return throttle.stop({ localhost: setOnLocalHost });
|
|
101
95
|
}
|
|
102
|
-
case 'tsproxy': {
|
|
103
|
-
return tsProxyInstance.stop();
|
|
104
|
-
}
|
|
105
96
|
case 'humble': {
|
|
106
97
|
return humble.stop();
|
|
107
98
|
}
|
package/lib/core/engine/index.js
CHANGED
|
@@ -6,7 +6,6 @@ const getPort = require('get-port');
|
|
|
6
6
|
const execa = require('execa');
|
|
7
7
|
const os = require('os');
|
|
8
8
|
const get = require('lodash.get');
|
|
9
|
-
const set = require('lodash.set');
|
|
10
9
|
const StorageManager = require('../../support/storageManager');
|
|
11
10
|
const Firefox = require('../../firefox/webdriver/firefox');
|
|
12
11
|
const Chromium = require('../../chrome/webdriver/chromium');
|
|
@@ -58,46 +57,32 @@ class Engine {
|
|
|
58
57
|
* * Start the extension server
|
|
59
58
|
*/
|
|
60
59
|
async start() {
|
|
61
|
-
|
|
60
|
+
const options = this.options;
|
|
61
|
+
|
|
62
|
+
options.devToolsPort = await getPort({
|
|
62
63
|
port: getPort.makeRange(9222, 9350),
|
|
63
64
|
host: '127.0.0.1'
|
|
64
65
|
});
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
options.safariDriverPort = await getPort({
|
|
67
68
|
port: getPort.makeRange(1234, 2000),
|
|
68
69
|
host: '127.0.0.1'
|
|
69
70
|
});
|
|
70
71
|
|
|
71
|
-
if (
|
|
72
|
-
this.options.browser === 'safari' &&
|
|
73
|
-
this.options.safari.ios &&
|
|
74
|
-
this.options.video
|
|
75
|
-
) {
|
|
72
|
+
if (options.browser === 'safari' && options.safari.ios && options.video) {
|
|
76
73
|
await IOSRecorder.activate();
|
|
77
74
|
await delay(2000);
|
|
78
75
|
}
|
|
79
76
|
|
|
80
|
-
|
|
81
|
-
set(
|
|
82
|
-
this.options,
|
|
83
|
-
'connectivity.tsproxy.port',
|
|
84
|
-
await getPort({
|
|
85
|
-
port: getPort.makeRange(1080, 1099),
|
|
86
|
-
host: '127.0.0.1'
|
|
87
|
-
})
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
if (!this.options.connectivity.variance) {
|
|
91
|
-
await addConnectivity(this.options);
|
|
92
|
-
}
|
|
77
|
+
await addConnectivity(options);
|
|
93
78
|
|
|
94
|
-
if (
|
|
95
|
-
const android = new Android(
|
|
79
|
+
if (options.android) {
|
|
80
|
+
const android = new Android(options);
|
|
96
81
|
await android._init();
|
|
97
82
|
this.android = android;
|
|
98
83
|
|
|
99
|
-
if (
|
|
100
|
-
this.gnirehtet = new Gnirehtet(
|
|
84
|
+
if (options.gnirehtet) {
|
|
85
|
+
this.gnirehtet = new Gnirehtet(options);
|
|
101
86
|
await this.gnirehtet.start();
|
|
102
87
|
}
|
|
103
88
|
|
|
@@ -108,12 +93,12 @@ class Engine {
|
|
|
108
93
|
throw Error(message);
|
|
109
94
|
}
|
|
110
95
|
|
|
111
|
-
if (
|
|
96
|
+
if (options.androidPretestPowerPress) {
|
|
112
97
|
await android.clickPowerButton();
|
|
113
98
|
}
|
|
114
99
|
|
|
115
|
-
if (
|
|
116
|
-
const pingAddress = get(
|
|
100
|
+
if (options.androidVerifyNetwork) {
|
|
101
|
+
const pingAddress = get(options, 'androidPingAddress', '8.8.8.8');
|
|
117
102
|
const connection = await android.ping(pingAddress);
|
|
118
103
|
if (!connection) {
|
|
119
104
|
const message = `No internet connection for ${android.id}. Could not ping ${pingAddress}`;
|
|
@@ -127,7 +112,7 @@ class Engine {
|
|
|
127
112
|
// Make sure screen is on!
|
|
128
113
|
await android._runCommand('svc power stayon true');
|
|
129
114
|
|
|
130
|
-
if (
|
|
115
|
+
if (options.androidRooted) {
|
|
131
116
|
const gotRoot = await android._runCommandAndGet(
|
|
132
117
|
'su - root -c "echo test"'
|
|
133
118
|
);
|
|
@@ -139,14 +124,13 @@ class Engine {
|
|
|
139
124
|
}
|
|
140
125
|
}
|
|
141
126
|
|
|
142
|
-
if (
|
|
143
|
-
const maxTries =
|
|
127
|
+
if (options.androidBatteryTemperatureLimit) {
|
|
128
|
+
const maxTries = options.androidBatteryTemperatureMaxTries || 20;
|
|
144
129
|
let batteryTry = 0;
|
|
145
130
|
let temp = await android.getTemperature();
|
|
146
|
-
const minTempLimit =
|
|
131
|
+
const minTempLimit = options.androidBatteryTemperatureLimit;
|
|
147
132
|
const waitTime =
|
|
148
|
-
(
|
|
149
|
-
1000;
|
|
133
|
+
(options.androidBatteryTemperatureWaitTimeInSeconds || 120) * 1000;
|
|
150
134
|
if (temp > minTempLimit) {
|
|
151
135
|
do {
|
|
152
136
|
temp = await android.getTemperature();
|
|
@@ -164,7 +148,7 @@ class Engine {
|
|
|
164
148
|
minTempLimit,
|
|
165
149
|
maxTries
|
|
166
150
|
);
|
|
167
|
-
if (
|
|
151
|
+
if (options.androidBatteryTemperatureReboot) {
|
|
168
152
|
log.info(
|
|
169
153
|
'Rebooting the device, will wait until ADB sees the device'
|
|
170
154
|
);
|
|
@@ -181,16 +165,13 @@ class Engine {
|
|
|
181
165
|
}
|
|
182
166
|
}
|
|
183
167
|
|
|
184
|
-
if (
|
|
185
|
-
this.options.connectivity &&
|
|
186
|
-
this.options.connectivity.engine === 'humble'
|
|
187
|
-
) {
|
|
168
|
+
if (options.connectivity && options.connectivity.engine === 'humble') {
|
|
188
169
|
const wifiName = await android.getWifi();
|
|
189
170
|
log.info('The phone is using the WiFi: %s', wifiName);
|
|
190
171
|
}
|
|
191
172
|
}
|
|
192
173
|
|
|
193
|
-
if (
|
|
174
|
+
if (options.safari && options.safari.useSimulator) {
|
|
194
175
|
// Start the simulator
|
|
195
176
|
try {
|
|
196
177
|
await execa.command(
|
|
@@ -211,7 +192,7 @@ class Engine {
|
|
|
211
192
|
const types = Object.keys(simulatedDevices.devices);
|
|
212
193
|
for (let type of types) {
|
|
213
194
|
for (let device of simulatedDevices.devices[type]) {
|
|
214
|
-
if (device.udid ===
|
|
195
|
+
if (device.udid === options.safari.deviceUDID) {
|
|
215
196
|
this.iosSimulatorDeviceName = device.name;
|
|
216
197
|
log.info(
|
|
217
198
|
'Running test on %s simulator using %s',
|
|
@@ -241,16 +222,16 @@ class Engine {
|
|
|
241
222
|
let engineDelegate;
|
|
242
223
|
switch (options.browser) {
|
|
243
224
|
case 'firefox':
|
|
244
|
-
engineDelegate = new Firefox(storageManager,
|
|
225
|
+
engineDelegate = new Firefox(storageManager, options);
|
|
245
226
|
break;
|
|
246
227
|
case 'chrome':
|
|
247
|
-
engineDelegate = new Chromium(storageManager,
|
|
228
|
+
engineDelegate = new Chromium(storageManager, options);
|
|
248
229
|
break;
|
|
249
230
|
case 'edge':
|
|
250
|
-
engineDelegate = new Chromium(storageManager,
|
|
231
|
+
engineDelegate = new Chromium(storageManager, options);
|
|
251
232
|
break;
|
|
252
233
|
case 'safari':
|
|
253
|
-
engineDelegate = new Safari(storageManager,
|
|
234
|
+
engineDelegate = new Safari(storageManager, options);
|
|
254
235
|
}
|
|
255
236
|
const iteration = new Iteration(
|
|
256
237
|
storageManager,
|
|
@@ -388,11 +369,11 @@ class Engine {
|
|
|
388
369
|
}
|
|
389
370
|
}
|
|
390
371
|
|
|
391
|
-
if (
|
|
372
|
+
if (options.safari && options.safari.useSimulator) {
|
|
392
373
|
for (let result of totalResult) {
|
|
393
374
|
result.info.ios = {
|
|
394
375
|
deviceName: this.iosSimulatorDeviceName + ' simulator',
|
|
395
|
-
deviceUDID:
|
|
376
|
+
deviceUDID: options.safari.deviceUDID,
|
|
396
377
|
arch: os.arch()
|
|
397
378
|
};
|
|
398
379
|
}
|
|
@@ -410,6 +391,7 @@ class Engine {
|
|
|
410
391
|
}
|
|
411
392
|
|
|
412
393
|
async runMultiple(urlOrFiles, scriptsByCategory, asyncScriptsByCategory) {
|
|
394
|
+
const options = this.options;
|
|
413
395
|
const scripts = [];
|
|
414
396
|
let name;
|
|
415
397
|
for (let urlOrFile of urlOrFiles) {
|
|
@@ -423,17 +405,17 @@ class Engine {
|
|
|
423
405
|
|
|
424
406
|
script = engineUtils.loadScript(script, true);
|
|
425
407
|
if (script.setUp) {
|
|
426
|
-
if (!
|
|
427
|
-
|
|
408
|
+
if (!options.preScript) {
|
|
409
|
+
options.preScript = [];
|
|
428
410
|
}
|
|
429
|
-
|
|
411
|
+
options.preScript.push(script.setUp);
|
|
430
412
|
}
|
|
431
413
|
|
|
432
414
|
if (script.tearDown) {
|
|
433
|
-
if (!
|
|
434
|
-
|
|
415
|
+
if (!options.postScript) {
|
|
416
|
+
options.postScript = [];
|
|
435
417
|
}
|
|
436
|
-
|
|
418
|
+
options.postScript.push(script.tearDown);
|
|
437
419
|
}
|
|
438
420
|
// here, url is the filename containing the script, and test the callable.
|
|
439
421
|
if (script.test) {
|
|
@@ -461,15 +443,14 @@ class Engine {
|
|
|
461
443
|
* * Stop the extension server
|
|
462
444
|
*/
|
|
463
445
|
async stop() {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
}
|
|
446
|
+
const options = this.options;
|
|
447
|
+
await removeConnectivity(options);
|
|
467
448
|
|
|
468
|
-
if (
|
|
449
|
+
if (options.androidRooted && this.rooted) {
|
|
469
450
|
await this.rooted.stop();
|
|
470
451
|
}
|
|
471
452
|
|
|
472
|
-
if (
|
|
453
|
+
if (options.safari && options.safari.useSimulator) {
|
|
473
454
|
try {
|
|
474
455
|
await execa.command('pkill -x Simulator', { shell: true });
|
|
475
456
|
} catch (e) {
|
|
@@ -477,7 +458,7 @@ class Engine {
|
|
|
477
458
|
}
|
|
478
459
|
}
|
|
479
460
|
|
|
480
|
-
if (
|
|
461
|
+
if (options.gnirehtet && this.gnirehtet) {
|
|
481
462
|
await this.gnirehtet.stop();
|
|
482
463
|
}
|
|
483
464
|
|
|
@@ -26,6 +26,7 @@ const AndroidCommand = require('./command/android.js');
|
|
|
26
26
|
const ChromeDevToolsProtocol = require('./command/chromeDevToolsProtocol.js');
|
|
27
27
|
const { addConnectivity, removeConnectivity } = require('../../connectivity');
|
|
28
28
|
const util = require('../../support/util.js');
|
|
29
|
+
const flushDNS = require('../../support/dns.js');
|
|
29
30
|
const {
|
|
30
31
|
SingleClick,
|
|
31
32
|
DoubleClick,
|
|
@@ -101,9 +102,11 @@ class Iteration {
|
|
|
101
102
|
const engineDelegate = this.engineDelegate;
|
|
102
103
|
|
|
103
104
|
try {
|
|
104
|
-
if (options.
|
|
105
|
-
await
|
|
105
|
+
if (!options.disableDNSFlush === true) {
|
|
106
|
+
await flushDNS(options);
|
|
106
107
|
}
|
|
108
|
+
await addConnectivity(options);
|
|
109
|
+
|
|
107
110
|
await engineDelegate.beforeBrowserStart();
|
|
108
111
|
await browser.start();
|
|
109
112
|
await engineDelegate.afterBrowserStart();
|
|
@@ -76,21 +76,11 @@ class SeleniumRunner {
|
|
|
76
76
|
);
|
|
77
77
|
break;
|
|
78
78
|
} catch (e) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
'There is a miss match between Chrome and Chromedriver version. You can manually install the correct Chromedriver version, download the correct version from https://chromedriver.chromium.org/downloads and set the path to the file with --chrome.chromedriverPath see https://www.sitespeed.io/documentation/sitespeed.io/browsers/#use-a-newer-version-of-chromedriver'
|
|
85
|
-
);
|
|
86
|
-
throw e;
|
|
87
|
-
} else {
|
|
88
|
-
log.info(
|
|
89
|
-
`${this.options.browser} failed to start, trying ${
|
|
90
|
-
tries - i - 1
|
|
91
|
-
} more time(s): ${e.message}`
|
|
92
|
-
);
|
|
93
|
-
}
|
|
79
|
+
log.info(
|
|
80
|
+
`${this.options.browser} failed to start, trying ${
|
|
81
|
+
tries - i - 1
|
|
82
|
+
} more time(s): ${e.message}`
|
|
83
|
+
);
|
|
94
84
|
}
|
|
95
85
|
}
|
|
96
86
|
if (!this.driver) {
|
|
@@ -207,20 +207,6 @@ module.exports.configureBuilder = function (builder, baseDir, options) {
|
|
|
207
207
|
builder.getCapabilities().set('acceptInsecureCerts', true);
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
const connectivity = options.connectivity || {};
|
|
211
|
-
|
|
212
|
-
if (
|
|
213
|
-
connectivity.engine === 'tsproxy' &&
|
|
214
|
-
connectivity.tsproxy &&
|
|
215
|
-
connectivity.profile !== 'native'
|
|
216
|
-
) {
|
|
217
|
-
ffOptions.setPreference('network.proxy.socks', 'localhost');
|
|
218
|
-
ffOptions.setPreference(
|
|
219
|
-
'network.proxy.socks_port',
|
|
220
|
-
connectivity.tsproxy.port
|
|
221
|
-
);
|
|
222
|
-
ffOptions.setPreference('network.proxy.type', 1);
|
|
223
|
-
}
|
|
224
210
|
builder
|
|
225
211
|
.getCapabilities()
|
|
226
212
|
.set('pageLoadStrategy', get(options, 'pageLoadStrategy', 'normal'));
|
|
@@ -143,6 +143,24 @@ class Firefox {
|
|
|
143
143
|
result.memory = await memoryReport.collect(index, url);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
const useFirefoxAppConstants = get(
|
|
147
|
+
this.options || {},
|
|
148
|
+
'firefox.appconstants',
|
|
149
|
+
false
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
if (useFirefoxAppConstants === true) {
|
|
153
|
+
const appConstantsScript = `const { AppConstants } = ChromeUtils.import(
|
|
154
|
+
'resource://gre/modules/AppConstants.jsm'
|
|
155
|
+
);
|
|
156
|
+
return AppConstants;`;
|
|
157
|
+
|
|
158
|
+
this.appConstants = await runner.runPrivilegedScript(
|
|
159
|
+
appConstantsScript,
|
|
160
|
+
'APP_CONSTANTS'
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
146
164
|
if (this.skipHar || this.options.android) {
|
|
147
165
|
return result;
|
|
148
166
|
} else {
|
|
@@ -167,27 +185,8 @@ class Firefox {
|
|
|
167
185
|
* The URL/test is finished, all metrics are collected.
|
|
168
186
|
*/
|
|
169
187
|
async afterEachURL(runner, index, result) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
'firefox.appconstants',
|
|
173
|
-
false
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
if (useFirefoxAppConstants === false) {
|
|
177
|
-
// We need to be extra careful here, see
|
|
178
|
-
// https://github.com/sitespeedio/browsertime/issues/1261
|
|
179
|
-
if (
|
|
180
|
-
result.browserScripts.browser &&
|
|
181
|
-
result.browserScripts.browser.appConstants
|
|
182
|
-
) {
|
|
183
|
-
delete result.browserScripts.browser.appConstants;
|
|
184
|
-
}
|
|
185
|
-
if (
|
|
186
|
-
result.browserScripts.browser &&
|
|
187
|
-
result.browserScripts.browser.asyncAppConstants
|
|
188
|
-
) {
|
|
189
|
-
delete result.browserScripts.browser.asyncAppConstants;
|
|
190
|
-
}
|
|
188
|
+
if (this.appConstants) {
|
|
189
|
+
result.browserScripts.browser.appConstants = this.appConstants;
|
|
191
190
|
}
|
|
192
191
|
}
|
|
193
192
|
|
package/lib/support/cli.js
CHANGED
|
@@ -87,12 +87,6 @@ function validateInput(argv) {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
if (argv.connectivity && argv.connectivity.engine === 'tsproxy') {
|
|
91
|
-
if (!hasbin.all.sync(['python'])) {
|
|
92
|
-
return 'You need to have Python 2.7 in your path to be able to use TSProxy.';
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
90
|
if (argv.connectivity && argv.connectivity.engine === 'humble') {
|
|
97
91
|
if (!argv.connectivity.humble || !argv.connectivity.humble.url) {
|
|
98
92
|
return 'You need to specify the URL to Humble by using the --connectivity.humble.url option.';
|
|
@@ -253,14 +247,8 @@ module.exports.parseCommandLine = function parseCommandLine() {
|
|
|
253
247
|
type: 'boolean',
|
|
254
248
|
group: 'chrome'
|
|
255
249
|
})
|
|
256
|
-
.option('chrome.visualMetricsUsingTrace', {
|
|
257
|
-
type: 'boolean',
|
|
258
|
-
default: false,
|
|
259
|
-
describe:
|
|
260
|
-
'Collect Visual Metrics using Chrome trace log. You need enable trace screenshots --chrome.enableTraceScreenshots and --cpu metrics for this to work.',
|
|
261
|
-
group: 'chrome'
|
|
262
|
-
})
|
|
263
250
|
.option('chrome.timeline', {
|
|
251
|
+
alias: 'chrome.trace',
|
|
264
252
|
describe:
|
|
265
253
|
'Collect the timeline data. Drag and drop the JSON in your Chrome detvools timeline panel or check out the CPU metrics in the Browsertime.json',
|
|
266
254
|
type: 'boolean',
|
|
@@ -943,7 +931,7 @@ module.exports.parseCommandLine = function parseCommandLine() {
|
|
|
943
931
|
})
|
|
944
932
|
.option('connectivity.engine', {
|
|
945
933
|
default: 'external',
|
|
946
|
-
choices: ['external', 'throttle', '
|
|
934
|
+
choices: ['external', 'throttle', 'humble'],
|
|
947
935
|
describe:
|
|
948
936
|
'The engine for connectivity. Throttle works on Mac and tc based Linux. For mobile you can use Humble if you have a Humble setup. Use external if you set the connectivity outside of Browsertime. The best way do to this is described in https://github.com/sitespeedio/browsertime#connectivity.',
|
|
949
937
|
group: 'connectivity'
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const execa = require('execa');
|
|
4
|
+
const log = require('intel').getLogger('browsertime.dns');
|
|
5
|
+
const { isAndroidConfigured } = require('../android');
|
|
6
|
+
module.exports = async function (options) {
|
|
7
|
+
if (isAndroidConfigured(options)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (options.safari && options.safari.ios) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (process.platform === 'darwin') {
|
|
16
|
+
try {
|
|
17
|
+
await execa('sudo', ['killall', '-HUP', 'mDNSResponder'], {
|
|
18
|
+
reject: false
|
|
19
|
+
});
|
|
20
|
+
await execa('sudo', ['dscacheutil', '-flushcache'], {
|
|
21
|
+
reject: false
|
|
22
|
+
});
|
|
23
|
+
return execa('sudo', ['lookupd', '-flushcache'], {
|
|
24
|
+
reject: false
|
|
25
|
+
});
|
|
26
|
+
} catch (err) {
|
|
27
|
+
log.error('Could not flush dns cache', err);
|
|
28
|
+
}
|
|
29
|
+
} else if (process.platform === 'linux') {
|
|
30
|
+
try {
|
|
31
|
+
await execa('sudo', ['service', 'dnsmasq', 'restart'], {
|
|
32
|
+
reject: false
|
|
33
|
+
});
|
|
34
|
+
await execa('sudo', ['rndc', 'restart'], {
|
|
35
|
+
reject: false
|
|
36
|
+
});
|
|
37
|
+
return execa('sudo', ['systemd-resolve', '--flush-caches'], {
|
|
38
|
+
reject: false
|
|
39
|
+
});
|
|
40
|
+
} catch (err) {
|
|
41
|
+
log.error('Could not flush dns cache', err);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|