browsertime 14.20.2 → 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 CHANGED
@@ -1,6 +1,26 @@
1
1
  # Browsertime changelog (we do [semantic versioning](https://semver.org))
2
2
 
3
- ## 14.20.2 - 2022-02-07
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).
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).
15
+ ## 14.21.1 - 2022-02-09
16
+ ### Fixed
17
+ * Always disable the new ChromeWhaxyNewUI splash screen in Chrome [#1717](https://github.com/sitespeedio/browsertime/pull/1717).
18
+ * Remove the Firefox persist log configuration that was needed for FF 94+ [#1716](https://github.com/sitespeedio/browsertime/pull/1716).
19
+ ## 14.21.0 - 2022-02-08
20
+ ### Added
21
+ * Upgraded to Egdedriver 98
22
+ * Upgraded to Edge 98 and Firefox 97 in the Docker container
23
+ ## 14.20.3 - 2022-02-07
4
24
  ### Fixed
5
25
  * There's a new setup how we build Docker releases and this release uses the new pipeline.
6
26
  ## 14.20.0 - 2022-02-07
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Browsertime - Your browser, your page, your scripts!
2
- ![Run Docker](https://github.com/sitespeedio/browsertime/workflows/Run%20Docker/badge.svg?branch=main)
3
- ![Unit tests](https://github.com/sitespeedio/browsertime/workflows/Unit%20tests/badge.svg?branch=main)
4
- ![Windows Edge](https://github.com/sitespeedio/browsertime/workflows/Windows%20Edge/badge.svg?branch=main)
5
- ![OSX Safari](https://github.com/sitespeedio/browsertime/workflows/OSX%20Safari/badge.svg?branch=main)
6
- ![Linux browsers](https://github.com/sitespeedio/browsertime/workflows/Linux%20browsers/badge.svg?branch=main)
2
+ ![Run Docker](https://github.com/sitespeedio/browsertime/actions/workflows/docker.yml/badge.svg?branch=main)
3
+ ![Unit tests](https://github.com/sitespeedio/browsertime/actions/workflows/unittests.yml/badge.svg?branch=main)
4
+ ![Windows Edge](https://github.com/sitespeedio/browsertime/actions/workflows/windows.yml/badge.svg?branch=main)
5
+ ![OSX Safari](https://github.com/sitespeedio/browsertime/actions/workflows/safari.yml/badge.svg?branch=main)
6
+ ![Linux browsers](https://github.com/sitespeedio/browsertime/actions/workflows/linux.yml/badge.svg?branch=main)
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(
@@ -108,9 +108,25 @@ module.exports = function (seleniumOptions, browserOptions, options, baseDir) {
108
108
  }
109
109
  }
110
110
 
111
+ // It's a new splash screen introduced in Chrome 98
112
+ // for new profiles
113
+ // disable it with ChromeWhatsNewUI
111
114
  if (browserOptions.args) {
112
- log.debug('Set Chrome args %j', browserOptions.args);
113
- seleniumOptions.addArguments(browserOptions.args);
115
+ const chromeCommandLineArgs = util.toArray(browserOptions.args);
116
+ for (const arg of chromeCommandLineArgs) {
117
+ if (
118
+ arg.indexOf('disable-features') > -1 &&
119
+ arg.indexOf('ChromeWhatsNewUI') === -1
120
+ ) {
121
+ seleniumOptions.addArguments(`${arg},ChromeWhatsNewUI`);
122
+ log.debug('Set Chrome args %j', `${arg},ChromeWhatsNewUI`);
123
+ } else {
124
+ seleniumOptions.addArguments(arg);
125
+ log.debug('Set Chrome args %j', arg);
126
+ }
127
+ }
128
+ } else {
129
+ seleniumOptions.addArguments('--disable-features=ChromeWhatsNewUI');
114
130
  }
115
131
 
116
132
  if (browserOptions.binaryPath) {
@@ -121,33 +137,6 @@ module.exports = function (seleniumOptions, browserOptions, options, baseDir) {
121
137
  seleniumOptions.setMobileEmulation(browserOptions.mobileEmulation);
122
138
  }
123
139
 
124
- const connectivity = options.connectivity || {};
125
-
126
- if (
127
- connectivity.engine === 'tsproxy' &&
128
- connectivity.tsproxy &&
129
- connectivity.profile !== 'native'
130
- ) {
131
- if (!connectivity.tsproxy.bind) {
132
- // If you run tsproxy on desktop instead of throttle or Docker networs
133
- // Configure SOCKS proxy, see https://www.chromium.org/developers/design-documents/network-stack/socks-proxy
134
- seleniumOptions.addArguments(
135
- '--proxy-server=socks5://localhost:' + connectivity.tsproxy.port
136
- );
137
- seleniumOptions.addArguments(
138
- '--host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE localhost"'
139
- );
140
- } else {
141
- // If you run on Android and want to use TSProxy on your desktop
142
- seleniumOptions.addArguments(
143
- '--proxy-server=socks://' +
144
- connectivity.tsproxy.bind +
145
- ':' +
146
- connectivity.tsproxy.port
147
- );
148
- }
149
- }
150
-
151
140
  // See https://bugs.chromium.org/p/chromium/issues/detail?id=818483
152
141
  // Coming again in Chrome 76
153
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
  }
@@ -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
- this.options.devToolsPort = await getPort({
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
- this.options.safariDriverPort = await getPort({
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
- if (get(this.options, 'connectivity.tsproxy.port') === undefined) {
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 (this.options.android) {
95
- const android = new Android(this.options);
79
+ if (options.android) {
80
+ const android = new Android(options);
96
81
  await android._init();
97
82
  this.android = android;
98
83
 
99
- if (this.options.gnirehtet) {
100
- this.gnirehtet = new Gnirehtet(this.options);
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 (this.options.androidPretestPowerPress) {
96
+ if (options.androidPretestPowerPress) {
112
97
  await android.clickPowerButton();
113
98
  }
114
99
 
115
- if (this.options.androidVerifyNetwork) {
116
- const pingAddress = get(this.options, 'androidPingAddress', '8.8.8.8');
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 (this.options.androidRooted) {
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 (this.options.androidBatteryTemperatureLimit) {
143
- const maxTries = this.options.androidBatteryTemperatureMaxTries || 20;
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 = this.options.androidBatteryTemperatureLimit;
131
+ const minTempLimit = options.androidBatteryTemperatureLimit;
147
132
  const waitTime =
148
- (this.options.androidBatteryTemperatureWaitTimeInSeconds || 120) *
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 (this.options.androidBatteryTemperatureReboot) {
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 (this.options.safari && this.options.safari.useSimulator) {
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 === this.options.safari.deviceUDID) {
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, this.options);
225
+ engineDelegate = new Firefox(storageManager, options);
245
226
  break;
246
227
  case 'chrome':
247
- engineDelegate = new Chromium(storageManager, this.options);
228
+ engineDelegate = new Chromium(storageManager, options);
248
229
  break;
249
230
  case 'edge':
250
- engineDelegate = new Chromium(storageManager, this.options);
231
+ engineDelegate = new Chromium(storageManager, options);
251
232
  break;
252
233
  case 'safari':
253
- engineDelegate = new Safari(storageManager, this.options);
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 (this.options.safari && this.options.safari.useSimulator) {
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: this.options.safari.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 (!this.options.preScript) {
427
- this.options.preScript = [];
408
+ if (!options.preScript) {
409
+ options.preScript = [];
428
410
  }
429
- this.options.preScript.push(script.setUp);
411
+ options.preScript.push(script.setUp);
430
412
  }
431
413
 
432
414
  if (script.tearDown) {
433
- if (!this.options.postScript) {
434
- this.options.postScript = [];
415
+ if (!options.postScript) {
416
+ options.postScript = [];
435
417
  }
436
- this.options.postScript.push(script.tearDown);
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
- if (!this.options.connectivity.variance) {
465
- await removeConnectivity(this.options);
466
- }
446
+ const options = this.options;
447
+ await removeConnectivity(options);
467
448
 
468
- if (this.options.androidRooted && this.rooted) {
449
+ if (options.androidRooted && this.rooted) {
469
450
  await this.rooted.stop();
470
451
  }
471
452
 
472
- if (this.options.safari && this.options.safari.useSimulator) {
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 (this.options.gnirehtet && this.gnirehtet) {
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.connectivity.variance) {
105
- await addConnectivity(options);
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
- // Fail fast if you are using the incorrect Chromedriver version
80
- if (
81
- e.message.indexOf('This version of ChromeDriver only supports') > -1
82
- ) {
83
- log.error(
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) {
@@ -179,8 +179,5 @@ module.exports = {
179
179
 
180
180
  // disable calls to detectportal.firefox.com
181
181
  'network.captive-portal-service.enabled': false,
182
- 'network.connectivity-service.enabled': false,
183
- // https://bugzilla.mozilla.org/show_bug.cgi?id=1740116#c15
184
- // https://github.com/sitespeedio/browsertime/issues/1671
185
- 'devtools.netmonitor.persistlog': true
182
+ 'network.connectivity-service.enabled': false
186
183
  };
@@ -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
- const useFirefoxAppConstants = get(
171
- this.options || {},
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
 
@@ -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', 'tsproxy', 'humble'],
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
+ };