browsertime 16.16.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 +52 -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 +25 -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 +93 -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 +123 -85
  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,23 +1,22 @@
1
- 'use strict';
1
+ import { execa } from 'execa';
2
+ import intel from 'intel';
3
+ const log = intel.getLogger('browsertime.video');
2
4
 
3
- const execa = require('execa');
4
- const log = require('intel').getLogger('browsertime.video');
5
-
6
- module.exports = async function convert(src, dest) {
7
- const scriptArgs = [
5
+ export default async function convert(source, destination) {
6
+ const scriptArguments = [
8
7
  // '-framerate',
9
8
  // 60,
10
9
  '-i',
11
- src,
10
+ source,
12
11
  '-c:v',
13
12
  'copy',
14
13
  '-f',
15
14
  'mp4',
16
- dest,
15
+ destination,
17
16
  '-y'
18
17
  ];
19
18
 
20
- log.debug('Converting video from h264 to mp4 %j', scriptArgs);
19
+ log.debug('Converting video from h264 to mp4 %j', scriptArguments);
21
20
 
22
- return execa('ffmpeg', scriptArgs);
23
- };
21
+ return execa('ffmpeg', scriptArguments);
22
+ }
@@ -1,13 +1,14 @@
1
- const log = require('intel').getLogger('browsertime.video');
2
- const path = require('path');
3
- const execa = require('execa');
4
- const util = require('util');
5
- const fs = require('fs');
1
+ import path from 'node:path';
2
+ import util from 'node:util';
3
+ import fs from 'node:fs';
4
+ import { execa } from 'execa';
5
+ import intel from 'intel';
6
+ import { default as convert } from './convertToMp4.js';
6
7
  const unlink = util.promisify(fs.unlink);
7
- const convert = require('./convertToMp4');
8
8
  const delay = ms => new Promise(res => setTimeout(res, ms));
9
+ const log = intel.getLogger('browsertime.video');
9
10
 
10
- module.exports = class IOSSimulatorRecorder {
11
+ export default class IOSSimulatorRecorder {
11
12
  constructor(options, baseDir) {
12
13
  this.options = options;
13
14
  this.tmpVideo = path.join(baseDir, 'tmp.mov');
@@ -35,6 +36,6 @@ module.exports = class IOSSimulatorRecorder {
35
36
  await delay(2500);
36
37
  await convert(this.tmpVideo, destination);
37
38
  await unlink(this.tmpVideo);
38
- return Promise.resolve(this.xcrunProcess);
39
+ return this.xcrunProcess;
39
40
  }
40
- };
41
+ }
@@ -1,12 +1,11 @@
1
- 'use strict';
2
- const { isAndroidConfigured } = require('../../android');
3
- const AndroidRecorder = require('./android/recorder');
4
- const DesktopRecorder = require('./desktop/desktopRecorder');
5
- const FirefoxWindowRecorder = require('./firefox/firefoxWindowRecorder');
6
- const IOSSimulatorRecorder = require('./iosSimulator/recorder');
7
- const IOSRecorder = require('./ios/iosRecorder');
1
+ import { isAndroidConfigured } from '../../android/index.js';
2
+ import AndroidRecorder from './android/recorder.js';
3
+ import DesktopRecorder from './desktop/desktopRecorder.js';
4
+ import FirefoxWindowRecorder from './firefox/firefoxWindowRecorder.js';
5
+ import IOSSimulatorRecorder from './iosSimulator/recorder.js';
6
+ import IOSRecorder from './ios/iosRecorder.js';
8
7
 
9
- module.exports = function getRecorder(options, browser, baseDir) {
8
+ export default function getRecorder(options, browser, baseDir) {
10
9
  if (
11
10
  options.browser === 'firefox' &&
12
11
  options.firefox &&
@@ -32,4 +31,4 @@ module.exports = function getRecorder(options, browser, baseDir) {
32
31
  }
33
32
 
34
33
  return new DesktopRecorder(options);
35
- };
34
+ }
@@ -1,8 +1,7 @@
1
- 'use strict';
2
-
3
- const log = require('intel').getLogger('browsertime.video');
4
- const { until, By } = require('selenium-webdriver');
5
- module.exports = async function (driver) {
1
+ import intel from 'intel';
2
+ import { until, By } from 'selenium-webdriver';
3
+ const log = intel.getLogger('browsertime.video');
4
+ export default async function (driver) {
6
5
  log.debug('Add orange color');
7
6
  // We tried other ways for Android (access an orange page)
8
7
  // That works fine ... but break scripts
@@ -27,4 +26,4 @@ module.exports = async function (driver) {
27
26
  // It seems that in some cases the video do not have any orange at the start, so make sure we
28
27
  // the div orange div really exits
29
28
  return driver.wait(until.elementsLocated(By.id('browsertime-orange')));
30
- };
29
+ }
@@ -1,11 +1,10 @@
1
- 'use strict';
2
- const path = require('path');
3
- const get = require('lodash.get');
4
- const getRecorder = require('./screenRecording/recorder');
5
- const getVideoMetrics = require('./postprocessing/visualmetrics/getVideoMetrics');
6
- const finetuneVideo = require('./postprocessing/finetune/');
7
- const fileUtil = require('../support/fileUtil');
8
- const pathToFolders = require('../support/pathToFolder');
1
+ import { join } from 'node:path';
2
+ import get from 'lodash.get';
3
+ import getRecorder from './screenRecording/recorder.js';
4
+ import getVideoMetrics from './postprocessing/visualmetrics/getVideoMetrics.js';
5
+ import finetuneVideo from './postprocessing/finetune/index.js';
6
+ import { rename, removeFile, removeDirAndFiles } from '../support/fileUtil.js';
7
+ import pathToFolders from '../support/pathToFolder.js';
9
8
 
10
9
  /**
11
10
  * Create a new Video that handles everything with the video
@@ -25,15 +24,15 @@ class Video {
25
24
  this.index = index;
26
25
 
27
26
  this.videoDir = await storageManager.createSubDataDir(
28
- path.join(pathToFolders(url, this.options), 'video')
27
+ join(pathToFolders(url, this.options), 'video')
29
28
  );
30
29
 
31
30
  await storageManager.createSubDataDir(
32
- path.join(pathToFolders(url, this.options), 'video', 'images', '' + index)
31
+ join(pathToFolders(url, this.options), 'video', 'images', '' + index)
33
32
  );
34
33
 
35
34
  this.filmstripDir = await storageManager.createSubDataDir(
36
- path.join(pathToFolders(url, this.options), 'filmstrip', '' + index)
35
+ join(pathToFolders(url, this.options), 'filmstrip', '' + index)
37
36
  );
38
37
  }
39
38
 
@@ -48,8 +47,8 @@ class Video {
48
47
  // skip recording if we already have one going
49
48
  if (!this.isRecording) {
50
49
  this.isRecording = true;
51
- let tmp = path.join(this.tmpDir, 'x11-tmp.mp4');
52
- return this.recorder.start(tmp);
50
+ let temporary = join(this.tmpDir, 'x11-tmp.mp4');
51
+ return this.recorder.start(temporary);
53
52
  }
54
53
  }
55
54
 
@@ -59,7 +58,7 @@ class Video {
59
58
  */
60
59
  async stop(url) {
61
60
  this.isRecording = false;
62
- this.videoPath = path.join(
61
+ this.videoPath = join(
63
62
  this.storageManager.directory,
64
63
  pathToFolders(url, this.options),
65
64
  'video',
@@ -72,16 +71,13 @@ class Video {
72
71
  async cleanup() {
73
72
  // Keep or remove the original file
74
73
  if (get(this.options, 'videoParams.keepOriginalVideo', false)) {
75
- const originalFile = path.join(
76
- this.videoDir,
77
- this.index + '-original.mp4'
78
- );
79
- await fileUtil.rename(this.videoPath, originalFile);
74
+ const originalFile = join(this.videoDir, this.index + '-original.mp4');
75
+ await rename(this.videoPath, originalFile);
80
76
  } else {
81
- await fileUtil.removeFile(this.videoPath);
77
+ await removeFile(this.videoPath);
82
78
  }
83
79
  // Remove all tmp videos (and screenshots)
84
- return fileUtil.removeDirAndFiles(path.join(this.videoDir, 'tmp'));
80
+ return removeDirAndFiles(join(this.videoDir, 'tmp'));
85
81
  }
86
82
 
87
83
  /**
@@ -103,18 +99,16 @@ class Video {
103
99
  this.options
104
100
  );
105
101
  }
106
- if (this.options.video === true) {
107
- await finetuneVideo(
108
- this.videoDir,
109
- this.videoPath,
110
- this.index,
111
- videoMetrics,
112
- timingMetrics,
113
- this.options
114
- );
115
- } else {
116
- await fileUtil.removeFile(this.videoPath);
117
- }
102
+ await (this.options.video === true
103
+ ? finetuneVideo(
104
+ this.videoDir,
105
+ this.videoPath,
106
+ this.index,
107
+ videoMetrics,
108
+ timingMetrics,
109
+ this.options
110
+ )
111
+ : removeFile(this.videoPath));
118
112
  return videoMetrics;
119
113
  }
120
114
 
@@ -127,4 +121,4 @@ class Video {
127
121
  }
128
122
  }
129
123
 
130
- module.exports = Video;
124
+ export default Video;
package/package.json CHANGED
@@ -1,23 +1,24 @@
1
1
  {
2
2
  "description": "Browsertime",
3
- "version": "16.16.0",
3
+ "version": "17.0.0-beta.0",
4
4
  "bin": "./bin/browsertime.js",
5
+ "type": "module",
5
6
  "dependencies": {
6
7
  "@cypress/xvfb": "1.2.4",
7
8
  "@devicefarmer/adbkit": "2.11.3",
8
- "@sitespeed.io/chromedriver": "105.0.5195-19",
9
- "@sitespeed.io/edgedriver": "104.0.1293-47",
9
+ "@sitespeed.io/chromedriver": "106.0.5249-61",
10
+ "@sitespeed.io/edgedriver": "106.0.1370-34",
10
11
  "@sitespeed.io/geckodriver": "0.31.0-c",
11
12
  "@sitespeed.io/throttle": "5.0.0",
12
13
  "@sitespeed.io/tracium": "0.3.3",
13
14
  "btoa": "1.2.1",
14
15
  "chrome-har": "0.13.0",
15
16
  "chrome-remote-interface": "0.31.3",
16
- "dayjs": "1.11.1",
17
- "execa": "5.1.1",
17
+ "dayjs": "1.11.6",
18
+ "execa": "6.1.0",
18
19
  "fast-stats": "0.0.6",
19
- "find-up": "5.0.0",
20
- "get-port": "5.1.1",
20
+ "find-up": "6.3.0",
21
+ "get-port": "6.1.2",
21
22
  "hasbin": "1.2.3",
22
23
  "intel": "1.2.0",
23
24
  "lodash.get": "4.4.2",
@@ -26,20 +27,21 @@
26
27
  "lodash.merge": "4.6.2",
27
28
  "lodash.pick": "4.4.0",
28
29
  "lodash.set": "4.3.2",
29
- "selenium-webdriver": "4.4.0",
30
- "yargs": "17.4.1"
30
+ "selenium-webdriver": "4.5.0",
31
+ "yargs": "17.6.0"
31
32
  },
32
33
  "optionalDependencies": {
33
- "jimp": "0.16.1"
34
+ "jimp": "0.16.2"
34
35
  },
35
36
  "devDependencies": {
36
- "ava": "4.3.3",
37
- "eslint": "8.14.0",
37
+ "ava": "5.0.1",
38
+ "eslint": "8.26.0",
38
39
  "eslint-config-prettier": "8.5.0",
39
- "eslint-plugin-prettier": "4.0.0",
40
- "prettier": "2.6.2",
40
+ "eslint-plugin-prettier": "4.2.1",
41
+ "eslint-plugin-unicorn": "44.0.2",
42
+ "prettier": "2.7.1",
41
43
  "serve-handler": "6.1.3",
42
- "serve": "13.0.2"
44
+ "serve": "14.0.1"
43
45
  },
44
46
  "engines": {
45
47
  "node": ">=14.19.1"
@@ -60,7 +62,7 @@
60
62
  "package.json",
61
63
  "vendor"
62
64
  ],
63
- "main": "index.js",
65
+ "exports": "./index.js",
64
66
  "scripts": {
65
67
  "test": "ava",
66
68
  "start-server": "serve test/data/html/",
@@ -91,7 +93,7 @@
91
93
  "!test/data"
92
94
  ],
93
95
  "concurrency": 1,
94
- "failFast": true,
96
+ "failFast": false,
95
97
  "require": [
96
98
  "./test/util/setup.js"
97
99
  ],