browsertime 17.0.0-beta.3 → 17.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.
Files changed (98) hide show
  1. package/CHANGELOG.md +47 -12
  2. package/bin/browsertime.js +5 -8
  3. package/bin/browsertimeWebPageReplay.js +2 -2
  4. package/index.js +2 -2
  5. package/lib/android/gnirehtet.js +1 -2
  6. package/lib/android/root.js +57 -16
  7. package/lib/chrome/chromeDevtoolsProtocol.js +2 -3
  8. package/lib/chrome/har.js +1 -1
  9. package/lib/chrome/longTaskMetrics.js +1 -1
  10. package/lib/chrome/parseCpuTrace.js +2 -2
  11. package/lib/chrome/settings/chromeAndroidOptions.js +1 -1
  12. package/lib/chrome/settings/chromeDesktopOptions.js +1 -1
  13. package/lib/chrome/settings/traceCategories.js +1 -1
  14. package/lib/chrome/traceCategoriesParser.js +3 -3
  15. package/lib/chrome/webdriver/builder.js +1 -1
  16. package/lib/chrome/webdriver/chromium.js +13 -17
  17. package/lib/chrome/webdriver/setupChromiumOptions.js +18 -13
  18. package/lib/connectivity/humble.js +10 -12
  19. package/lib/connectivity/index.js +1 -1
  20. package/lib/core/engine/collector.js +2 -4
  21. package/lib/core/engine/command/addText.js +1 -2
  22. package/lib/core/engine/command/android.js +1 -1
  23. package/lib/core/engine/command/cache.js +1 -2
  24. package/lib/core/engine/command/chromeDevToolsProtocol.js +1 -2
  25. package/lib/core/engine/command/click.js +1 -2
  26. package/lib/core/engine/command/debug.js +1 -3
  27. package/lib/core/engine/command/javaScript.js +1 -2
  28. package/lib/core/engine/command/measure.js +13 -15
  29. package/lib/core/engine/command/meta.js +1 -1
  30. package/lib/core/engine/command/navigation.js +1 -1
  31. package/lib/core/engine/command/screenshot.js +1 -1
  32. package/lib/core/engine/command/scroll.js +1 -1
  33. package/lib/core/engine/command/select.js +1 -1
  34. package/lib/core/engine/command/set.js +1 -1
  35. package/lib/core/engine/command/stopWatch.js +1 -1
  36. package/lib/core/engine/command/switch.js +44 -1
  37. package/lib/core/engine/command/util/lcpHighlightScript.js +1 -1
  38. package/lib/core/engine/command/util/lsHighlightScript.js +1 -1
  39. package/lib/core/engine/command/wait.js +1 -1
  40. package/lib/core/engine/index.js +33 -15
  41. package/lib/core/engine/iteration.js +35 -42
  42. package/lib/core/engine/run.js +1 -1
  43. package/lib/core/pageCompleteChecks/defaultPageCompleteCheck.js +1 -1
  44. package/lib/core/pageCompleteChecks/pageCompleteCheckByInactivity.js +1 -1
  45. package/lib/core/pageCompleteChecks/spaInactivity.js +1 -1
  46. package/lib/core/seleniumRunner.js +9 -11
  47. package/lib/edge/webdriver/builder.js +1 -1
  48. package/lib/extensionserver/index.js +2 -4
  49. package/lib/extensionserver/setup.js +1 -1
  50. package/lib/firefox/geckoProfiler.js +46 -16
  51. package/lib/firefox/getHAR.js +1 -1
  52. package/lib/firefox/memoryReport.js +1 -1
  53. package/lib/firefox/settings/disableSafeBrowsingPreferences.js +1 -1
  54. package/lib/firefox/settings/disableTrackingProtectionPreferences.js +1 -1
  55. package/lib/firefox/settings/firefoxPreferences.js +1 -1
  56. package/lib/firefox/webdriver/builder.js +9 -9
  57. package/lib/firefox/webdriver/firefox.js +24 -6
  58. package/lib/safari/webdriver/safari.js +1 -1
  59. package/lib/screenshot/defaults.js +1 -1
  60. package/lib/screenshot/index.js +3 -5
  61. package/lib/support/cli.js +11 -5
  62. package/lib/support/dns.js +1 -1
  63. package/lib/support/engineUtils.js +60 -66
  64. package/lib/support/getViewPort.js +1 -1
  65. package/lib/support/har/index.js +6 -8
  66. package/lib/support/images/index.js +1 -1
  67. package/lib/support/logging.js +1 -1
  68. package/lib/support/pathToFolder.js +4 -4
  69. package/lib/support/preURL.js +1 -1
  70. package/lib/support/processes.js +1 -1
  71. package/lib/support/setResourceTimingBufferSize.js +1 -1
  72. package/lib/support/stop.js +1 -1
  73. package/lib/support/storageManager.js +1 -3
  74. package/lib/support/tcpdump.js +2 -2
  75. package/lib/support/xvfb.js +2 -4
  76. package/lib/video/postprocessing/finetune/addTextToVideo.js +3 -3
  77. package/lib/video/postprocessing/finetune/convertFps.js +1 -1
  78. package/lib/video/postprocessing/finetune/getFont.js +1 -1
  79. package/lib/video/postprocessing/finetune/getTimingMetrics.js +2 -2
  80. package/lib/video/postprocessing/finetune/index.js +4 -4
  81. package/lib/video/postprocessing/finetune/removeOrange.js +1 -1
  82. package/lib/video/postprocessing/visualmetrics/extraMetrics.js +1 -1
  83. package/lib/video/postprocessing/visualmetrics/getVideoMetrics.js +2 -2
  84. package/lib/video/screenRecording/android/recorder.js +1 -1
  85. package/lib/video/screenRecording/desktop/convert.js +1 -1
  86. package/lib/video/screenRecording/desktop/desktopRecorder.js +3 -3
  87. package/lib/video/screenRecording/desktop/ffmpegRecorder.js +6 -6
  88. package/lib/video/screenRecording/desktop/osx/getSPDisplaysDataType.js +1 -1
  89. package/lib/video/screenRecording/desktop/osx/getScreen.js +1 -1
  90. package/lib/video/screenRecording/firefox/firefoxWindowRecorder.js +1 -1
  91. package/lib/video/screenRecording/ios/convertToMp4.js +1 -1
  92. package/lib/video/screenRecording/ios/iosRecorder.js +2 -2
  93. package/lib/video/screenRecording/iosSimulator/convertToMp4.js +1 -1
  94. package/lib/video/screenRecording/iosSimulator/recorder.js +2 -2
  95. package/lib/video/screenRecording/recorder.js +6 -6
  96. package/lib/video/screenRecording/setOrangeBackground.js +1 -1
  97. package/lib/video/video.js +9 -11
  98. package/package.json +17 -17
package/CHANGELOG.md CHANGED
@@ -1,12 +1,42 @@
1
1
  # Browsertime changelog (we do [semantic versioning](https://semver.org))
2
2
 
3
- ## 17.0.0 - UNRELEASED
3
+ ## 17.0.0 - 2022-02-10
4
4
 
5
5
  ### Breaking changes
6
- * We moved the project to be a [pure ESM package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) [#1859](https://github.com/sitespeedio/browsertime/pull/1859). That helps us keep up to date with dependencies that already did the move.
6
+ The project was transitioned to a [pure ESM package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) [#1859](https://github.com/sitespeedio/browsertime/pull/1859), allowing us to stay current with dependencies that have made the same transition and ensuring the ability to always utilize the latest versions of our dependencies. This is important for us and will make the project easier to maintain.
7
7
 
8
- If you are a command line user, everything will work as before. If you import Browsertime in NodeJS
9
- we changed how you do your import.
8
+
9
+ #### CLI users
10
+ If you are a command line user and use scripting, you will need to do a change to your scripts or add a extra configuration.
11
+
12
+ The new browsertime version treat all JavaScript files that ends with *.js* as ESM modules, that means your old script files will not work out of the box. There's a couple of fixes for that:
13
+
14
+ **The best fix**:
15
+ Change your code so your scripts also follows ESM package. If you have simple scripts you probably just need to change your exports. The old way looked like this:
16
+
17
+ ```
18
+ module.exports = async function(context, commands) {
19
+ ...
20
+ }
21
+ ```
22
+
23
+ change that to:
24
+ ```
25
+ export default async function (context, commands) {
26
+ ...
27
+ }
28
+ ```
29
+
30
+ If you have more complicated scripts, follow the [ESM package guide](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
31
+
32
+ This is the best fix and will woirk 100% of the time.
33
+
34
+ **The quick fix**: Rename your *.js* to *.cjs* that way NodeJS will treat your file as a common JS file and everything will just work. For example if you have a file names `login.js` you can rename that to `login.cjs` and make sure you load that new file.
35
+
36
+ **Another quick fix alternative**: As a last alternative add `--cjs` as a parameter to your test. That way the scripting file will be treated as a commonjs file. This is a hack, so to make sure it works, the user that runs Browsertime need to have write privileges to the folder where you have your scripting files. Browsertime will create a package.json file on the same levels as yoru script file. If you already have a package.json there, it will be overwritten.
37
+
38
+ #### Non cli users
39
+ If you import Browsertime in NodeJS we changed how you do your import.
10
40
 
11
41
  If you use ES modules you can import Browsertime like this:
12
42
  ```JavaScript
@@ -24,7 +54,7 @@ Read [Sindre Sorhus Pure ESM package guide](https://gist.github.com/sindresorhus
24
54
 
25
55
  * We moved to use a new [Visual Metrics script](https://github.com/sitespeedio/browsertime/blob/main/browsertime/visualmetrics-portable.py) as default contributed by [Gregory Mierzwinski](https://github.com/gmierz) that do _not_ use ImageMagick. Mozilla has used this script for many months and we have internally used it in our test infrastructure since it was first released.
26
56
 
27
- If you run Browsertime direct using NodeJs (and not using Docker) you need to install two new Python dependencies OpenCV-Python Numpy.
57
+ If you run Browsertime direct using NodeJs (and not using Docker) you need to install two new Python dependencies `OpenCV-Python Numpy`.
28
58
 
29
59
  ```
30
60
  python -m pip install --user OpenCV-Python Numpy
@@ -33,16 +63,21 @@ python -m pip install --user OpenCV-Python Numpy
33
63
  This is pretty cool because it makes dependencies easier to install on all platforms + the script has also been cleaned up so its easier for us to maintain.
34
64
 
35
65
  ### Added
36
- * Chrome and Chromedriver 106 [#1853](https://github.com/sitespeedio/browsertime/pull/1853).
37
- * Selenium 4.5 [#1852](https://github.com/sitespeedio/browsertime/pull/1852).
38
- * Updated dependencies: edgedriver, execa, days, find-up, get-ports, jimp, yargs [#1860](https://github.com/sitespeedio/browsertime/pull/1860)
39
- * Updated to Chrome 107 in the Docker container.
40
- * Updated to NodeJS 18 in the Docker container.
41
-
66
+ * Selenium 4.8.
67
+ * Updated dependencies: execa, days, find-up, get-ports, jimp, yargs [#1860](https://github.com/sitespeedio/browsertime/pull/1860)
68
+ * Updated to Chrome, Firefox and Edge 109 in the Docker container. Also updated all drivers.
69
+ * Updated to NodeJS 18 and Ubuntu 22.04 in the Docker container.
70
+ * Get CPU metrics using Glean on Firefox, thank you [afinder-mozilla](https://github.com/afinder-mozilla) for PR [#1875](https://github.com/sitespeedio/browsertime/pull/1875)
71
+ * Provide active tab id to gecko profiler StartProfiler API in Firefox, thank you [Nazım Can Altınova](https://github.com/canova) for PR [#1874](https://github.com/sitespeedio/browsertime/pull/1874).
72
+ * There's two new methods to switch to frame: `switch.toFrameByXpath(xpath)` and `switch.toFrameBySelector(selector)` [#1880](https://github.com/sitespeedio/browsertime/pull/1880).
73
+ * Add a timeout to gecko profiler gzipping phase, thank you [Nazım Can Altınova](https://github.com/canova) for PR [#1896](https://github.com/sitespeedio/browsertime/pull/1896)
74
+ * Pin CPU freq to fastest for Samsung A51 (if you have a rooted device) [#1895](https://github.com/sitespeedio/browsertime/pull/1895).
42
75
  ### Fixed
43
76
  * Pause the gecko profiler before starting to collect the profile data, thank you [Nazım Can Altınova](https://github.com/canova) for PR [#1856](https://github.com/sitespeedio/browsertime/pull/1856).
44
77
 
45
- * All Android configurations has been moved to an Android group. That makes it easier when you run --help and can see all Android configuration grouped together. For example `--androidBatteryTemperature` is now `--android.batteryTemperatureLimit`. Old names will still work. [#1865](https://github.com/sitespeedio/browsertime/pull/1865)
78
+ * All Android configurations has been moved to an Android group. That makes it easier when you run --help and can see all Android configuration grouped together. For example `--androidBatteryTemperature` is now `--android.batteryTemperatureLimit`. Old names will still work but are deprecated [#1865](https://github.com/sitespeedio/browsertime/pull/1865).
79
+
80
+ * Updated to Chromedriver 110 to work with Android 13 [#1894](https://github.com/sitespeedio/browsertime/pull/1894).
46
81
 
47
82
  ## 16.17.0 - 2022-09-27
48
83
  ### Added
@@ -5,15 +5,15 @@ import set from 'lodash.set';
5
5
  import intel from 'intel';
6
6
  import { existsSync, mkdirSync } from 'node:fs';
7
7
  import { resolve, relative } from 'node:path';
8
- import Engine from '../lib/core/engine/index.js';
8
+ import { Engine } from '../lib/core/engine/index.js';
9
9
  import {
10
10
  findAndParseScripts,
11
11
  allScriptCategories,
12
12
  getScriptsForCategories
13
13
  } from '../lib/support/browserScript.js';
14
- import logging from '../lib/support/logging.js';
14
+ import { configure } from '../lib/support/logging.js';
15
15
  import { parseCommandLine } from '../lib/support/cli.js';
16
- import StorageManager from '../lib/support/storageManager.js';
16
+ import { StorageManager } from '../lib/support/storageManager.js';
17
17
  import { loadScript } from '../lib/support/engineUtils.js';
18
18
  import { isAndroidConfigured } from '../lib/android/index.js';
19
19
 
@@ -154,6 +154,7 @@ async function run(urls, options) {
154
154
  }
155
155
 
156
156
  let cliResult = parseCommandLine();
157
+ configure(cliResult.options);
157
158
 
158
159
  /*
159
160
  Each url can be:
@@ -169,8 +170,7 @@ const tests = [];
169
170
  for (const url of cliResult.urls) {
170
171
  // for each url, we try to load it as a script, that may contain
171
172
  // export a single function or an object containing setUp/test/tearDown functions.
172
- let testScript = await loadScript(url);
173
-
173
+ let testScript = await loadScript(url, cliResult.options);
174
174
  // if the value is an url or a not a single function, we can return the original value
175
175
  if (typeof testScript == 'string' || testScript instanceof AsyncFunction) {
176
176
  tests.push(url);
@@ -192,7 +192,4 @@ for (const url of cliResult.urls) {
192
192
  // here, url is the filename containing the script, and test the callable.
193
193
  tests.push([url, testScript.test]);
194
194
  }
195
-
196
- logging(cliResult.options);
197
-
198
195
  await run(tests, cliResult.options);
@@ -3,8 +3,8 @@ import merge from 'lodash.merge';
3
3
  import yargs from 'yargs';
4
4
  import { hideBin } from 'yargs/helpers';
5
5
 
6
- import Engine from '../lib/core/engine/index.js';
7
- import logging from '../lib/support/logging.js';
6
+ import { Engine } from '../lib/core/engine/index.js';
7
+ import { configure as logging } from '../lib/support/logging.js';
8
8
 
9
9
  async function runBrowsertime() {
10
10
  let yargsInstance = yargs(hideBin(process.argv));
package/index.js CHANGED
@@ -12,5 +12,5 @@ export const browserScripts = {
12
12
  findAndParseScripts
13
13
  };
14
14
 
15
- export { default as BrowsertimeEngine } from './lib/core/engine/index.js';
16
- export { default as configureLogging } from './lib/support/logging.js';
15
+ export { Engine as BrowsertimeEngine } from './lib/core/engine/index.js';
16
+ export { configure as configureLogging } from './lib/support/logging.js';
@@ -3,7 +3,7 @@ import intel from 'intel';
3
3
  const log = intel.getLogger('browsertime.gnirehtet');
4
4
  const delay = ms => new Promise(response => setTimeout(response, ms));
5
5
 
6
- class Gnirehtet {
6
+ export class Gnirehtet {
7
7
  constructor(options) {
8
8
  this.options = options;
9
9
  }
@@ -65,4 +65,3 @@ class Gnirehtet {
65
65
  return delay(2000);
66
66
  }
67
67
  }
68
- export default Gnirehtet;
@@ -11,7 +11,7 @@ const animationsToStop = [
11
11
  'window_animation_scale'
12
12
  ];
13
13
 
14
- class RootedDevice {
14
+ export class RootedDevice {
15
15
  constructor(androidClient) {
16
16
  this.client = androidClient;
17
17
  }
@@ -83,6 +83,29 @@ class RootedDevice {
83
83
  }
84
84
  }
85
85
 
86
+ async setCPUPerformanceSamsungA51() {
87
+ // Octa-core (4x2.3 GHz Cortex-A73 & 4x1.7 GHz Cortex-A53)
88
+ // See values by
89
+ // cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies
90
+ // cat /sys/devices/system/cpu/cpufreq/policy4/scaling_available_frequencies
91
+
92
+ await this.client._runAsRoot(
93
+ 'echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor'
94
+ );
95
+
96
+ await this.client._runAsRoot(
97
+ 'echo performance > /sys/devices/system/cpu/cpufreq/policy4/scaling_governor'
98
+ );
99
+
100
+ await this.client._runAsRoot(
101
+ 'echo 1742000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq'
102
+ );
103
+
104
+ return this.client._runAsRoot(
105
+ 'echo 2314000 > /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq'
106
+ );
107
+ }
108
+
86
109
  async setCPUPerformancePixel2() {
87
110
  // MSM8998 (4x 2.35GHz, 4x 1.9GHz)
88
111
  // values obtained from:
@@ -166,6 +189,11 @@ class RootedDevice {
166
189
  );
167
190
  }
168
191
 
192
+ async setGPUPerformanceSamsungA51() {
193
+ // Mali-G72 MP3 (3 @ 850 MHz)
194
+ // Missing info on how to set the GPU
195
+ }
196
+
169
197
  async start() {
170
198
  await this.stopServices();
171
199
  await this.stopAnimations();
@@ -178,19 +206,34 @@ class RootedDevice {
178
206
  `getprop ro.product.model`
179
207
  );
180
208
 
181
- if (model === 'Moto G (5)') {
182
- log.info('Set CPU and GPU performance settings for Moto G5');
183
- await this.setCPUPerformanceMotoG5();
184
- await this.setGPUPerformanceMotoG5();
185
- } else if (model === 'Pixel 2') {
186
- log.info('Set CPU and GPU performance settings for Pixel 2');
187
- await this.setCPUPerformancePixel2();
188
- await this.setGPUPerformancePixel2();
189
- } else {
190
- log.info(
191
- 'No specific CPU/GPU settings for %s - you can help out by creating a PR at https://github.com/sitespeedio/browsertime for your phone',
192
- model
193
- );
209
+ switch (model) {
210
+ case 'Moto G (5)': {
211
+ log.info('Set CPU and GPU performance settings for Moto G5');
212
+ await this.setCPUPerformanceMotoG5();
213
+ await this.setGPUPerformanceMotoG5();
214
+
215
+ break;
216
+ }
217
+ case 'Pixel 2': {
218
+ log.info('Set CPU and GPU performance settings for Pixel 2');
219
+ await this.setCPUPerformancePixel2();
220
+ await this.setGPUPerformancePixel2();
221
+
222
+ break;
223
+ }
224
+ case 'SM-A515F': {
225
+ // Samsung A51
226
+ await this.setCPUPerformanceSamsungA51();
227
+ await this.setGPUPerformanceSamsungA51();
228
+
229
+ break;
230
+ }
231
+ default: {
232
+ log.info(
233
+ 'No specific CPU/GPU settings for %s - you can help out by creating a PR at https://github.com/sitespeedio/browsertime for your phone',
234
+ model
235
+ );
236
+ }
194
237
  }
195
238
  }
196
239
 
@@ -199,5 +242,3 @@ class RootedDevice {
199
242
  return this.startAnimations();
200
243
  }
201
244
  }
202
-
203
- export default RootedDevice;
@@ -3,7 +3,7 @@ import CDP from 'chrome-remote-interface';
3
3
  import btoa from 'btoa';
4
4
  const log = intel.getLogger('browsertime.chrome.cdp');
5
5
  import { toArray } from '../support/util.js';
6
- import defaultTraceCategories from './settings/traceCategories.js';
6
+ import { traceCategories as defaultTraceCategories } from './settings/traceCategories.js';
7
7
 
8
8
  const MIME_TYPE_MATCHERS = [
9
9
  [/^text\/html/, 'html'],
@@ -20,7 +20,7 @@ function getContentType(mimeType) {
20
20
  return MIME_TYPE_MATCHERS.find(matcher => matcher[0].test(mimeType))[1];
21
21
  }
22
22
 
23
- class ChromeDevtoolsProtocol {
23
+ export class ChromeDevtoolsProtocol {
24
24
  constructor(options) {
25
25
  this.options = options;
26
26
  this.chrome = options.chrome || {};
@@ -234,4 +234,3 @@ class ChromeDevtoolsProtocol {
234
234
  }
235
235
  }
236
236
  }
237
- export default ChromeDevtoolsProtocol;
package/lib/chrome/har.js CHANGED
@@ -5,7 +5,7 @@ const log = intel.getLogger('browsertime.chrome');
5
5
  import { addBrowser } from '../support/har/index.js';
6
6
  const { Type } = logging;
7
7
 
8
- export default async function (
8
+ export async function getHar(
9
9
  runner,
10
10
  result,
11
11
  index,
@@ -1,6 +1,6 @@
1
1
  import get from 'lodash.get';
2
2
 
3
- export default function (result, options) {
3
+ export function longTaskMetrics(result, options) {
4
4
  let totalDurationFirstPaint = 0;
5
5
  let totalDurationFirstContentFulPaint = 0;
6
6
  let totalDurationLargestContentFulPaint = 0;
@@ -11,7 +11,7 @@ function slowestFirst(a, b) {
11
11
  return b.value - a.value;
12
12
  }
13
13
 
14
- export default async (tracelog, url) => {
14
+ export async function parseCPUTrace(tracelog, url) {
15
15
  try {
16
16
  log.debug('Start parse Chrome trace log using Tracium.');
17
17
  const tasks = computeMainThreadTasks(tracelog, {
@@ -87,4 +87,4 @@ export default async (tracelog, url) => {
87
87
  );
88
88
  return {};
89
89
  }
90
- };
90
+ }
@@ -3,7 +3,7 @@
3
3
  * see https://github.com/GoogleChrome/chrome-launcher/blob/master/docs/chrome-flags-for-tools.md
4
4
  * https://peter.sh/experiments/chromium-command-line-switches/
5
5
  */
6
- export default [
6
+ export const chromeAndroidOptions = [
7
7
  '--disable-fre',
8
8
  // : Disable reporting to UMA, but allows for collection
9
9
  '--metrics-recording-only',
@@ -1,6 +1,6 @@
1
1
  // See https://github.com/GoogleChrome/chrome-launcher/blob/master/docs/chrome-flags-for-tools.md
2
2
  // https://peter.sh/experiments/chromium-command-line-switches/
3
- export default [
3
+ export const chromeDesktopOptions = [
4
4
  '--disable-background-networking',
5
5
  '--no-default-browser-check',
6
6
  '--no-first-run',
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Default trace categories for the Chrome trace log.
3
3
  */
4
- export default [
4
+ export const traceCategories = [
5
5
  '-*',
6
6
  'disabled-by-default-lighthouse',
7
7
  'v8',
@@ -119,9 +119,7 @@ function cleanTrace(trace, url) {
119
119
  // and using TS of first found TracingStartedIn* event
120
120
 
121
121
  // With Chrome 58 we got undefined events on Travis (I cant't reproduce it on my local)
122
- if (mostActiveFrame !== undefined) {
123
- traceEvents.unshift(makeMockEvent(mostActiveFrame, ts));
124
- } else {
122
+ if (mostActiveFrame === undefined) {
125
123
  // sometimes it seems we are missing inserting the 'TracingStartedInPage
126
124
  // let log and find out more
127
125
  log.error(
@@ -130,6 +128,8 @@ function cleanTrace(trace, url) {
130
128
  traceEvents.length,
131
129
  threads
132
130
  );
131
+ } else {
132
+ traceEvents.unshift(makeMockEvent(mostActiveFrame, ts));
133
133
  }
134
134
 
135
135
  // Verify that we got a navigationStart event for that frame. In Chrome 76 we started to get
@@ -4,7 +4,7 @@ import get from 'lodash.get';
4
4
  import { logging } from 'selenium-webdriver';
5
5
  import { ServiceBuilder, Options } from 'selenium-webdriver/chrome.js';
6
6
  import { pac, manual } from 'selenium-webdriver/proxy.js';
7
- import setupChromiumOptions from './setupChromiumOptions.js';
7
+ import { setupChromiumOptions } from './setupChromiumOptions.js';
8
8
 
9
9
  /**
10
10
  * Configure a WebDriver builder based on the specified options.
@@ -5,20 +5,20 @@ import { logging } from 'selenium-webdriver';
5
5
  import intel from 'intel';
6
6
  const log = intel.getLogger('browsertime.chrome');
7
7
  const { Type } = logging;
8
- import cpuMetrics from '../longTaskMetrics.js';
9
- import parseCpuTrace from '../parseCpuTrace.js';
10
- import har from '../har.js';
8
+ import { longTaskMetrics } from '../longTaskMetrics.js';
9
+ import { parseCPUTrace } from '../parseCpuTrace.js';
10
+ import { getHar } from '../har.js';
11
11
  import { getEmptyHAR, mergeHars } from '../../support/har/index.js';
12
12
  import { toArray } from '../../support/util.js';
13
13
  import { logging as _logging } from 'selenium-webdriver';
14
14
  import { parse } from '../traceCategoriesParser.js';
15
- import pathToFolder from '../../support/pathToFolder.js';
16
- import ChromeDevtoolsProtocol from '../chromeDevtoolsProtocol.js';
15
+ import { pathToFolder } from '../../support/pathToFolder.js';
16
+ import { ChromeDevtoolsProtocol } from '../chromeDevtoolsProtocol.js';
17
17
  import { Android, isAndroidConfigured } from '../../android/index.js';
18
18
  const unlink = promisify(_unlink);
19
19
  const rm = promisify(_rm);
20
20
 
21
- class Chromium {
21
+ export class Chromium {
22
22
  constructor(storageManager, options) {
23
23
  this.options = options;
24
24
  this.chrome = options.chrome || {};
@@ -248,7 +248,7 @@ class Chromium {
248
248
 
249
249
  if (!this.skipHar) {
250
250
  this.hars.push(
251
- await har(
251
+ await getHar(
252
252
  runner,
253
253
  result,
254
254
  index,
@@ -286,11 +286,9 @@ class Chromium {
286
286
  break;
287
287
  }
288
288
  default: {
289
- if (m.name.includes('Duration')) {
290
- cleanedMetrics[m.name] = m.value * 1000;
291
- } else {
292
- cleanedMetrics[m.name] = m.value;
293
- }
289
+ cleanedMetrics[m.name] = m.name.includes('Duration')
290
+ ? m.value * 1000
291
+ : m.value;
294
292
  }
295
293
  }
296
294
  }
@@ -334,7 +332,7 @@ class Chromium {
334
332
  if (this.collectTracingEvents) {
335
333
  const trace = parse(this.events, result.url);
336
334
  result.extraJson[`trace-${index}.json`] = trace;
337
- const cpu = await parseCpuTrace(trace, result.url);
335
+ const cpu = await parseCPUTrace(trace, result.url);
338
336
  result.cpu = cpu;
339
337
 
340
338
  // Collect render blocking info
@@ -420,7 +418,7 @@ class Chromium {
420
418
  result.browserScripts.pageinfo &&
421
419
  result.browserScripts.pageinfo.longTask
422
420
  ) {
423
- const cpuData = cpuMetrics(result, this.options);
421
+ const cpuData = longTaskMetrics(result, this.options);
424
422
  if (result.cpu) {
425
423
  result.cpu.longTasks = cpuData.longTasks;
426
424
  } else {
@@ -492,12 +490,10 @@ class Chromium {
492
490
  }
493
491
 
494
492
  async getHARs() {
495
- return !this.skipHar ? { har: mergeHars(this.hars) } : {};
493
+ return this.skipHar ? {} : { har: mergeHars(this.hars) };
496
494
  }
497
495
 
498
496
  async setCookies(url, cookies) {
499
497
  return this.cdpClient.setCookies(url, cookies);
500
498
  }
501
499
  }
502
-
503
- export default Chromium;
@@ -1,8 +1,8 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import intel from 'intel';
3
- import defaultChromeOptions from '../settings/chromeDesktopOptions.js';
4
- import defaultAndroidChromeOptions from '../settings/chromeAndroidOptions.js';
5
- import getViewPort from '../../support/getViewPort.js';
3
+ import { chromeDesktopOptions as defaultChromeOptions } from '../settings/chromeDesktopOptions.js';
4
+ import { chromeAndroidOptions as defaultAndroidChromeOptions } from '../settings/chromeAndroidOptions.js';
5
+ import { getViewPort } from '../../support/getViewPort.js';
6
6
  import { toArray } from '../../support/util.js';
7
7
  import { isAndroidConfigured } from '../../android/index.js';
8
8
  const log = intel.getLogger('browsertime.chrome');
@@ -19,7 +19,12 @@ const CHROME_AMD_EDGE_INTERNAL_PHONE_HOME = [
19
19
  '"MAP optimizationguide-pa.googleapis.com 127.0.0.1"'
20
20
  ];
21
21
 
22
- export default function (seleniumOptions, browserOptions, options, baseDir) {
22
+ export function setupChromiumOptions(
23
+ seleniumOptions,
24
+ browserOptions,
25
+ options,
26
+ baseDir
27
+ ) {
23
28
  // Fixing save password popup, only on Desktop
24
29
 
25
30
  if (!isAndroidConfigured(options)) {
@@ -93,9 +98,9 @@ export default function (seleniumOptions, browserOptions, options, baseDir) {
93
98
  }
94
99
 
95
100
  if (options.extension) {
96
- const extensions = !Array.isArray(options.extension)
97
- ? [options.extension]
98
- : options.extension;
101
+ const extensions = Array.isArray(options.extension)
102
+ ? options.extension
103
+ : [options.extension];
99
104
  for (const extension of extensions) {
100
105
  seleniumOptions.addExtensions(
101
106
  readFileSync(extension, { encoding: 'base64' })
@@ -119,9 +124,9 @@ export default function (seleniumOptions, browserOptions, options, baseDir) {
119
124
  }
120
125
 
121
126
  if (browserOptions.collectNetLog) {
122
- const dir = !isAndroidConfigured(browserOptions)
123
- ? baseDir
124
- : '/data/local/tmp';
127
+ const dir = isAndroidConfigured(browserOptions)
128
+ ? '/data/local/tmp'
129
+ : baseDir;
125
130
  seleniumOptions.addArguments(`--log-net-log=${dir}/chromeNetlog.json`);
126
131
  const level = browserOptions.netLogCaptureMode || 'IncludeSensitive';
127
132
  seleniumOptions.addArguments(`--net-log-capture-mode=${level}`);
@@ -133,13 +138,13 @@ export default function (seleniumOptions, browserOptions, options, baseDir) {
133
138
  '--remote-debugging-port=' + options.devToolsPort
134
139
  );
135
140
  } else {
136
- if (!browserOptions.noDefaultOptions) {
141
+ if (browserOptions.noDefaultOptions) {
142
+ log.info('Skip setting default options for Chrome');
143
+ } else {
137
144
  seleniumOptions.addArguments(defaultChromeOptions);
138
145
  seleniumOptions.addArguments(
139
146
  '--remote-debugging-port=' + options.devToolsPort
140
147
  );
141
- } else {
142
- log.info('Skip setting default options for Chrome');
143
148
  }
144
149
  }
145
150
 
@@ -4,7 +4,7 @@ import get from 'lodash.get';
4
4
  import intel from 'intel';
5
5
  const log = intel.getLogger('browsertime.connectivity.humble');
6
6
 
7
- class Humble {
7
+ export class Humble {
8
8
  constructor(options) {
9
9
  this.url = get(options.connectivity, 'humble.url');
10
10
  this.profile = options.connectivity.profile;
@@ -13,13 +13,13 @@ class Humble {
13
13
  async start(profile) {
14
14
  const library = this.url.startsWith('https') ? https : http;
15
15
  const res = await new Promise(resolve => {
16
- if (this.profile !== 'custom') {
17
- library.get(`${this.url}/api/${this.profile}`, resolve);
18
- } else {
16
+ if (this.profile === 'custom') {
19
17
  library.get(
20
18
  `${this.url}/api/custom?up=${profile.up}&down=${profile.down}&rtt=${profile.rtt}`,
21
19
  resolve
22
20
  );
21
+ } else {
22
+ library.get(`${this.url}/api/${this.profile}`, resolve);
23
23
  }
24
24
  });
25
25
 
@@ -30,10 +30,10 @@ class Humble {
30
30
  res.on('end', () => resolve(data));
31
31
  });
32
32
 
33
- if (res.statusCode !== 200) {
34
- log.error('Humble response: %s', data);
35
- } else {
33
+ if (res.statusCode === 200) {
36
34
  log.info('Switch Humble at %s to use profile %s', this.url, this.profile);
35
+ } else {
36
+ log.error('Humble response: %s', data);
37
37
  }
38
38
  }
39
39
 
@@ -50,12 +50,10 @@ class Humble {
50
50
  res.on('end', () => resolve(data));
51
51
  });
52
52
 
53
- if (res.statusCode !== 200) {
54
- log.error('Humble response: %s', data);
55
- } else {
53
+ if (res.statusCode === 200) {
56
54
  log.info('Humble throttling stopped successfully');
55
+ } else {
56
+ log.error('Humble response: %s', data);
57
57
  }
58
58
  }
59
59
  }
60
-
61
- export default Humble;
@@ -5,7 +5,7 @@ import {
5
5
  stop as throttleStop
6
6
  } from '@sitespeed.io/throttle';
7
7
  const log = intel.getLogger('browsertime.connectivity');
8
- import Humble from './humble.js';
8
+ import { Humble } from './humble.js';
9
9
  import { parseTrafficShapeConfig } from './trafficShapeParser.js';
10
10
 
11
11
  let humble;
@@ -4,7 +4,7 @@ import get from 'lodash.get';
4
4
  import intel from 'intel';
5
5
  import { timestamp as _timestamp } from '../../support/engineUtils.js';
6
6
  import { Statistics } from '../../support/statistics.js';
7
- import pathToFolder from '../../support/pathToFolder.js';
7
+ import { pathToFolder } from '../../support/pathToFolder.js';
8
8
  import { getConnectivitySettings } from '../../connectivity/index.js';
9
9
  import { formatMetric } from '../../support/util.js';
10
10
  const require = createRequire(import.meta.url);
@@ -60,7 +60,7 @@ function getNewResult(url, options) {
60
60
  * per iteration and store what's needed to disk.
61
61
  * @class
62
62
  */
63
- class Collector {
63
+ export class Collector {
64
64
  constructor(url, storageManager, options) {
65
65
  this.options = options;
66
66
  this.storageManager = storageManager;
@@ -520,5 +520,3 @@ class Collector {
520
520
  }
521
521
  }
522
522
  }
523
-
524
- export default Collector;
@@ -2,7 +2,7 @@ import { By } from 'selenium-webdriver';
2
2
  import intel from 'intel';
3
3
  const log = intel.getLogger('browsertime.command.addText');
4
4
 
5
- class AddText {
5
+ export class AddText {
6
6
  constructor(browser) {
7
7
  this.browser = browser;
8
8
  }
@@ -117,4 +117,3 @@ class AddText {
117
117
  }
118
118
  }
119
119
  }
120
- export default AddText;
@@ -1,7 +1,7 @@
1
1
  import intel from 'intel';
2
2
  import { Android, isAndroidConfigured } from '../../../android/index.js';
3
3
  const log = intel.getLogger('browsertime.command.android');
4
- export default class AndroidCommand {
4
+ export class AndroidCommand {
5
5
  constructor(options) {
6
6
  this.options = options;
7
7
  }