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.
- package/CHANGELOG.md +52 -0
- package/bin/browsertime.js +43 -43
- package/bin/browsertimeWebPageReplay.js +10 -9
- package/browserscripts/pageinfo/generator.js +1 -1
- package/index.js +14 -13
- package/lib/android/gnirehtet.js +14 -15
- package/lib/android/index.js +92 -89
- package/lib/android/root.js +6 -9
- package/lib/chrome/chromeDevtoolsProtocol.js +46 -45
- package/lib/chrome/har.js +12 -13
- package/lib/chrome/longTaskMetrics.js +3 -5
- package/lib/chrome/parseCpuTrace.js +13 -10
- package/lib/chrome/settings/chromeAndroidOptions.js +1 -3
- package/lib/chrome/settings/chromeDesktopOptions.js +1 -3
- package/lib/chrome/settings/traceCategories.js +1 -3
- package/lib/chrome/traceCategoriesParser.js +35 -36
- package/lib/chrome/webdriver/builder.js +18 -26
- package/lib/chrome/webdriver/chromium.js +56 -46
- package/lib/chrome/webdriver/setupChromiumOptions.js +32 -27
- package/lib/connectivity/humble.js +13 -14
- package/lib/connectivity/index.js +74 -77
- package/lib/connectivity/trafficShapeParser.js +31 -35
- package/lib/core/engine/collector.js +25 -22
- package/lib/core/engine/command/addText.js +24 -27
- package/lib/core/engine/command/android.js +7 -11
- package/lib/core/engine/command/cache.js +3 -4
- package/lib/core/engine/command/chromeDevToolsProtocol.js +20 -20
- package/lib/core/engine/command/click.js +48 -49
- package/lib/core/engine/command/debug.js +3 -4
- package/lib/core/engine/command/javaScript.js +18 -19
- package/lib/core/engine/command/measure.js +31 -37
- package/lib/core/engine/command/meta.js +1 -4
- package/lib/core/engine/command/mouse/clickAndHold.js +36 -39
- package/lib/core/engine/command/mouse/contextClick.js +17 -18
- package/lib/core/engine/command/mouse/doubleClick.js +17 -19
- package/lib/core/engine/command/mouse/index.js +5 -9
- package/lib/core/engine/command/mouse/mouseMove.js +19 -23
- package/lib/core/engine/command/mouse/singleClick.js +15 -19
- package/lib/core/engine/command/navigation.js +12 -14
- package/lib/core/engine/command/screenshot.js +1 -4
- package/lib/core/engine/command/scroll.js +4 -7
- package/lib/core/engine/command/select.js +26 -26
- package/lib/core/engine/command/set.js +25 -23
- package/lib/core/engine/command/stopWatch.js +5 -8
- package/lib/core/engine/command/switch.js +18 -20
- package/lib/core/engine/command/util/lcpHighlightScript.js +1 -2
- package/lib/core/engine/command/util/lsHighlightScript.js +1 -2
- package/lib/core/engine/command/wait.js +18 -18
- package/lib/core/engine/index.js +81 -71
- package/lib/core/engine/iteration.js +93 -79
- package/lib/core/engine/run.js +5 -9
- package/lib/core/pageCompleteChecks/defaultPageCompleteCheck.js +1 -2
- package/lib/core/pageCompleteChecks/pageCompleteCheckByInactivity.js +1 -3
- package/lib/core/pageCompleteChecks/spaInactivity.js +1 -3
- package/lib/core/seleniumRunner.js +92 -100
- package/lib/core/webdriver/index.js +24 -21
- package/lib/edge/webdriver/builder.js +21 -26
- package/lib/extensionserver/httpServer.js +17 -21
- package/lib/extensionserver/index.js +8 -12
- package/lib/extensionserver/setup.js +12 -12
- package/lib/firefox/geckoProfiler.js +27 -21
- package/lib/firefox/getHAR.js +7 -8
- package/lib/firefox/memoryReport.js +9 -11
- package/lib/firefox/perfStats.js +5 -7
- package/lib/firefox/settings/disableSafeBrowsingPreferences.js +1 -3
- package/lib/firefox/settings/disableTrackingProtectionPreferences.js +1 -3
- package/lib/firefox/settings/firefoxPreferences.js +2 -4
- package/lib/firefox/settings/geckoProfilerDefaults.js +5 -9
- package/lib/firefox/webdriver/builder.js +66 -63
- package/lib/firefox/webdriver/firefox.js +43 -48
- package/lib/safari/webdriver/builder.js +4 -5
- package/lib/safari/webdriver/safari.js +4 -8
- package/lib/screenshot/defaults.js +1 -3
- package/lib/screenshot/index.js +24 -21
- package/lib/support/browserScript.js +65 -56
- package/lib/support/cli.js +123 -85
- package/lib/support/dns.js +6 -7
- package/lib/support/engineUtils.js +85 -38
- package/lib/support/errors.js +4 -13
- package/lib/support/fileUtil.js +81 -68
- package/lib/support/filters.js +15 -20
- package/lib/support/getViewPort.js +6 -7
- package/lib/support/har/index.js +208 -216
- package/lib/support/images/index.js +54 -26
- package/lib/support/logging.js +20 -17
- package/lib/support/pathToFolder.js +18 -23
- package/lib/support/preURL.js +5 -6
- package/lib/support/processes.js +4 -6
- package/lib/support/setResourceTimingBufferSize.js +2 -4
- package/lib/support/statistics.js +58 -56
- package/lib/support/stop.js +7 -8
- package/lib/support/storageManager.js +44 -44
- package/lib/support/tcpdump.js +22 -16
- package/lib/support/userTiming.js +7 -13
- package/lib/support/util.js +204 -224
- package/lib/support/xvfb.js +11 -13
- package/lib/video/defaults.js +6 -10
- package/lib/video/postprocessing/finetune/addTextToVideo.js +15 -15
- package/lib/video/postprocessing/finetune/convertFps.js +14 -8
- package/lib/video/postprocessing/finetune/getFont.js +7 -9
- package/lib/video/postprocessing/finetune/getTimingMetrics.js +19 -18
- package/lib/video/postprocessing/finetune/index.js +40 -36
- package/lib/video/postprocessing/finetune/removeOrange.js +10 -11
- package/lib/video/postprocessing/visualmetrics/extraMetrics.js +17 -13
- package/lib/video/postprocessing/visualmetrics/getVideoMetrics.js +12 -13
- package/lib/video/postprocessing/visualmetrics/visualMetrics.js +117 -128
- package/lib/video/screenRecording/android/recorder.js +12 -17
- package/lib/video/screenRecording/desktop/convert.js +13 -11
- package/lib/video/screenRecording/desktop/desktopRecorder.js +29 -24
- package/lib/video/screenRecording/desktop/ffmpegRecorder.js +60 -63
- package/lib/video/screenRecording/desktop/osx/getSPDisplaysDataType.js +4 -6
- package/lib/video/screenRecording/desktop/osx/getScreen.js +9 -10
- package/lib/video/screenRecording/firefox/firefoxWindowRecorder.js +54 -54
- package/lib/video/screenRecording/ios/convertToMp4.js +10 -11
- package/lib/video/screenRecording/ios/iosRecorder.js +23 -21
- package/lib/video/screenRecording/iosSimulator/convertToMp4.js +10 -11
- package/lib/video/screenRecording/iosSimulator/recorder.js +10 -9
- package/lib/video/screenRecording/recorder.js +8 -9
- package/lib/video/screenRecording/setOrangeBackground.js +5 -6
- package/lib/video/video.js +28 -34
- package/package.json +19 -17
|
@@ -1,46 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import { platform } from 'node:os';
|
|
2
|
+
import webdriver from 'selenium-webdriver';
|
|
3
|
+
import intel from 'intel';
|
|
4
|
+
|
|
5
|
+
import SeleniumRunner from '../seleniumRunner.js';
|
|
6
|
+
import preURL from '../../support/preURL.js';
|
|
7
|
+
import setResourceTimingBufferSize from '../../support/setResourceTimingBufferSize.js';
|
|
8
|
+
import ScreenshotManager from '../../screenshot/index.js';
|
|
9
|
+
import ExtensionServer from '../../extensionserver/index.js';
|
|
10
|
+
import {
|
|
11
|
+
loadPrePostScriptsSync,
|
|
12
|
+
loadScriptSync
|
|
13
|
+
} from '../../support/engineUtils.js';
|
|
14
|
+
import Video from '../../video/video.js';
|
|
15
|
+
import stop from '../../support/stop.js';
|
|
16
|
+
import AddText from './command/addText.js';
|
|
17
|
+
import Click from './command/click.js';
|
|
18
|
+
import Wait from './command/wait.js';
|
|
19
|
+
import Measure from './command/measure.js';
|
|
20
|
+
import JavaScript from './command/javaScript.js';
|
|
21
|
+
import Switch from './command/switch.js';
|
|
22
|
+
import Screenshot from './command/screenshot.js';
|
|
23
|
+
import Set from './command/set.js';
|
|
24
|
+
import Cache from './command/cache.js';
|
|
25
|
+
import Meta from './command/meta.js';
|
|
26
|
+
import StopWatch from './command/stopWatch.js';
|
|
27
|
+
import Select from './command/select.js';
|
|
28
|
+
import Debug from './command/debug.js';
|
|
29
|
+
import AndroidCommand from './command/android.js';
|
|
30
|
+
import ChromeDevelopmentToolsProtocol from './command/chromeDevToolsProtocol.js';
|
|
31
|
+
import {
|
|
32
|
+
addConnectivity,
|
|
33
|
+
removeConnectivity
|
|
34
|
+
} from '../../connectivity/index.js';
|
|
35
|
+
import { jsonifyVisualProgress } from '../../support/util.js';
|
|
36
|
+
import flushDNS from '../../support/dns.js';
|
|
37
|
+
import {
|
|
32
38
|
SingleClick,
|
|
33
39
|
DoubleClick,
|
|
34
40
|
ClickAndHold,
|
|
35
41
|
ContextClick,
|
|
36
42
|
MouseMove
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
43
|
+
} from './command/mouse/index.js';
|
|
44
|
+
import getNumberOfRunningProcesses from '../../support/processes.js';
|
|
45
|
+
import { isAndroidConfigured, Android } from '../../android/index.js';
|
|
46
|
+
import Scroll from './command/scroll.js';
|
|
47
|
+
import Navigation from './command/navigation.js';
|
|
48
|
+
const log = intel.getLogger('browsertime');
|
|
44
49
|
const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
45
50
|
|
|
46
51
|
// Make this configurable
|
|
@@ -50,7 +55,7 @@ const ANDROID_DELAY_TIME = 2000;
|
|
|
50
55
|
* Browsertime will do through one iteration of testing a URL.
|
|
51
56
|
* @class
|
|
52
57
|
*/
|
|
53
|
-
class Iteration {
|
|
58
|
+
export default class Iteration {
|
|
54
59
|
constructor(
|
|
55
60
|
storageManager,
|
|
56
61
|
engineDelegate,
|
|
@@ -59,17 +64,15 @@ class Iteration {
|
|
|
59
64
|
options
|
|
60
65
|
) {
|
|
61
66
|
try {
|
|
62
|
-
this.preScripts =
|
|
63
|
-
this.postScripts =
|
|
64
|
-
this.postURLScripts =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
log.error(e.message);
|
|
72
|
-
throw e;
|
|
67
|
+
this.preScripts = loadPrePostScriptsSync(options.preScript);
|
|
68
|
+
this.postScripts = loadPrePostScriptsSync(options.postScript);
|
|
69
|
+
this.postURLScripts = loadPrePostScriptsSync(options.postURLScript);
|
|
70
|
+
this.pageCompleteCheck = options.pageCompleteCheck
|
|
71
|
+
? loadScriptSync(options.pageCompleteCheck)
|
|
72
|
+
: undefined;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
log.error(error.message);
|
|
75
|
+
throw error;
|
|
73
76
|
}
|
|
74
77
|
this.options = options;
|
|
75
78
|
this.storageManager = storageManager;
|
|
@@ -85,8 +88,8 @@ class Iteration {
|
|
|
85
88
|
* @param {*} index - Which iteration it is
|
|
86
89
|
*/
|
|
87
90
|
async run(navigationScript, index) {
|
|
88
|
-
if (
|
|
89
|
-
this.processesAtStart =
|
|
91
|
+
if (platform() === 'darwin' || platform() === 'linux') {
|
|
92
|
+
this.processesAtStart = Number(await getNumberOfRunningProcesses());
|
|
90
93
|
}
|
|
91
94
|
const screenshotManager = new ScreenshotManager(
|
|
92
95
|
this.storageManager,
|
|
@@ -151,7 +154,10 @@ class Iteration {
|
|
|
151
154
|
options
|
|
152
155
|
);
|
|
153
156
|
|
|
154
|
-
const cdp = new
|
|
157
|
+
const cdp = new ChromeDevelopmentToolsProtocol(
|
|
158
|
+
engineDelegate,
|
|
159
|
+
options.browser
|
|
160
|
+
);
|
|
155
161
|
const android = new Android(options);
|
|
156
162
|
const debug = new Debug(browser, options);
|
|
157
163
|
const commands = {
|
|
@@ -225,10 +231,10 @@ class Iteration {
|
|
|
225
231
|
|
|
226
232
|
try {
|
|
227
233
|
await navigationScript(context, commands, this.postURLScripts);
|
|
228
|
-
} catch (
|
|
229
|
-
commands.error(
|
|
230
|
-
commands.markAsFailure(
|
|
231
|
-
throw
|
|
234
|
+
} catch (error) {
|
|
235
|
+
commands.error(error.message);
|
|
236
|
+
commands.markAsFailure(error.message);
|
|
237
|
+
throw error;
|
|
232
238
|
}
|
|
233
239
|
if (commands.measure.areWeMeasuring === true) {
|
|
234
240
|
// someone forgot to call stop();
|
|
@@ -259,7 +265,17 @@ class Iteration {
|
|
|
259
265
|
if (options.browser === 'firefox' && options.debug) {
|
|
260
266
|
log.info('Firefox is kept open in debug mode');
|
|
261
267
|
} else {
|
|
262
|
-
|
|
268
|
+
if (isAndroidConfigured(options) && options.ignoreShutdownFailures) {
|
|
269
|
+
try {
|
|
270
|
+
log.info('Ignoring shutdown failures on android...');
|
|
271
|
+
await browser.stop();
|
|
272
|
+
} catch {
|
|
273
|
+
// Ignore shutdown failures on android
|
|
274
|
+
log.info('Shutdown problem hit, ignoring...');
|
|
275
|
+
}
|
|
276
|
+
} else {
|
|
277
|
+
await browser.stop();
|
|
278
|
+
}
|
|
263
279
|
}
|
|
264
280
|
// Give the browsers some time to stop
|
|
265
281
|
await delay(2000);
|
|
@@ -271,12 +287,12 @@ class Iteration {
|
|
|
271
287
|
}
|
|
272
288
|
|
|
273
289
|
if (options.visualMetrics && !options.videoParams.debug) {
|
|
274
|
-
let
|
|
290
|
+
let index_ = 0;
|
|
275
291
|
for (let myVideo of videos) {
|
|
276
292
|
try {
|
|
277
293
|
const videoMetrics = await myVideo.postProcessing(
|
|
278
|
-
result[
|
|
279
|
-
result[
|
|
294
|
+
result[index_].browserScripts.timings.pageTimings,
|
|
295
|
+
result[index_].browserScripts.pageinfo.visualElements
|
|
280
296
|
);
|
|
281
297
|
|
|
282
298
|
for (let progress of [
|
|
@@ -285,20 +301,20 @@ class Iteration {
|
|
|
285
301
|
'PerceptualSpeedIndexProgress'
|
|
286
302
|
]) {
|
|
287
303
|
if (videoMetrics.visualMetrics[progress]) {
|
|
288
|
-
videoMetrics.visualMetrics[progress] =
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
);
|
|
304
|
+
videoMetrics.visualMetrics[progress] = jsonifyVisualProgress(
|
|
305
|
+
videoMetrics.visualMetrics[progress]
|
|
306
|
+
);
|
|
292
307
|
}
|
|
293
308
|
}
|
|
294
|
-
result[
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
309
|
+
result[index_].videoRecordingStart =
|
|
310
|
+
videoMetrics.videoRecordingStart;
|
|
311
|
+
result[index_].visualMetrics = videoMetrics.visualMetrics;
|
|
312
|
+
index_++;
|
|
313
|
+
} catch (error) {
|
|
298
314
|
// If one of the Visual Metrics runs fail, try the next one
|
|
299
|
-
log.error('Visual Metrics failed to analyse the video',
|
|
300
|
-
if (result[
|
|
301
|
-
result[
|
|
315
|
+
log.error('Visual Metrics failed to analyse the video', error);
|
|
316
|
+
if (result[index_]) {
|
|
317
|
+
result[index_].error.push(error.message);
|
|
302
318
|
}
|
|
303
319
|
}
|
|
304
320
|
}
|
|
@@ -323,8 +339,8 @@ class Iteration {
|
|
|
323
339
|
|
|
324
340
|
result.processesAtStart = this.processesAtStart;
|
|
325
341
|
return result;
|
|
326
|
-
} catch (
|
|
327
|
-
log.error(
|
|
342
|
+
} catch (error) {
|
|
343
|
+
log.error(error);
|
|
328
344
|
if (recordVideo && options.videoParams.debug) {
|
|
329
345
|
// Just use the first URL
|
|
330
346
|
const url =
|
|
@@ -336,9 +352,9 @@ class Iteration {
|
|
|
336
352
|
if (options.docker && recordVideo && !isAndroidConfigured(options)) {
|
|
337
353
|
await stop('ffmpeg');
|
|
338
354
|
}
|
|
339
|
-
result.error = [
|
|
355
|
+
result.error = [error.name];
|
|
340
356
|
result.markedAsFailure = 1;
|
|
341
|
-
result.failureMessages = [
|
|
357
|
+
result.failureMessages = [error.message];
|
|
342
358
|
return result;
|
|
343
359
|
} finally {
|
|
344
360
|
// Here we should also make sure FFMPEG is really killed/stopped
|
|
@@ -352,11 +368,9 @@ class Iteration {
|
|
|
352
368
|
} else {
|
|
353
369
|
await browser.stop();
|
|
354
370
|
}
|
|
355
|
-
} catch
|
|
371
|
+
} catch {
|
|
356
372
|
// Most cases the browser been stopped already
|
|
357
373
|
}
|
|
358
374
|
}
|
|
359
375
|
}
|
|
360
376
|
}
|
|
361
|
-
|
|
362
|
-
module.exports = Iteration;
|
package/lib/core/engine/run.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
module.exports = function (urlOrFunctions) {
|
|
1
|
+
export default function (urlOrFunctions) {
|
|
4
2
|
return async function (context, commands) {
|
|
5
3
|
for (let urlOrFunction of urlOrFunctions) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
await commands.measure.start(urlOrFunction);
|
|
10
|
-
}
|
|
4
|
+
await (typeof urlOrFunction === 'function'
|
|
5
|
+
? urlOrFunction(context, commands)
|
|
6
|
+
: commands.measure.start(urlOrFunction));
|
|
11
7
|
}
|
|
12
8
|
};
|
|
13
|
-
}
|
|
9
|
+
}
|