browsertime 16.17.0 → 17.0.0-beta.1
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 +44 -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 +22 -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 +82 -72
- package/lib/core/engine/iteration.js +83 -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 +44 -49
- 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 +120 -87
- 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();
|
|
@@ -263,7 +269,7 @@ class Iteration {
|
|
|
263
269
|
try {
|
|
264
270
|
log.info('Ignoring shutdown failures on android...');
|
|
265
271
|
await browser.stop();
|
|
266
|
-
} catch
|
|
272
|
+
} catch {
|
|
267
273
|
// Ignore shutdown failures on android
|
|
268
274
|
log.info('Shutdown problem hit, ignoring...');
|
|
269
275
|
}
|
|
@@ -281,12 +287,12 @@ class Iteration {
|
|
|
281
287
|
}
|
|
282
288
|
|
|
283
289
|
if (options.visualMetrics && !options.videoParams.debug) {
|
|
284
|
-
let
|
|
290
|
+
let index_ = 0;
|
|
285
291
|
for (let myVideo of videos) {
|
|
286
292
|
try {
|
|
287
293
|
const videoMetrics = await myVideo.postProcessing(
|
|
288
|
-
result[
|
|
289
|
-
result[
|
|
294
|
+
result[index_].browserScripts.timings.pageTimings,
|
|
295
|
+
result[index_].browserScripts.pageinfo.visualElements
|
|
290
296
|
);
|
|
291
297
|
|
|
292
298
|
for (let progress of [
|
|
@@ -295,20 +301,20 @@ class Iteration {
|
|
|
295
301
|
'PerceptualSpeedIndexProgress'
|
|
296
302
|
]) {
|
|
297
303
|
if (videoMetrics.visualMetrics[progress]) {
|
|
298
|
-
videoMetrics.visualMetrics[progress] =
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
);
|
|
304
|
+
videoMetrics.visualMetrics[progress] = jsonifyVisualProgress(
|
|
305
|
+
videoMetrics.visualMetrics[progress]
|
|
306
|
+
);
|
|
302
307
|
}
|
|
303
308
|
}
|
|
304
|
-
result[
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
309
|
+
result[index_].videoRecordingStart =
|
|
310
|
+
videoMetrics.videoRecordingStart;
|
|
311
|
+
result[index_].visualMetrics = videoMetrics.visualMetrics;
|
|
312
|
+
index_++;
|
|
313
|
+
} catch (error) {
|
|
308
314
|
// If one of the Visual Metrics runs fail, try the next one
|
|
309
|
-
log.error('Visual Metrics failed to analyse the video',
|
|
310
|
-
if (result[
|
|
311
|
-
result[
|
|
315
|
+
log.error('Visual Metrics failed to analyse the video', error);
|
|
316
|
+
if (result[index_]) {
|
|
317
|
+
result[index_].error.push(error.message);
|
|
312
318
|
}
|
|
313
319
|
}
|
|
314
320
|
}
|
|
@@ -333,8 +339,8 @@ class Iteration {
|
|
|
333
339
|
|
|
334
340
|
result.processesAtStart = this.processesAtStart;
|
|
335
341
|
return result;
|
|
336
|
-
} catch (
|
|
337
|
-
log.error(
|
|
342
|
+
} catch (error) {
|
|
343
|
+
log.error(error);
|
|
338
344
|
if (recordVideo && options.videoParams.debug) {
|
|
339
345
|
// Just use the first URL
|
|
340
346
|
const url =
|
|
@@ -346,9 +352,9 @@ class Iteration {
|
|
|
346
352
|
if (options.docker && recordVideo && !isAndroidConfigured(options)) {
|
|
347
353
|
await stop('ffmpeg');
|
|
348
354
|
}
|
|
349
|
-
result.error = [
|
|
355
|
+
result.error = [error.name];
|
|
350
356
|
result.markedAsFailure = 1;
|
|
351
|
-
result.failureMessages = [
|
|
357
|
+
result.failureMessages = [error.message];
|
|
352
358
|
return result;
|
|
353
359
|
} finally {
|
|
354
360
|
// Here we should also make sure FFMPEG is really killed/stopped
|
|
@@ -362,11 +368,9 @@ class Iteration {
|
|
|
362
368
|
} else {
|
|
363
369
|
await browser.stop();
|
|
364
370
|
}
|
|
365
|
-
} catch
|
|
371
|
+
} catch {
|
|
366
372
|
// Most cases the browser been stopped already
|
|
367
373
|
}
|
|
368
374
|
}
|
|
369
375
|
}
|
|
370
376
|
}
|
|
371
|
-
|
|
372
|
-
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
|
+
}
|