browsertime 14.4.0 → 14.7.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 (55) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/bin/browsertime.js +1 -1
  3. package/lib/android/index.js +1 -1
  4. package/lib/chrome/har.js +4 -4
  5. package/lib/chrome/longTaskMetrics.js +1 -1
  6. package/lib/chrome/speedline.js +2 -2
  7. package/lib/chrome/webdriver/builder.js +1 -1
  8. package/lib/chrome/webdriver/setupChromiumOptions.js +7 -2
  9. package/lib/connectivity/trafficShapeParser.js +2 -2
  10. package/lib/connectivity/tsProxy.js +3 -3
  11. package/lib/core/engine/command/measure.js +16 -10
  12. package/lib/core/engine/command/mouse/clickAndHold.js +146 -0
  13. package/lib/core/engine/command/mouse/contextClick.js +61 -0
  14. package/lib/core/engine/command/mouse/doubleClick.js +76 -0
  15. package/lib/core/engine/command/mouse/index.js +9 -0
  16. package/lib/core/engine/command/mouse/mouseMove.js +81 -0
  17. package/lib/core/engine/command/mouse/singleClick.js +79 -0
  18. package/lib/core/engine/command/switch.js +2 -8
  19. package/lib/core/engine/iteration.js +5 -6
  20. package/lib/core/engine/run.js +2 -2
  21. package/lib/core/seleniumRunner.js +23 -22
  22. package/lib/core/webdriver/index.js +1 -1
  23. package/lib/edge/webdriver/builder.js +1 -1
  24. package/lib/extensionserver/setup.js +1 -1
  25. package/lib/firefox/geckoProfiler.js +2 -3
  26. package/lib/firefox/getHAR.js +1 -1
  27. package/lib/firefox/webdriver/builder.js +12 -7
  28. package/lib/firefox/webdriver/firefox.js +6 -7
  29. package/lib/safari/webdriver/builder.js +1 -1
  30. package/lib/support/browserScript.js +1 -1
  31. package/lib/support/cli.js +12 -0
  32. package/lib/support/engineUtils.js +1 -1
  33. package/lib/support/getViewPort.js +1 -1
  34. package/lib/support/har/index.js +13 -14
  35. package/lib/support/pathToFolder.js +4 -10
  36. package/lib/support/preURL.js +1 -1
  37. package/lib/support/setResourceTimingBufferSize.js +1 -1
  38. package/lib/support/statistics.js +1 -1
  39. package/lib/support/stop.js +1 -1
  40. package/lib/support/storageManager.js +5 -10
  41. package/lib/video/postprocessing/finetune/addTextToVideo.js +1 -1
  42. package/lib/video/postprocessing/finetune/convertFps.js +1 -1
  43. package/lib/video/postprocessing/finetune/getFont.js +1 -1
  44. package/lib/video/postprocessing/finetune/getTimingMetrics.js +5 -4
  45. package/lib/video/postprocessing/finetune/index.js +1 -1
  46. package/lib/video/postprocessing/finetune/removeOrange.js +1 -1
  47. package/lib/video/postprocessing/visualmetrics/extraMetrics.js +1 -1
  48. package/lib/video/postprocessing/visualmetrics/getVideoMetrics.js +1 -1
  49. package/lib/video/screenRecording/desktop/ffmpegRecorder.js +3 -3
  50. package/lib/video/screenRecording/desktop/osx/getSPDisplaysDataType.js +1 -1
  51. package/lib/video/screenRecording/desktop/osx/getScreen.js +1 -1
  52. package/lib/video/screenRecording/firefox/firefoxWindowRecorder.js +2 -2
  53. package/lib/video/screenRecording/setOrangeBackground.js +1 -1
  54. package/package.json +9 -9
  55. package/lib/core/engine/command/mouse.js +0 -314
@@ -26,11 +26,12 @@ function get(metric, metricName, pos, options) {
26
26
  }
27
27
 
28
28
  // H-h/8
29
- return `drawtext=${fontFile}enable='between(t,${Number(metric) /
30
- 1000},30)':x=(w-tw)/2: y=H-${pos}-h/${x}:fontcolor=white:fontsize=h/${fontSize}:box=1:boxcolor=0x000000AA:boxborderw=2:text='${metricName} ${metric}'`;
29
+ return `drawtext=${fontFile}enable='between(t,${
30
+ Number(metric) / 1000
31
+ },30)':x=(w-tw)/2: y=H-${pos}-h/${x}:fontcolor=white:fontsize=h/${fontSize}:box=1:boxcolor=0x000000AA:boxborderw=2:text='${metricName} ${metric}'`;
31
32
  }
32
33
 
33
- module.exports = function(videoMetrics, timingMetrics, options) {
34
+ module.exports = function (videoMetrics, timingMetrics, options) {
34
35
  let text = '';
35
36
  const vm = videoMetrics.visualMetrics;
36
37
  const startPosition = 'h/10';
@@ -59,7 +60,7 @@ module.exports = function(videoMetrics, timingMetrics, options) {
59
60
  });
60
61
  }
61
62
 
62
- metricsAndValues.sort(function(a, b) {
63
+ metricsAndValues.sort(function (a, b) {
63
64
  return b.value - a.value;
64
65
  });
65
66
 
@@ -12,7 +12,7 @@ const rename = promisify(fs.rename);
12
12
  const unlink = promisify(fs.unlink);
13
13
  const defaults = require('../../defaults');
14
14
 
15
- module.exports = async function(
15
+ module.exports = async function (
16
16
  videoDir,
17
17
  videoPath,
18
18
  index,
@@ -3,7 +3,7 @@
3
3
  const execa = require('execa');
4
4
  const log = require('intel').getLogger('browsertime.video');
5
5
 
6
- module.exports = async function(
6
+ module.exports = async function (
7
7
  inputFile,
8
8
  outputFile,
9
9
  newStart,
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- module.exports = function(metrics) {
3
+ module.exports = function (metrics) {
4
4
  const videoMetrics = {};
5
5
  if (!metrics.VisualReadiness) {
6
6
  metrics.VisualReadiness =
@@ -5,7 +5,7 @@ const path = require('path');
5
5
  const visualMetrics = require('./visualMetrics');
6
6
  const extraMetrics = require('./extraMetrics');
7
7
 
8
- module.exports = async function(
8
+ module.exports = async function (
9
9
  videoDir,
10
10
  filmstripDir,
11
11
  videoPath,
@@ -38,9 +38,9 @@ async function buildX11FfmpegArgs({
38
38
  '-r',
39
39
  30,
40
40
  '-filter:v',
41
- `crop=${widthAndHeight[0] * devicePixelRatio}:${widthAndHeight[1] *
42
- devicePixelRatio}:${offset.x * devicePixelRatio}:${offset.y *
43
- devicePixelRatio}`,
41
+ `crop=${widthAndHeight[0] * devicePixelRatio}:${
42
+ widthAndHeight[1] * devicePixelRatio
43
+ }:${offset.x * devicePixelRatio}:${offset.y * devicePixelRatio}`,
44
44
  '-codec:v',
45
45
  'libx264rgb',
46
46
  '-threads',
@@ -2,7 +2,7 @@
2
2
 
3
3
  const execa = require('execa');
4
4
 
5
- module.exports = async function() {
5
+ module.exports = async function () {
6
6
  const output = await execa.command('system_profiler SPDisplaysDataType', {
7
7
  shell: true
8
8
  });
@@ -3,7 +3,7 @@
3
3
  const execa = require('execa');
4
4
  const log = require('intel').getLogger('browsertime.video');
5
5
 
6
- module.exports = async function() {
6
+ module.exports = async function () {
7
7
  const scriptArgs = [
8
8
  '-hide_banner',
9
9
  '-f',
@@ -81,7 +81,7 @@ function writeFrameDurationsToFile(directoryName, imageFiles) {
81
81
  const stream = fs.createWriteStream(
82
82
  path.join(directoryName, 'durations.txt')
83
83
  );
84
- stream.once('open', function() {
84
+ stream.once('open', function () {
85
85
  stream.write(
86
86
  "file '" + path.join(directoryName, imageFiles[0].filename) + "'\n"
87
87
  );
@@ -120,7 +120,7 @@ async function generateVideo(destination, recordingDirectoryName) {
120
120
  imageFiles.push({ filename: newFilename, offset: offset });
121
121
  });
122
122
 
123
- imageFiles.sort(function(a, b) {
123
+ imageFiles.sort(function (a, b) {
124
124
  if (a.filename < b.filename) return -1;
125
125
  if (a.filename > b.filename) return 1;
126
126
  return 0;
@@ -2,7 +2,7 @@
2
2
 
3
3
  const log = require('intel').getLogger('browsertime.video');
4
4
  const { until, By } = require('selenium-webdriver');
5
- module.exports = async function(driver, options) {
5
+ module.exports = async function (driver, options) {
6
6
  log.debug('Add orange color');
7
7
  // We tried other ways for Android (access an orange page)
8
8
  // That works fine ... but break scripts
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "description": "Browsertime",
3
- "version": "14.4.0",
3
+ "version": "14.7.0",
4
4
  "bin": "./bin/browsertime.js",
5
5
  "dependencies": {
6
6
  "@sitespeed.io/throttle": "3.0.0",
7
7
  "@devicefarmer/adbkit": "2.11.3",
8
8
  "btoa": "1.2.1",
9
- "@sitespeed.io/chromedriver": "94.0.4606-41",
9
+ "@sitespeed.io/chromedriver": "95.0.4638-17",
10
10
  "chrome-har": "0.11.12",
11
11
  "chrome-remote-interface": "0.31.0",
12
12
  "dayjs": "1.10.5",
@@ -22,7 +22,7 @@
22
22
  "lodash.merge": "4.6.2",
23
23
  "lodash.pick": "4.4.0",
24
24
  "lodash.set": "4.3.2",
25
- "selenium-webdriver": "4.0.0-rc-1",
25
+ "selenium-webdriver": "4.0.0",
26
26
  "@sitespeed.io/edgedriver": "93.0.910-5",
27
27
  "@sitespeed.io/geckodriver": "0.29.1-2",
28
28
  "@sitespeed.io/tracium": "0.3.3",
@@ -34,15 +34,15 @@
34
34
  "jimp": "0.16.1"
35
35
  },
36
36
  "devDependencies": {
37
- "bluebird": "3.5.5",
38
- "chai": "4.2.0",
37
+ "bluebird": "3.7.2",
38
+ "chai": "4.3.4",
39
39
  "chai-as-promised": "7.1.1",
40
- "eslint": "6.2.2",
41
- "eslint-config-prettier": "6.1.0",
42
- "eslint-plugin-prettier": "3.1.0",
40
+ "eslint": "8.0.1",
41
+ "eslint-config-prettier": "8.3.0",
42
+ "eslint-plugin-prettier": "4.0.0",
43
43
  "longjohn": "0.2.12",
44
44
  "mocha": "6.2.0",
45
- "prettier": "1.18.2"
45
+ "prettier": "2.4.1"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=10.13.0"
@@ -1,314 +0,0 @@
1
- 'use strict';
2
-
3
- const log = require('intel').getLogger('browsertime.command.mouse');
4
- const webdriver = require('selenium-webdriver');
5
-
6
- class ClickAndHold {
7
- constructor(browser) {
8
- this.driver = browser.getDriver();
9
- this.actions = this.driver.actions({ async: true });
10
- }
11
-
12
- /**
13
- * Click and hold an element that matches a XPath selector.
14
- * @param {string} xpath
15
- * @returns {Promise} Promise object represents when mouse is pressed.
16
- * @throws Will throw an error if the element is not found.
17
- */
18
- async byXpath(xpath) {
19
- try {
20
- const element = await this.driver.findElement(webdriver.By.xpath(xpath));
21
- return this.actions
22
- .move({ origin: element })
23
- .press()
24
- .perform();
25
- } catch (e) {
26
- log.error('Could not click and hold on element with xpath %s', xpath);
27
- log.verbose(e);
28
- throw Error('Could not click and hold on element with xpath ' + xpath);
29
- }
30
- }
31
-
32
- /**
33
- * Click and hold an element at the cursor's position.
34
- * @param {string} xpath
35
- * @returns {Promise} Promise object represents when mouse is pressed.
36
- * @throws Will throw an error if action cannot be performed.
37
- */
38
- async atCursor() {
39
- try {
40
- return this.actions
41
- .move({ origin: webdriver.Origin.POINTER })
42
- .press()
43
- .perform();
44
- } catch (e) {
45
- log.error('Could not click and hold at cursor');
46
- log.verbose(e);
47
- throw Error('Could not click and hold at cursor');
48
- }
49
- }
50
-
51
- /**
52
- * Click and hold an element at the given coordinates.
53
- * @param {string} xpath
54
- * @returns {Promise} Promise object represents when mouse is pressed.
55
- * @throws Will throw an error if action cannot be performed.
56
- */
57
- async atPosition(xPos, yPos) {
58
- try {
59
- return this.actions
60
- .move({ x: xPos, y: yPos, origin: webdriver.Origin.VIEWPORT })
61
- .press()
62
- .perform();
63
- } catch (e) {
64
- log.error('Could not click and hold at position (%d,%d)', xPos, yPos);
65
- log.verbose(e);
66
- throw Error(
67
- 'Could not click and hold at position (' + xPos + ',' + yPos + ')'
68
- );
69
- }
70
- }
71
-
72
- /**
73
- * Release mouse on element that matches the specified Xpath.
74
- * @param {string} xpath
75
- * @returns {Promise} Promise object represents when mouse is released.
76
- * @throws Will throw an error if action cannot be performed.
77
- */
78
- async releaseAtXpath(xpath) {
79
- try {
80
- const element = await this.driver.findElement(webdriver.By.xpath(xpath));
81
- return this.actions
82
- .move({ origin: element })
83
- .release()
84
- .perform();
85
- } catch (e) {
86
- log.error('Could not release on xpath %s', xpath);
87
- log.verbose(e);
88
- throw Error('Could not release on xpath ' + xpath);
89
- }
90
- }
91
-
92
- /**
93
- * Release mouse at specified coordinates.
94
- * @param {string} xpath
95
- * @returns {Promise} Promise object represents when mouse is released.
96
- * @throws Will throw an error if action cannot be performed.
97
- */
98
- async releaseAtPosition(xPos, yPos) {
99
- try {
100
- return this.actions
101
- .move({ x: xPos, y: yPos, origin: webdriver.Origin.VIEWPORT })
102
- .release()
103
- .perform();
104
- } catch (e) {
105
- log.error('Could not release at position (%d,%d)', xPos, yPos);
106
- log.verbose(e);
107
- throw Error('Could not release at position (' + xPos + ',' + yPos + ')');
108
- }
109
- }
110
- }
111
-
112
- class SingleClick {
113
- constructor(browser, pageCompleteCheck) {
114
- this.browser = browser;
115
- this.actions = this.browser.getDriver().actions({ async: true });
116
- this.pageCompleteCheck = pageCompleteCheck;
117
- }
118
-
119
- /**
120
- * Perform mouse single click on an element matches a XPath selector.
121
- * @param {string} xpath
122
- * @returns {Promise} Promise object represents when the element has been clicked.
123
- * @throws Will throw an error if the element is not found.
124
- */
125
- async byXpath(xpath, options) {
126
- try {
127
- const element = await this.browser
128
- .getDriver()
129
- .findElement(webdriver.By.xpath(xpath));
130
- await this.actions.click(element).perform();
131
- if (options && 'wait' in options && options.wait === true) {
132
- return this.browser.extraWait(this.pageCompleteCheck);
133
- }
134
- } catch (e) {
135
- log.error('Could not single click on element with xpath %s', xpath);
136
- log.verbose(e);
137
- throw Error('Could not single click on element with xpath ' + xpath);
138
- }
139
- }
140
-
141
- /**
142
- * Perform mouse single click at the cursor's position.
143
- * @param {string} xpath
144
- * @returns {Promise} Promise object represents when double click occurs.
145
- * @throws Will throw an error if double click cannot be performed.
146
- */
147
- async atCursor(options) {
148
- try {
149
- await this.actions.click().perform();
150
- if (options && 'wait' in options && options.wait === true) {
151
- return this.browser.extraWait(this.pageCompleteCheck);
152
- }
153
- } catch (e) {
154
- log.error('Could not perform single click');
155
- log.verbose(e);
156
- throw Error('Could not perform single click');
157
- }
158
- }
159
- }
160
-
161
- class DoubleClick {
162
- constructor(browser, pageCompleteCheck) {
163
- this.browser = browser;
164
- this.actions = this.browser.getDriver().actions({ async: true });
165
- this.pageCompleteCheck = pageCompleteCheck;
166
- }
167
-
168
- /**
169
- * Perform mouse double click on an element matches a XPath selector.
170
- * @param {string} xpath
171
- * @returns {Promise} Promise object represents when the element has been double clicked.
172
- * @throws Will throw an error if the element is not found.
173
- */
174
- async byXpath(xpath, options) {
175
- try {
176
- const element = await this.browser
177
- .getDriver()
178
- .findElement(webdriver.By.xpath(xpath));
179
- await this.actions.doubleClick(element).perform();
180
- if (options && 'wait' in options && options.wait === true) {
181
- return this.browser.extraWait(this.pageCompleteCheck);
182
- }
183
- } catch (e) {
184
- log.error('Could not double click on element with xpath %s', xpath);
185
- log.verbose(e);
186
- throw Error('Could not double click on element with xpath ' + xpath);
187
- }
188
- }
189
-
190
- /**
191
- * Perform mouse double click at the cursor's position.
192
- * @param {string} xpath
193
- * @returns {Promise} Promise object represents when double click occurs.
194
- * @throws Will throw an error if double click cannot be performed.
195
- */
196
- async atCursor(options) {
197
- try {
198
- await this.actions.doubleClick().perform();
199
- if (options && 'wait' in options && options.wait === true) {
200
- return this.browser.extraWait(this.pageCompleteCheck);
201
- }
202
- } catch (e) {
203
- log.error('Could not perform double click');
204
- log.verbose(e);
205
- throw Error('Could not perform double click');
206
- }
207
- }
208
- }
209
-
210
- class ContextClick {
211
- constructor(browser) {
212
- this.driver = browser.getDriver();
213
- this.actions = this.driver.actions({ async: true });
214
- }
215
-
216
- /**
217
- * Perform ContextClick on an element that matches a XPath selector.
218
- * @param {string} xpath
219
- * @returns {Promise} Promise object represents when context click occurs.
220
- * @throws Will throw an error if the element is not found
221
- */
222
- async byXpath(xpath) {
223
- try {
224
- const element = await this.driver.findElement(webdriver.By.xpath(xpath));
225
- return this.actions.contextClick(element).perform();
226
- } catch (e) {
227
- log.error('Could not context click on element with xpath %s', xpath);
228
- log.verbose(e);
229
- throw Error('Could not context click on element with xpath ' + xpath);
230
- }
231
- }
232
-
233
- /**
234
- * Perform ContextClick at the cursor's position.
235
- * @param {string} xpath
236
- * @returns {Promise} Promise object represents when context click occurs.
237
- * @throws Will throw an error if context click cannot be performed.
238
- */
239
- async atCursor() {
240
- try {
241
- return this.actions.contextClick().perform();
242
- } catch (e) {
243
- log.error('Could not perform context click');
244
- log.verbose(e);
245
- throw Error('Could not perform context click');
246
- }
247
- }
248
- }
249
-
250
- class MouseMove {
251
- constructor(browser) {
252
- this.driver = browser.getDriver();
253
- this.actions = this.driver.actions({ async: true });
254
- }
255
-
256
- /**
257
- * Move mouse to an element that matches a XPath selector.
258
- * @param {string} xpath
259
- * @returns {Promise} Promise object represents when the mouse has moved
260
- * @throws Will throw an error if the element is not found
261
- */
262
- async byXpath(xpath) {
263
- try {
264
- const element = await this.driver.findElement(webdriver.By.xpath(xpath));
265
- return this.actions.move({ origin: element }).perform();
266
- } catch (e) {
267
- log.error('Could not find element by xpath %s', xpath);
268
- log.verbose(e);
269
- throw Error('Could not find element by xpath ' + xpath);
270
- }
271
- }
272
-
273
- /**
274
- * Move mouse to a position
275
- * @param {number} xPos, {number} yPos
276
- * @returns {Promise} Promise object represents when the mouse has moved
277
- * @throws Will throw an error if the element is not found
278
- */
279
- async toPosition(xPos, yPos) {
280
- try {
281
- return this.actions.move({ x: xPos, y: yPos }).perform();
282
- } catch (e) {
283
- log.error('Could not move mouse to position.');
284
- log.verbose(e);
285
- throw Error('Could not move mouse to position.');
286
- }
287
- }
288
-
289
- /**
290
- * Move mouse by an offset
291
- * @param {number} xOffset, {number} yOffset
292
- * @returns {Promise} Promise object represents when the mouse has moved
293
- * @throws Will throw an error if the element is not found
294
- */
295
- async byOffset(xOffset, yOffset) {
296
- try {
297
- return this.actions
298
- .move({ x: xOffset, y: yOffset, origin: webdriver.Origin.POINTER })
299
- .perform();
300
- } catch (e) {
301
- log.error('Could not move mouse by offset');
302
- log.verbose(e);
303
- throw Error('Could not move mouse by offset');
304
- }
305
- }
306
- }
307
-
308
- module.exports = {
309
- SingleClick,
310
- DoubleClick,
311
- ClickAndHold,
312
- ContextClick,
313
- MouseMove
314
- };