browsertime 16.17.0 → 17.0.0-beta.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 (121) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/bin/browsertime.js +43 -43
  3. package/bin/browsertimeWebPageReplay.js +10 -9
  4. package/browserscripts/pageinfo/generator.js +1 -1
  5. package/index.js +14 -13
  6. package/lib/android/gnirehtet.js +14 -15
  7. package/lib/android/index.js +92 -89
  8. package/lib/android/root.js +6 -9
  9. package/lib/chrome/chromeDevtoolsProtocol.js +46 -45
  10. package/lib/chrome/har.js +12 -13
  11. package/lib/chrome/longTaskMetrics.js +3 -5
  12. package/lib/chrome/parseCpuTrace.js +13 -10
  13. package/lib/chrome/settings/chromeAndroidOptions.js +1 -3
  14. package/lib/chrome/settings/chromeDesktopOptions.js +1 -3
  15. package/lib/chrome/settings/traceCategories.js +1 -3
  16. package/lib/chrome/traceCategoriesParser.js +35 -36
  17. package/lib/chrome/webdriver/builder.js +18 -26
  18. package/lib/chrome/webdriver/chromium.js +56 -46
  19. package/lib/chrome/webdriver/setupChromiumOptions.js +32 -27
  20. package/lib/connectivity/humble.js +13 -14
  21. package/lib/connectivity/index.js +74 -77
  22. package/lib/connectivity/trafficShapeParser.js +31 -35
  23. package/lib/core/engine/collector.js +22 -22
  24. package/lib/core/engine/command/addText.js +24 -27
  25. package/lib/core/engine/command/android.js +7 -11
  26. package/lib/core/engine/command/cache.js +3 -4
  27. package/lib/core/engine/command/chromeDevToolsProtocol.js +20 -20
  28. package/lib/core/engine/command/click.js +48 -49
  29. package/lib/core/engine/command/debug.js +3 -4
  30. package/lib/core/engine/command/javaScript.js +18 -19
  31. package/lib/core/engine/command/measure.js +31 -37
  32. package/lib/core/engine/command/meta.js +1 -4
  33. package/lib/core/engine/command/mouse/clickAndHold.js +36 -39
  34. package/lib/core/engine/command/mouse/contextClick.js +17 -18
  35. package/lib/core/engine/command/mouse/doubleClick.js +17 -19
  36. package/lib/core/engine/command/mouse/index.js +5 -9
  37. package/lib/core/engine/command/mouse/mouseMove.js +19 -23
  38. package/lib/core/engine/command/mouse/singleClick.js +15 -19
  39. package/lib/core/engine/command/navigation.js +12 -14
  40. package/lib/core/engine/command/screenshot.js +1 -4
  41. package/lib/core/engine/command/scroll.js +4 -7
  42. package/lib/core/engine/command/select.js +26 -26
  43. package/lib/core/engine/command/set.js +25 -23
  44. package/lib/core/engine/command/stopWatch.js +5 -8
  45. package/lib/core/engine/command/switch.js +18 -20
  46. package/lib/core/engine/command/util/lcpHighlightScript.js +1 -2
  47. package/lib/core/engine/command/util/lsHighlightScript.js +1 -2
  48. package/lib/core/engine/command/wait.js +18 -18
  49. package/lib/core/engine/index.js +81 -71
  50. package/lib/core/engine/iteration.js +83 -79
  51. package/lib/core/engine/run.js +5 -9
  52. package/lib/core/pageCompleteChecks/defaultPageCompleteCheck.js +1 -2
  53. package/lib/core/pageCompleteChecks/pageCompleteCheckByInactivity.js +1 -3
  54. package/lib/core/pageCompleteChecks/spaInactivity.js +1 -3
  55. package/lib/core/seleniumRunner.js +92 -100
  56. package/lib/core/webdriver/index.js +24 -21
  57. package/lib/edge/webdriver/builder.js +21 -26
  58. package/lib/extensionserver/httpServer.js +17 -21
  59. package/lib/extensionserver/index.js +8 -12
  60. package/lib/extensionserver/setup.js +12 -12
  61. package/lib/firefox/geckoProfiler.js +27 -21
  62. package/lib/firefox/getHAR.js +7 -8
  63. package/lib/firefox/memoryReport.js +9 -11
  64. package/lib/firefox/perfStats.js +5 -7
  65. package/lib/firefox/settings/disableSafeBrowsingPreferences.js +1 -3
  66. package/lib/firefox/settings/disableTrackingProtectionPreferences.js +1 -3
  67. package/lib/firefox/settings/firefoxPreferences.js +2 -4
  68. package/lib/firefox/settings/geckoProfilerDefaults.js +5 -9
  69. package/lib/firefox/webdriver/builder.js +66 -63
  70. package/lib/firefox/webdriver/firefox.js +43 -48
  71. package/lib/safari/webdriver/builder.js +4 -5
  72. package/lib/safari/webdriver/safari.js +4 -8
  73. package/lib/screenshot/defaults.js +1 -3
  74. package/lib/screenshot/index.js +24 -21
  75. package/lib/support/browserScript.js +65 -56
  76. package/lib/support/cli.js +120 -87
  77. package/lib/support/dns.js +6 -7
  78. package/lib/support/engineUtils.js +85 -38
  79. package/lib/support/errors.js +4 -13
  80. package/lib/support/fileUtil.js +81 -68
  81. package/lib/support/filters.js +15 -20
  82. package/lib/support/getViewPort.js +6 -7
  83. package/lib/support/har/index.js +208 -216
  84. package/lib/support/images/index.js +54 -26
  85. package/lib/support/logging.js +20 -17
  86. package/lib/support/pathToFolder.js +18 -23
  87. package/lib/support/preURL.js +5 -6
  88. package/lib/support/processes.js +4 -6
  89. package/lib/support/setResourceTimingBufferSize.js +2 -4
  90. package/lib/support/statistics.js +58 -56
  91. package/lib/support/stop.js +7 -8
  92. package/lib/support/storageManager.js +44 -44
  93. package/lib/support/tcpdump.js +22 -16
  94. package/lib/support/userTiming.js +7 -13
  95. package/lib/support/util.js +204 -224
  96. package/lib/support/xvfb.js +11 -13
  97. package/lib/video/defaults.js +6 -10
  98. package/lib/video/postprocessing/finetune/addTextToVideo.js +15 -15
  99. package/lib/video/postprocessing/finetune/convertFps.js +14 -8
  100. package/lib/video/postprocessing/finetune/getFont.js +7 -9
  101. package/lib/video/postprocessing/finetune/getTimingMetrics.js +19 -18
  102. package/lib/video/postprocessing/finetune/index.js +40 -36
  103. package/lib/video/postprocessing/finetune/removeOrange.js +10 -11
  104. package/lib/video/postprocessing/visualmetrics/extraMetrics.js +17 -13
  105. package/lib/video/postprocessing/visualmetrics/getVideoMetrics.js +12 -13
  106. package/lib/video/postprocessing/visualmetrics/visualMetrics.js +117 -128
  107. package/lib/video/screenRecording/android/recorder.js +12 -17
  108. package/lib/video/screenRecording/desktop/convert.js +13 -11
  109. package/lib/video/screenRecording/desktop/desktopRecorder.js +29 -24
  110. package/lib/video/screenRecording/desktop/ffmpegRecorder.js +60 -63
  111. package/lib/video/screenRecording/desktop/osx/getSPDisplaysDataType.js +4 -6
  112. package/lib/video/screenRecording/desktop/osx/getScreen.js +9 -10
  113. package/lib/video/screenRecording/firefox/firefoxWindowRecorder.js +54 -54
  114. package/lib/video/screenRecording/ios/convertToMp4.js +10 -11
  115. package/lib/video/screenRecording/ios/iosRecorder.js +23 -21
  116. package/lib/video/screenRecording/iosSimulator/convertToMp4.js +10 -11
  117. package/lib/video/screenRecording/iosSimulator/recorder.js +10 -9
  118. package/lib/video/screenRecording/recorder.js +8 -9
  119. package/lib/video/screenRecording/setOrangeBackground.js +5 -6
  120. package/lib/video/video.js +28 -34
  121. package/package.json +19 -17
@@ -1,9 +1,8 @@
1
- 'use strict';
2
-
3
- const http = require('http');
4
- const https = require('https');
5
- const get = require('lodash.get');
6
- const log = require('intel').getLogger('browsertime.connectivity.humble');
1
+ import http from 'node:http';
2
+ import https from 'node:https';
3
+ import get from 'lodash.get';
4
+ import intel from 'intel';
5
+ const log = intel.getLogger('browsertime.connectivity.humble');
7
6
 
8
7
  class Humble {
9
8
  constructor(options) {
@@ -12,12 +11,12 @@ class Humble {
12
11
  }
13
12
 
14
13
  async start(profile) {
15
- const lib = this.url.startsWith('https') ? https : http;
14
+ const library = this.url.startsWith('https') ? https : http;
16
15
  const res = await new Promise(resolve => {
17
16
  if (this.profile !== 'custom') {
18
- lib.get(`${this.url}/api/${this.profile}`, resolve);
17
+ library.get(`${this.url}/api/${this.profile}`, resolve);
19
18
  } else {
20
- lib.get(
19
+ library.get(
21
20
  `${this.url}/api/custom?up=${profile.up}&down=${profile.down}&rtt=${profile.rtt}`,
22
21
  resolve
23
22
  );
@@ -27,7 +26,7 @@ class Humble {
27
26
  let data = await new Promise((resolve, reject) => {
28
27
  let data = '';
29
28
  res.on('data', chunk => (data += chunk));
30
- res.on('error', err => reject(err));
29
+ res.on('error', error => reject(error));
31
30
  res.on('end', () => resolve(data));
32
31
  });
33
32
 
@@ -39,15 +38,15 @@ class Humble {
39
38
  }
40
39
 
41
40
  async stop() {
42
- const lib = this.url.startsWith('https') ? https : http;
41
+ const library = this.url.startsWith('https') ? https : http;
43
42
  const res = await new Promise(resolve => {
44
- lib.get(`${this.url}/api/stop`, resolve);
43
+ library.get(`${this.url}/api/stop`, resolve);
45
44
  });
46
45
 
47
46
  let data = await new Promise((resolve, reject) => {
48
47
  let data = '';
49
48
  res.on('data', chunk => (data += chunk));
50
- res.on('error', err => reject(err));
49
+ res.on('error', error => reject(error));
51
50
  res.on('end', () => resolve(data));
52
51
  });
53
52
 
@@ -59,4 +58,4 @@ class Humble {
59
58
  }
60
59
  }
61
60
 
62
- module.exports = Humble;
61
+ export default Humble;
@@ -1,11 +1,14 @@
1
- 'use strict';
1
+ import get from 'lodash.get';
2
+ import intel from 'intel';
3
+ import {
4
+ start as throttleStart,
5
+ stop as throttleStop
6
+ } from '@sitespeed.io/throttle';
7
+ const log = intel.getLogger('browsertime.connectivity');
8
+ import Humble from './humble.js';
9
+ import { parseTrafficShapeConfig } from './trafficShapeParser.js';
2
10
 
3
- const trafficShapeParser = require('./trafficShapeParser');
4
- const get = require('lodash.get');
5
- const log = require('intel').getLogger('browsertime.connectivity');
6
- const Humble = require('./humble');
7
-
8
- let humble = null;
11
+ let humble;
9
12
 
10
13
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
11
14
  function getRandomIntInclusive(min, max) {
@@ -14,89 +17,83 @@ function getRandomIntInclusive(min, max) {
14
17
  return Math.floor(Math.random() * (max - min + 1)) + min;
15
18
  }
16
19
 
17
- module.exports = {
18
- async addConnectivity(options) {
19
- const profile = trafficShapeParser.parseTrafficShapeConfig(options);
20
- if (!profile) {
20
+ export async function addConnectivity(options) {
21
+ const profile = parseTrafficShapeConfig(options);
22
+ if (!profile) {
23
+ return;
24
+ }
25
+
26
+ const connectivity = options.connectivity;
27
+ switch (connectivity.engine) {
28
+ case 'external': {
21
29
  return;
22
30
  }
23
-
24
- const connectivity = options.connectivity;
25
- switch (connectivity.engine) {
26
- case 'external': {
27
- return;
28
- }
29
- case 'throttle': {
30
- if (!options.docker) {
31
- // The log message is confusing if you run in Docker since
32
- // there's nothing you can do about it
33
- if (options.connectivity && options.connectivity.profile) {
34
- log.info(
35
- 'Changing network interfaces needs sudo rights. Setting connectivity profile %s',
36
- options.connectivity.profile
37
- );
38
- } else {
39
- log.info('Changing network interfaces needs sudo rights.');
40
- }
41
- }
42
-
43
- const setOnLocalHost = get(connectivity, 'throttle.localhost', false);
44
- const rtt = profile.variance
45
- ? getRandomIntInclusive(
46
- profile.rtt,
47
- Math.ceil(profile.rtt * (profile.variance / 100 + 1))
48
- )
49
- : profile.rtt;
50
- if (profile.variance) {
31
+ case 'throttle': {
32
+ if (!options.docker) {
33
+ // The log message is confusing if you run in Docker since
34
+ // there's nothing you can do about it
35
+ if (options.connectivity && options.connectivity.profile) {
51
36
  log.info(
52
- 'Using random variance %s% setting the latency to %s (configured %s)',
53
- profile.variance,
54
- rtt,
55
- profile.rtt
37
+ 'Changing network interfaces needs sudo rights. Setting connectivity profile %s',
38
+ options.connectivity.profile
56
39
  );
40
+ } else {
41
+ log.info('Changing network interfaces needs sudo rights.');
57
42
  }
58
- const throttle = await import('@sitespeed.io/throttle');
59
- if (setOnLocalHost) {
60
- return throttle.start({
43
+ }
44
+
45
+ const setOnLocalHost = get(connectivity, 'throttle.localhost', false);
46
+ const rtt = profile.variance
47
+ ? getRandomIntInclusive(
48
+ profile.rtt,
49
+ Math.ceil(profile.rtt * (profile.variance / 100 + 1))
50
+ )
51
+ : profile.rtt;
52
+ if (profile.variance) {
53
+ log.info(
54
+ 'Using random variance %s% setting the latency to %s (configured %s)',
55
+ profile.variance,
56
+ rtt,
57
+ profile.rtt
58
+ );
59
+ }
60
+ return setOnLocalHost
61
+ ? throttleStart({
61
62
  localhost: true,
62
63
  rtt
63
- });
64
- } else {
65
- return throttle.start({
64
+ })
65
+ : throttleStart({
66
66
  up: profile.up,
67
67
  down: profile.down,
68
68
  rtt
69
69
  });
70
- }
71
- }
72
- case 'humble': {
73
- humble = new Humble(options);
74
- return humble.start(profile);
75
- }
76
70
  }
77
- },
78
- getConnectivitySettings(options) {
79
- return trafficShapeParser.parseTrafficShapeConfig(options);
80
- },
81
- async removeConnectivity(options) {
82
- const profile = trafficShapeParser.parseTrafficShapeConfig(options);
83
- if (!profile) {
84
- return;
71
+ case 'humble': {
72
+ humble = new Humble(options);
73
+ return humble.start(profile);
85
74
  }
75
+ }
76
+ }
77
+ export function getConnectivitySettings(options) {
78
+ return parseTrafficShapeConfig(options);
79
+ }
80
+ export async function removeConnectivity(options) {
81
+ const profile = parseTrafficShapeConfig(options);
82
+ if (!profile) {
83
+ return;
84
+ }
86
85
 
87
- const connectivity = options.connectivity;
88
- switch (connectivity.engine) {
89
- case 'external': {
90
- return;
91
- }
92
- case 'throttle': {
93
- const setOnLocalHost = get(connectivity, 'throttle.localhost', false);
94
- const throttle = await import('@sitespeed.io/throttle');
95
- return throttle.stop({ localhost: setOnLocalHost });
96
- }
97
- case 'humble': {
98
- return humble.stop();
99
- }
86
+ const connectivity = options.connectivity;
87
+ switch (connectivity.engine) {
88
+ case 'external': {
89
+ return;
90
+ }
91
+ case 'throttle': {
92
+ const setOnLocalHost = get(connectivity, 'throttle.localhost', false);
93
+ return throttleStop({ localhost: setOnLocalHost });
94
+ }
95
+ case 'humble': {
96
+ return humble.stop();
100
97
  }
101
98
  }
102
- };
99
+ }
@@ -1,5 +1,3 @@
1
- 'use strict';
2
-
3
1
  /* Config from throttle following WebPageTest */
4
2
 
5
3
  const newProfiles = {
@@ -44,8 +42,8 @@ const newProfiles = {
44
42
  rtt: 85
45
43
  },
46
44
  lte: {
47
- down: 12000,
48
- up: 12000,
45
+ down: 12_000,
46
+ up: 12_000,
49
47
  rtt: 35
50
48
  },
51
49
  edge: {
@@ -59,7 +57,7 @@ const newProfiles = {
59
57
  rtt: 60
60
58
  },
61
59
  fois: {
62
- down: 20000,
60
+ down: 20_000,
63
61
  up: 5000,
64
62
  rtt: 2
65
63
  }
@@ -103,37 +101,35 @@ const legacyProfiles = {
103
101
  }
104
102
  };
105
103
 
106
- module.exports = {
107
- parseTrafficShapeConfig: function (options) {
108
- if (options.connectivity && options.connectivity.profile === 'custom') {
109
- return {
110
- down: options.connectivity.down,
111
- up: options.connectivity.up,
112
- rtt: options.connectivity.rtt,
113
- variance: options.connectivity.variance
114
- };
115
- }
104
+ export function parseTrafficShapeConfig(options) {
105
+ if (options.connectivity && options.connectivity.profile === 'custom') {
106
+ return {
107
+ down: options.connectivity.down,
108
+ up: options.connectivity.up,
109
+ rtt: options.connectivity.rtt,
110
+ variance: options.connectivity.variance
111
+ };
112
+ }
116
113
 
117
- if (options.connectivity && options.connectivity.profile) {
118
- if (options.connectivity.profile === 'native') {
119
- return null;
120
- }
114
+ if (options.connectivity && options.connectivity.profile) {
115
+ if (options.connectivity.profile === 'native') {
116
+ return;
117
+ }
121
118
 
122
- const profile = options.legacyConnectivityProfiles
123
- ? legacyProfiles[options.connectivity.profile]
124
- : newProfiles[options.connectivity.profile];
125
- profile.variance = options.connectivity.variance;
126
- if (!profile) {
127
- throw new Error(
128
- `Unknown connectivity profile ${options.connectivity.profile}`
129
- );
130
- }
131
- return profile;
132
- } else {
133
- return null;
119
+ const profile = options.legacyConnectivityProfiles
120
+ ? legacyProfiles[options.connectivity.profile]
121
+ : newProfiles[options.connectivity.profile];
122
+ profile.variance = options.connectivity.variance;
123
+ if (!profile) {
124
+ throw new Error(
125
+ `Unknown connectivity profile ${options.connectivity.profile}`
126
+ );
134
127
  }
135
- },
136
- getProfiles: function () {
137
- return newProfiles;
128
+ return profile;
129
+ } else {
130
+ return;
138
131
  }
139
- };
132
+ }
133
+ export function getProfiles() {
134
+ return newProfiles;
135
+ }
@@ -1,13 +1,15 @@
1
- 'use strict';
2
- const get = require('lodash.get');
3
- const version = require('../../../package').version;
4
- const engineUtils = require('../../support/engineUtils');
5
- const log = require('intel').getLogger('browsertime');
6
- const Statistics = require('../../support/statistics').Statistics;
7
- const pathToFolder = require('../../support/pathToFolder');
8
- const connectivity = require('../../connectivity/');
9
- const { formatMetric } = require('../../support/util');
10
- const path = require('path');
1
+ import { join } from 'node:path';
2
+ import { createRequire } from 'node:module';
3
+ import get from 'lodash.get';
4
+ import intel from 'intel';
5
+ import { timestamp as _timestamp } from '../../support/engineUtils.js';
6
+ import { Statistics } from '../../support/statistics.js';
7
+ import pathToFolder from '../../support/pathToFolder.js';
8
+ import { getConnectivitySettings } from '../../connectivity/index.js';
9
+ import { formatMetric } from '../../support/util.js';
10
+ const require = createRequire(import.meta.url);
11
+ const version = require('../../../package.json').version;
12
+ const log = intel.getLogger('browsertime');
11
13
 
12
14
  function getNewResult(url, options) {
13
15
  return {
@@ -16,11 +18,11 @@ function getNewResult(url, options) {
16
18
  version
17
19
  },
18
20
  url,
19
- timestamp: engineUtils.timestamp(),
21
+ timestamp: _timestamp(),
20
22
  connectivity: {
21
23
  engine: get(options, 'connectivity.engine'),
22
24
  profile: get(options, 'connectivity.profile'),
23
- settings: connectivity.getConnectivitySettings(options) || undefined
25
+ settings: getConnectivitySettings(options) || undefined
24
26
  },
25
27
  extra: JSON.parse(get(options, 'info.extra', '{}')),
26
28
  browser: { name: options.browser }
@@ -157,9 +159,7 @@ class Collector {
157
159
  url = this.aliasAndUrl[alias];
158
160
  }
159
161
 
160
- const results = this.allResults[url]
161
- ? this.allResults[url]
162
- : getNewResult(url, this.options);
162
+ const results = this.allResults[url] ?? getNewResult(url, this.options);
163
163
  results.info.description = allData.description;
164
164
  results.info.title = allData.title;
165
165
  results.info.browser.userAgent = get(
@@ -172,9 +172,7 @@ class Collector {
172
172
  results.files.screenshot.push(allData.screenshots);
173
173
  }
174
174
 
175
- const statistics = this.allStats[url]
176
- ? this.allStats[url]
177
- : new Statistics();
175
+ const statistics = this.allStats[url] ?? new Statistics();
178
176
 
179
177
  // The user can add extra data in a script or post script
180
178
  if (data.extras) {
@@ -205,14 +203,16 @@ class Collector {
205
203
  if (data.browserScripts) {
206
204
  results.browserScripts.push(data.browserScripts);
207
205
  // Add all browserscripts to the stats
206
+ const equals = (a1, a2) => JSON.stringify(a1) === JSON.stringify(a2);
208
207
  statistics.addDeep(data.browserScripts, (keyPath, value) => {
209
- const equals = (a1, a2) => JSON.stringify(a1) === JSON.stringify(a2);
210
208
  if (equals(keyPath.slice(-2), ['userTimings', 'marks'])) {
209
+ // eslint-disable-next-line unicorn/no-array-reduce
211
210
  return value.reduce((result, mark) => {
212
211
  result[mark.name] = mark.startTime;
213
212
  return result;
214
213
  }, {});
215
214
  } else if (equals(keyPath.slice(-2), ['userTimings', 'measures'])) {
215
+ // eslint-disable-next-line unicorn/no-array-reduce
216
216
  return value.reduce((result, mark) => {
217
217
  result[mark.name] = mark.duration;
218
218
  return result;
@@ -343,7 +343,7 @@ class Collector {
343
343
  }
344
344
  for (let key of Object.keys(data.visualMetrics)) {
345
345
  // Skip VisualProgress/ContentfulProgress etc
346
- if (key.indexOf('Progress') === -1) {
346
+ if (!key.includes('Progress')) {
347
347
  const d = { visualMetrics: {} };
348
348
  d['visualMetrics'][key] = data.visualMetrics[key];
349
349
  statistics.addDeep(d);
@@ -467,7 +467,7 @@ class Collector {
467
467
  for (let filename of Object.keys(data.extraJson)) {
468
468
  extraWork.push(
469
469
  this.storageManager.writeJson(
470
- path.join(pathToFolder(url, this.options), filename),
470
+ join(pathToFolder(url, this.options), filename),
471
471
  data.extraJson[filename],
472
472
  true
473
473
  )
@@ -521,4 +521,4 @@ class Collector {
521
521
  }
522
522
  }
523
523
 
524
- module.exports = Collector;
524
+ export default Collector;
@@ -1,7 +1,6 @@
1
- 'use strict';
2
-
3
- const webdriver = require('selenium-webdriver');
4
- const log = require('intel').getLogger('browsertime.command.addText');
1
+ import { By } from 'selenium-webdriver';
2
+ import intel from 'intel';
3
+ const log = intel.getLogger('browsertime.command.addText');
5
4
 
6
5
  class AddText {
7
6
  constructor(browser) {
@@ -19,14 +18,14 @@ class AddText {
19
18
  async byId(text, id) {
20
19
  const driver = this.browser.getDriver();
21
20
  try {
22
- const element = await driver.findElement(webdriver.By.id(id));
21
+ const element = await driver.findElement(By.id(id));
23
22
  // make sure we clear it
24
23
  await element.clear();
25
24
  return element.sendKeys(text);
26
- } catch (e) {
25
+ } catch (error) {
27
26
  log.error('Could not add text %s to id %s', text, id);
28
- log.verbose(e);
29
- throw Error(`Could not add text ${text} to id ${id}`);
27
+ log.verbose(error);
28
+ throw new Error(`Could not add text ${text} to id ${id}`);
30
29
  }
31
30
  }
32
31
 
@@ -41,14 +40,14 @@ class AddText {
41
40
  async byXpath(text, xpath) {
42
41
  const driver = this.browser.getDriver();
43
42
  try {
44
- const element = await driver.findElement(webdriver.By.xpath(xpath));
43
+ const element = await driver.findElement(By.xpath(xpath));
45
44
  // make sure we clear it
46
45
  await element.clear();
47
46
  return element.sendKeys(text);
48
- } catch (e) {
47
+ } catch (error) {
49
48
  log.error('Could not add text %s to xpath %s', text, xpath);
50
- log.verbose(e);
51
- throw Error(`Could not add text ${text} to xpath ${xpath}`);
49
+ log.verbose(error);
50
+ throw new Error(`Could not add text ${text} to xpath ${xpath}`);
52
51
  }
53
52
  }
54
53
 
@@ -63,14 +62,14 @@ class AddText {
63
62
  async bySelector(text, selector) {
64
63
  const driver = this.browser.getDriver();
65
64
  try {
66
- const element = await driver.findElement(webdriver.By.css(selector));
65
+ const element = await driver.findElement(By.css(selector));
67
66
  // make sure we clear it
68
67
  await element.clear();
69
68
  return element.sendKeys(text);
70
- } catch (e) {
69
+ } catch (error) {
71
70
  log.error('Could not add text %s to selector %s', text, selector);
72
- log.verbose(e);
73
- throw Error(`Could not add text ${text} to selector ${selector}`);
71
+ log.verbose(error);
72
+ throw new Error(`Could not add text ${text} to selector ${selector}`);
74
73
  }
75
74
  }
76
75
 
@@ -85,16 +84,14 @@ class AddText {
85
84
  async byClassName(text, className) {
86
85
  const driver = this.browser.getDriver();
87
86
  try {
88
- const element = await driver.findElement(
89
- webdriver.By.className(className)
90
- );
87
+ const element = await driver.findElement(By.className(className));
91
88
  // make sure we clear it
92
89
  await element.clear();
93
90
  return element.sendKeys(text);
94
- } catch (e) {
91
+ } catch (error) {
95
92
  log.error('Could not add text %s to class name %s', text, className);
96
- log.verbose(e);
97
- throw Error(`Could not add text ${text} to class name ${className}`);
93
+ log.verbose(error);
94
+ throw new Error(`Could not add text ${text} to class name ${className}`);
98
95
  }
99
96
  }
100
97
 
@@ -109,15 +106,15 @@ class AddText {
109
106
  async byName(text, name) {
110
107
  const driver = this.browser.getDriver();
111
108
  try {
112
- const element = await driver.findElement(webdriver.By.name(name));
109
+ const element = await driver.findElement(By.name(name));
113
110
  // make sure we clear it
114
111
  await element.clear();
115
112
  return element.sendKeys(text);
116
- } catch (e) {
113
+ } catch (error) {
117
114
  log.error('Could not add text %s to name attribute %s', text, name);
118
- log.verbose(e);
119
- throw Error(`Could not add text ${text} to name attribute ${name}`);
115
+ log.verbose(error);
116
+ throw new Error(`Could not add text ${text} to name attribute ${name}`);
120
117
  }
121
118
  }
122
119
  }
123
- module.exports = AddText;
120
+ export default AddText;
@@ -1,9 +1,7 @@
1
- 'use strict';
2
-
3
- const log = require('intel').getLogger('browsertime.command.android');
4
- const { Android, isAndroidConfigured } = require('../../../android');
5
-
6
- class AndroidCommand {
1
+ import intel from 'intel';
2
+ import { Android, isAndroidConfigured } from '../../../android/index.js';
3
+ const log = intel.getLogger('browsertime.command.android');
4
+ export default class AndroidCommand {
7
5
  constructor(options) {
8
6
  this.options = options;
9
7
  }
@@ -20,12 +18,10 @@ class AndroidCommand {
20
18
  try {
21
19
  this.a = new Android(this.options);
22
20
  return this.a._runCommandAndGet(command);
23
- } catch (e) {
24
- log.error('Could not run shell command %s', command, e);
25
- throw Error(`Could not run Android shell commmand ${command}`);
21
+ } catch (error) {
22
+ log.error('Could not run shell command %s', command, error);
23
+ throw new Error(`Could not run Android shell commmand ${command}`);
26
24
  }
27
25
  } else throw new Error('Android is not configured');
28
26
  }
29
27
  }
30
-
31
- module.exports = AndroidCommand;
@@ -1,6 +1,5 @@
1
- 'use strict';
2
-
3
- const log = require('intel').getLogger('browsertime.command.cache');
1
+ import intel from 'intel';
2
+ const log = intel.getLogger('browsertime.command.cache');
4
3
  class Cache {
5
4
  constructor(browser, browserName, extensionServer, cdp) {
6
5
  this.browser = browser;
@@ -46,4 +45,4 @@ class Cache {
46
45
  }
47
46
  }
48
47
  }
49
- module.exports = Cache;
48
+ export default Cache;