browsertime 17.0.0-beta.4 → 17.0.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 +22 -13
- package/bin/browsertime.js +4 -4
- package/bin/browsertimeWebPageReplay.js +2 -2
- package/index.js +2 -2
- package/lib/android/gnirehtet.js +1 -2
- package/lib/android/root.js +57 -16
- package/lib/chrome/chromeDevtoolsProtocol.js +2 -3
- package/lib/chrome/har.js +1 -1
- package/lib/chrome/longTaskMetrics.js +1 -1
- package/lib/chrome/parseCpuTrace.js +2 -2
- package/lib/chrome/settings/chromeAndroidOptions.js +1 -1
- package/lib/chrome/settings/chromeDesktopOptions.js +1 -1
- package/lib/chrome/settings/traceCategories.js +1 -1
- package/lib/chrome/traceCategoriesParser.js +3 -3
- package/lib/chrome/webdriver/builder.js +1 -1
- package/lib/chrome/webdriver/chromium.js +13 -17
- package/lib/chrome/webdriver/setupChromiumOptions.js +18 -13
- package/lib/connectivity/humble.js +10 -12
- package/lib/connectivity/index.js +1 -1
- package/lib/core/engine/collector.js +2 -4
- package/lib/core/engine/command/addText.js +1 -2
- package/lib/core/engine/command/android.js +1 -1
- package/lib/core/engine/command/cache.js +1 -2
- package/lib/core/engine/command/chromeDevToolsProtocol.js +1 -2
- package/lib/core/engine/command/click.js +1 -2
- package/lib/core/engine/command/debug.js +1 -3
- package/lib/core/engine/command/javaScript.js +1 -2
- package/lib/core/engine/command/measure.js +13 -15
- package/lib/core/engine/command/meta.js +1 -1
- package/lib/core/engine/command/navigation.js +1 -1
- package/lib/core/engine/command/screenshot.js +1 -1
- package/lib/core/engine/command/scroll.js +1 -1
- package/lib/core/engine/command/select.js +1 -1
- package/lib/core/engine/command/set.js +1 -1
- package/lib/core/engine/command/stopWatch.js +1 -1
- package/lib/core/engine/command/switch.js +44 -1
- package/lib/core/engine/command/util/lcpHighlightScript.js +1 -1
- package/lib/core/engine/command/util/lsHighlightScript.js +1 -1
- package/lib/core/engine/command/wait.js +1 -1
- package/lib/core/engine/index.js +12 -12
- package/lib/core/engine/iteration.js +27 -27
- package/lib/core/engine/run.js +1 -1
- package/lib/core/pageCompleteChecks/defaultPageCompleteCheck.js +1 -1
- package/lib/core/pageCompleteChecks/pageCompleteCheckByInactivity.js +1 -1
- package/lib/core/pageCompleteChecks/spaInactivity.js +1 -1
- package/lib/core/seleniumRunner.js +9 -11
- package/lib/edge/webdriver/builder.js +1 -1
- package/lib/extensionserver/index.js +2 -4
- package/lib/extensionserver/setup.js +1 -1
- package/lib/firefox/geckoProfiler.js +46 -16
- package/lib/firefox/getHAR.js +1 -1
- package/lib/firefox/memoryReport.js +1 -1
- package/lib/firefox/settings/disableSafeBrowsingPreferences.js +1 -1
- package/lib/firefox/settings/disableTrackingProtectionPreferences.js +1 -1
- package/lib/firefox/settings/firefoxPreferences.js +1 -1
- package/lib/firefox/webdriver/builder.js +9 -9
- package/lib/firefox/webdriver/firefox.js +24 -6
- package/lib/safari/webdriver/safari.js +1 -1
- package/lib/screenshot/defaults.js +1 -1
- package/lib/screenshot/index.js +3 -5
- package/lib/support/cli.js +5 -5
- package/lib/support/dns.js +1 -1
- package/lib/support/engineUtils.js +5 -13
- package/lib/support/getViewPort.js +1 -1
- package/lib/support/har/index.js +6 -8
- package/lib/support/images/index.js +1 -1
- package/lib/support/logging.js +1 -1
- package/lib/support/pathToFolder.js +4 -4
- package/lib/support/preURL.js +1 -1
- package/lib/support/processes.js +1 -1
- package/lib/support/setResourceTimingBufferSize.js +1 -1
- package/lib/support/stop.js +1 -1
- package/lib/support/storageManager.js +1 -3
- package/lib/support/tcpdump.js +2 -2
- package/lib/support/xvfb.js +2 -4
- package/lib/video/postprocessing/finetune/addTextToVideo.js +3 -3
- package/lib/video/postprocessing/finetune/convertFps.js +1 -1
- package/lib/video/postprocessing/finetune/getFont.js +1 -1
- package/lib/video/postprocessing/finetune/getTimingMetrics.js +2 -2
- package/lib/video/postprocessing/finetune/index.js +4 -4
- package/lib/video/postprocessing/finetune/removeOrange.js +1 -1
- package/lib/video/postprocessing/visualmetrics/extraMetrics.js +1 -1
- package/lib/video/postprocessing/visualmetrics/getVideoMetrics.js +2 -2
- package/lib/video/screenRecording/android/recorder.js +1 -1
- package/lib/video/screenRecording/desktop/convert.js +1 -1
- package/lib/video/screenRecording/desktop/desktopRecorder.js +3 -3
- package/lib/video/screenRecording/desktop/ffmpegRecorder.js +6 -6
- package/lib/video/screenRecording/desktop/osx/getSPDisplaysDataType.js +1 -1
- package/lib/video/screenRecording/desktop/osx/getScreen.js +1 -1
- package/lib/video/screenRecording/firefox/firefoxWindowRecorder.js +1 -1
- package/lib/video/screenRecording/ios/convertToMp4.js +1 -1
- package/lib/video/screenRecording/ios/iosRecorder.js +2 -2
- package/lib/video/screenRecording/iosSimulator/convertToMp4.js +1 -1
- package/lib/video/screenRecording/iosSimulator/recorder.js +2 -2
- package/lib/video/screenRecording/recorder.js +6 -6
- package/lib/video/screenRecording/setOrangeBackground.js +1 -1
- package/lib/video/video.js +9 -11
- package/package.json +17 -17
|
@@ -10,7 +10,7 @@ function addClick(js) {
|
|
|
10
10
|
return script;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
class Click {
|
|
13
|
+
export class Click {
|
|
14
14
|
constructor(browser, pageCompleteCheck) {
|
|
15
15
|
this.browser = browser;
|
|
16
16
|
this.pageCompleteCheck = pageCompleteCheck;
|
|
@@ -269,4 +269,3 @@ class Click {
|
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
|
-
export default Click;
|
|
@@ -2,7 +2,7 @@ import intel from 'intel';
|
|
|
2
2
|
const log = intel.getLogger('browsertime.command.debug');
|
|
3
3
|
const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
4
4
|
|
|
5
|
-
class Debug {
|
|
5
|
+
export class Debug {
|
|
6
6
|
constructor(browser, options) {
|
|
7
7
|
this.browser = browser;
|
|
8
8
|
this.options = options;
|
|
@@ -43,5 +43,3 @@ class Debug {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
export default Debug;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import intel from 'intel';
|
|
2
2
|
const log = intel.getLogger('browsertime.command.javascript');
|
|
3
|
-
class JavaScript {
|
|
3
|
+
export class JavaScript {
|
|
4
4
|
constructor(browser, pageCompleteCheck) {
|
|
5
5
|
this.browser = browser;
|
|
6
6
|
this.pageCompleteCheck = pageCompleteCheck;
|
|
@@ -97,4 +97,3 @@ class JavaScript {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
export default JavaScript;
|
|
@@ -3,14 +3,14 @@ import intel from 'intel';
|
|
|
3
3
|
import get from 'lodash.get';
|
|
4
4
|
import merge from 'lodash.merge';
|
|
5
5
|
import { timestamp as _timestamp } from '../../../support/engineUtils.js';
|
|
6
|
-
import Video from '../../../video/video.js';
|
|
7
|
-
import pathToFolder from '../../../support/pathToFolder.js';
|
|
8
|
-
import setOrangeBackground from '../../../video/screenRecording/setOrangeBackground.js';
|
|
6
|
+
import { Video } from '../../../video/video.js';
|
|
7
|
+
import { pathToFolder } from '../../../support/pathToFolder.js';
|
|
8
|
+
import { setOrangeBackground } from '../../../video/screenRecording/setOrangeBackground.js';
|
|
9
9
|
import { filterWhitelisted } from '../../../support/userTiming.js';
|
|
10
10
|
import { isAndroidConfigured, Android } from '../../../android/index.js';
|
|
11
|
-
import TCPDump from '../../../support/tcpdump.js';
|
|
12
|
-
import highlightLargestContentfulPaint from './util/lcpHighlightScript.js';
|
|
13
|
-
import highlightLS from './util/lsHighlightScript.js';
|
|
11
|
+
import { TCPDump } from '../../../support/tcpdump.js';
|
|
12
|
+
import { lcpHighlightScript as highlightLargestContentfulPaint } from './util/lcpHighlightScript.js';
|
|
13
|
+
import { clsHighlightScript as highlightLS } from './util/lsHighlightScript.js';
|
|
14
14
|
const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
15
15
|
const log = intel.getLogger('browsertime.command.measure');
|
|
16
16
|
|
|
@@ -27,7 +27,7 @@ function getNewResult() {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
class Measure {
|
|
30
|
+
export class Measure {
|
|
31
31
|
constructor(
|
|
32
32
|
browser,
|
|
33
33
|
index,
|
|
@@ -105,10 +105,10 @@ class Measure {
|
|
|
105
105
|
_error(message) {
|
|
106
106
|
// If we already are measuring a page, associate the error woth that page
|
|
107
107
|
if (this.areWeMeasuring === true) {
|
|
108
|
-
if (
|
|
109
|
-
this.result[this.numberOfMeasuredPages].error = [message];
|
|
110
|
-
} else {
|
|
108
|
+
if (this.result[this.numberOfMeasuredPages].error) {
|
|
111
109
|
this.result[this.numberOfMeasuredPages].error.push(message);
|
|
110
|
+
} else {
|
|
111
|
+
this.result[this.numberOfMeasuredPages].error = [message];
|
|
112
112
|
}
|
|
113
113
|
} else {
|
|
114
114
|
// If we have tested pages before, but not in the making of
|
|
@@ -360,10 +360,10 @@ class Measure {
|
|
|
360
360
|
this.result[this.numberOfMeasuredPages].alias
|
|
361
361
|
) {
|
|
362
362
|
const alias = this.result[this.numberOfMeasuredPages].alias;
|
|
363
|
-
if (
|
|
364
|
-
aliasAndUrl[alias] = url;
|
|
365
|
-
} else {
|
|
363
|
+
if (aliasAndUrl[alias]) {
|
|
366
364
|
url = aliasAndUrl[alias];
|
|
365
|
+
} else {
|
|
366
|
+
aliasAndUrl[alias] = url;
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
369
|
|
|
@@ -522,5 +522,3 @@ class Measure {
|
|
|
522
522
|
this.areWeMeasuring = false;
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
|
-
|
|
526
|
-
export default Measure;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import intel from 'intel';
|
|
2
2
|
const log = intel.getLogger('browsertime.command.navigation');
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export class Navigation {
|
|
5
5
|
constructor(browser, pageCompleteCheck) {
|
|
6
6
|
this.browser = browser;
|
|
7
7
|
this.pageCompleteCheck = pageCompleteCheck;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import intel from 'intel';
|
|
2
2
|
const log = intel.getLogger('browsertime.command.scroll');
|
|
3
3
|
const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
4
|
-
export
|
|
4
|
+
export class Scroll {
|
|
5
5
|
constructor(browser, options) {
|
|
6
6
|
this.browser = browser;
|
|
7
7
|
this.options = options;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import intel from 'intel';
|
|
2
|
+
import { By } from 'selenium-webdriver';
|
|
2
3
|
const log = intel.getLogger('browsertime.command.switch');
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
+
export class Switch {
|
|
5
6
|
constructor(browser, pageCompleteCheck, navigate) {
|
|
6
7
|
this.browser = browser;
|
|
7
8
|
this.pageCompleteCheck = pageCompleteCheck;
|
|
@@ -23,6 +24,48 @@ export default class Switch {
|
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Switch to frame by xpath
|
|
29
|
+
* @param {*} xpath
|
|
30
|
+
*/
|
|
31
|
+
async toFrameByXpath(xpath) {
|
|
32
|
+
const driver = this.browser.getDriver();
|
|
33
|
+
try {
|
|
34
|
+
const element = await driver.findElement(By.xpath(xpath));
|
|
35
|
+
if (element) {
|
|
36
|
+
await driver.switchTo().frame(element);
|
|
37
|
+
} else {
|
|
38
|
+
log.error('Could not find frame using xpath %s ', xpath);
|
|
39
|
+
throw new Error(`Could not find frame using xpath ${xpath}`);
|
|
40
|
+
}
|
|
41
|
+
} catch (error) {
|
|
42
|
+
log.error('Could not switch to frame using xpath %s ', xpath);
|
|
43
|
+
log.verbose(error);
|
|
44
|
+
throw new Error(`Could not switch to frame using xpath ${xpath}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Switch to frame by xpath
|
|
50
|
+
* @param {*} xpath
|
|
51
|
+
*/
|
|
52
|
+
async toFrameBySelector(selector) {
|
|
53
|
+
const driver = this.browser.getDriver();
|
|
54
|
+
try {
|
|
55
|
+
const element = await driver.findElement(By.css(selector));
|
|
56
|
+
if (element) {
|
|
57
|
+
await driver.switchTo().frame(element);
|
|
58
|
+
} else {
|
|
59
|
+
log.error('Could not find frame using selector%s ', selector);
|
|
60
|
+
throw new Error(`Could not find frame using selector ${selector}`);
|
|
61
|
+
}
|
|
62
|
+
} catch (error) {
|
|
63
|
+
log.error('Could not switch to frame using selector %s ', selector);
|
|
64
|
+
log.verbose(error);
|
|
65
|
+
throw new Error(`Could not switch to frame using selector${selector}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
26
69
|
/**
|
|
27
70
|
* Switch to a window by name
|
|
28
71
|
* @param {*} name
|
|
@@ -3,7 +3,7 @@ import intel from 'intel';
|
|
|
3
3
|
const log = intel.getLogger('browsertime.command.wait');
|
|
4
4
|
const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export class Wait {
|
|
7
7
|
constructor(browser, pageCompleteCheck) {
|
|
8
8
|
this.browser = browser;
|
|
9
9
|
this.pageCompleteCheck = pageCompleteCheck;
|
package/lib/core/engine/index.js
CHANGED
|
@@ -4,10 +4,10 @@ import merge from 'lodash.merge';
|
|
|
4
4
|
import getPort, { portNumbers } from 'get-port';
|
|
5
5
|
import { execaCommand as command } from 'execa';
|
|
6
6
|
import get from 'lodash.get';
|
|
7
|
-
import StorageManager from '../../support/storageManager.js';
|
|
8
|
-
import Firefox from '../../firefox/webdriver/firefox.js';
|
|
9
|
-
import Chromium from '../../chrome/webdriver/chromium.js';
|
|
10
|
-
import Safari from '../../safari/webdriver/safari.js';
|
|
7
|
+
import { StorageManager } from '../../support/storageManager.js';
|
|
8
|
+
import { Firefox } from '../../firefox/webdriver/firefox.js';
|
|
9
|
+
import { Chromium } from '../../chrome/webdriver/chromium.js';
|
|
10
|
+
import { Safari } from '../../safari/webdriver/safari.js';
|
|
11
11
|
import {
|
|
12
12
|
addConnectivity,
|
|
13
13
|
removeConnectivity
|
|
@@ -18,14 +18,14 @@ import {
|
|
|
18
18
|
getMainDocumentTimings,
|
|
19
19
|
addExtraFieldsToHar
|
|
20
20
|
} from '../../support/har/index.js';
|
|
21
|
-
import XVFB from '../../support/xvfb.js';
|
|
22
|
-
import Gnirehtet from '../../android/gnirehtet.js';
|
|
23
|
-
import Iteration from './iteration.js';
|
|
24
|
-
import Collector from './collector.js';
|
|
21
|
+
import { XVFB } from '../../support/xvfb.js';
|
|
22
|
+
import { Gnirehtet } from '../../android/gnirehtet.js';
|
|
23
|
+
import { Iteration } from './iteration.js';
|
|
24
|
+
import { Collector } from './collector.js';
|
|
25
25
|
import { Android, isAndroidConfigured } from '../../android/index.js';
|
|
26
|
-
import RootedDevice from '../../android/root.js';
|
|
27
|
-
import run from './run.js';
|
|
28
|
-
import IOSRecorder from '../../video/screenRecording/ios/iosRecorder.js';
|
|
26
|
+
import { RootedDevice } from '../../android/root.js';
|
|
27
|
+
import { run } from './run.js';
|
|
28
|
+
import { IOSRecorder } from '../../video/screenRecording/ios/iosRecorder.js';
|
|
29
29
|
import { loadPrePostScripts, loadScript } from '../../support/engineUtils.js';
|
|
30
30
|
const log = intel.getLogger('browsertime');
|
|
31
31
|
const defaults = {
|
|
@@ -45,7 +45,7 @@ function shouldDelay(index, total, delay) {
|
|
|
45
45
|
* Create a new Browsertime Engine.
|
|
46
46
|
* @class
|
|
47
47
|
*/
|
|
48
|
-
export
|
|
48
|
+
export class Engine {
|
|
49
49
|
constructor(options) {
|
|
50
50
|
this.options = merge({}, defaults, options);
|
|
51
51
|
if (log.isEnabledFor(log.DEBUG)) {
|
|
@@ -2,34 +2,34 @@ import { platform } from 'node:os';
|
|
|
2
2
|
import webdriver from 'selenium-webdriver';
|
|
3
3
|
import intel from 'intel';
|
|
4
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 Video from '../../video/video.js';
|
|
11
|
-
import stop from '../../support/stop.js';
|
|
12
|
-
import AddText from './command/addText.js';
|
|
13
|
-
import Click from './command/click.js';
|
|
14
|
-
import Wait from './command/wait.js';
|
|
15
|
-
import Measure from './command/measure.js';
|
|
16
|
-
import JavaScript from './command/javaScript.js';
|
|
17
|
-
import Switch from './command/switch.js';
|
|
18
|
-
import Screenshot from './command/screenshot.js';
|
|
19
|
-
import Set from './command/set.js';
|
|
20
|
-
import Cache from './command/cache.js';
|
|
21
|
-
import Meta from './command/meta.js';
|
|
22
|
-
import StopWatch from './command/stopWatch.js';
|
|
23
|
-
import Select from './command/select.js';
|
|
24
|
-
import Debug from './command/debug.js';
|
|
25
|
-
import AndroidCommand from './command/android.js';
|
|
26
|
-
import ChromeDevelopmentToolsProtocol from './command/chromeDevToolsProtocol.js';
|
|
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 { Video } from '../../video/video.js';
|
|
11
|
+
import { stop } from '../../support/stop.js';
|
|
12
|
+
import { AddText } from './command/addText.js';
|
|
13
|
+
import { Click } from './command/click.js';
|
|
14
|
+
import { Wait } from './command/wait.js';
|
|
15
|
+
import { Measure } from './command/measure.js';
|
|
16
|
+
import { JavaScript } from './command/javaScript.js';
|
|
17
|
+
import { Switch } from './command/switch.js';
|
|
18
|
+
import { Screenshot } from './command/screenshot.js';
|
|
19
|
+
import { Set } from './command/set.js';
|
|
20
|
+
import { Cache } from './command/cache.js';
|
|
21
|
+
import { Meta } from './command/meta.js';
|
|
22
|
+
import { Watch as StopWatch } from './command/stopWatch.js';
|
|
23
|
+
import { Select } from './command/select.js';
|
|
24
|
+
import { Debug } from './command/debug.js';
|
|
25
|
+
import { AndroidCommand } from './command/android.js';
|
|
26
|
+
import { ChromeDevelopmentToolsProtocol } from './command/chromeDevToolsProtocol.js';
|
|
27
27
|
import {
|
|
28
28
|
addConnectivity,
|
|
29
29
|
removeConnectivity
|
|
30
30
|
} from '../../connectivity/index.js';
|
|
31
31
|
import { jsonifyVisualProgress } from '../../support/util.js';
|
|
32
|
-
import flushDNS from '../../support/dns.js';
|
|
32
|
+
import { flushDNS } from '../../support/dns.js';
|
|
33
33
|
import {
|
|
34
34
|
SingleClick,
|
|
35
35
|
DoubleClick,
|
|
@@ -37,10 +37,10 @@ import {
|
|
|
37
37
|
ContextClick,
|
|
38
38
|
MouseMove
|
|
39
39
|
} from './command/mouse/index.js';
|
|
40
|
-
import getNumberOfRunningProcesses from '../../support/processes.js';
|
|
40
|
+
import { getNumberOfRunningProcesses } from '../../support/processes.js';
|
|
41
41
|
import { isAndroidConfigured, Android } from '../../android/index.js';
|
|
42
|
-
import Scroll from './command/scroll.js';
|
|
43
|
-
import Navigation from './command/navigation.js';
|
|
42
|
+
import { Scroll } from './command/scroll.js';
|
|
43
|
+
import { Navigation } from './command/navigation.js';
|
|
44
44
|
const log = intel.getLogger('browsertime');
|
|
45
45
|
const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
46
46
|
|
|
@@ -51,7 +51,7 @@ const ANDROID_DELAY_TIME = 2000;
|
|
|
51
51
|
* Browsertime will do through one iteration of testing a URL.
|
|
52
52
|
* @class
|
|
53
53
|
*/
|
|
54
|
-
export
|
|
54
|
+
export class Iteration {
|
|
55
55
|
constructor(
|
|
56
56
|
storageManager,
|
|
57
57
|
engineDelegate,
|
package/lib/core/engine/run.js
CHANGED
|
@@ -5,10 +5,10 @@ import { Condition } from 'selenium-webdriver';
|
|
|
5
5
|
import { isAndroidConfigured } from '../android/index.js';
|
|
6
6
|
import { UrlLoadError, BrowserError, TimeoutError } from '../support/errors.js';
|
|
7
7
|
import { createWebDriver } from './webdriver/index.js';
|
|
8
|
-
import getViewPort from '../support/getViewPort.js';
|
|
9
|
-
import defaultPageCompleteCheck from './pageCompleteChecks/defaultPageCompleteCheck.js';
|
|
10
|
-
import pageCompleteCheckByInactivity from './pageCompleteChecks/pageCompleteCheckByInactivity.js';
|
|
11
|
-
import spaCheck from './pageCompleteChecks/spaInactivity.js';
|
|
8
|
+
import { getViewPort } from '../support/getViewPort.js';
|
|
9
|
+
import { defaultPageCompleteCheck } from './pageCompleteChecks/defaultPageCompleteCheck.js';
|
|
10
|
+
import { pageCompleteCheckByInactivity } from './pageCompleteChecks/pageCompleteCheckByInactivity.js';
|
|
11
|
+
import { spaInactivity as spaCheck } from './pageCompleteChecks/spaInactivity.js';
|
|
12
12
|
const log = intel.getLogger('browsertime');
|
|
13
13
|
|
|
14
14
|
const defaults = {
|
|
@@ -49,7 +49,7 @@ async function timeout(promise, ms, errorMessage) {
|
|
|
49
49
|
* Wrapper for Selenium.
|
|
50
50
|
* @class
|
|
51
51
|
*/
|
|
52
|
-
class SeleniumRunner {
|
|
52
|
+
export class SeleniumRunner {
|
|
53
53
|
constructor(baseDir, options) {
|
|
54
54
|
this.options = merge({}, defaults, options);
|
|
55
55
|
this.baseDir = baseDir;
|
|
@@ -296,10 +296,7 @@ class SeleniumRunner {
|
|
|
296
296
|
`Could not load ${url} is the web page down?`,
|
|
297
297
|
url
|
|
298
298
|
);
|
|
299
|
-
} else if (newURI
|
|
300
|
-
// We navigated to a new page, we don't need to test anymore
|
|
301
|
-
break;
|
|
302
|
-
} else {
|
|
299
|
+
} else if (newURI === startURI) {
|
|
303
300
|
const waitTime = (this.options.retryWaitTime || 10_000) * (index + 1);
|
|
304
301
|
totalWaitTime += waitTime;
|
|
305
302
|
log.debug(
|
|
@@ -322,6 +319,9 @@ class SeleniumRunner {
|
|
|
322
319
|
'Will check again if the browser has navigated to the page'
|
|
323
320
|
);
|
|
324
321
|
}
|
|
322
|
+
} else {
|
|
323
|
+
// We navigated to a new page, we don't need to test anymore
|
|
324
|
+
break;
|
|
325
325
|
}
|
|
326
326
|
} catch (error) {
|
|
327
327
|
log.info(
|
|
@@ -667,5 +667,3 @@ class SeleniumRunner {
|
|
|
667
667
|
return results;
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
|
-
|
|
671
|
-
export default SeleniumRunner;
|
|
@@ -4,7 +4,7 @@ import get from 'lodash.get';
|
|
|
4
4
|
import pick from 'lodash.pick';
|
|
5
5
|
import isEmpty from 'lodash.isempty';
|
|
6
6
|
import { logging } from 'selenium-webdriver';
|
|
7
|
-
import setupChromiumOptions from '../../chrome/webdriver/setupChromiumOptions.js';
|
|
7
|
+
import { setupChromiumOptions } from '../../chrome/webdriver/setupChromiumOptions.js';
|
|
8
8
|
const log = intel.getLogger('browsertime.edge');
|
|
9
9
|
const { pac, manual } = 'selenium-webdriver/proxy.js';
|
|
10
10
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { startServer, stopServer } from './httpServer.js';
|
|
2
|
-
import setup from './setup.js';
|
|
2
|
+
import { setup } from './setup.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Create a ExtensionServer. The extension server helps us with
|
|
@@ -7,7 +7,7 @@ import setup from './setup.js';
|
|
|
7
7
|
* use a WebExtension to prepare our tests.
|
|
8
8
|
* @class
|
|
9
9
|
*/
|
|
10
|
-
class ExtensionServer {
|
|
10
|
+
export class ExtensionServer {
|
|
11
11
|
constructor(options) {
|
|
12
12
|
this.options = options;
|
|
13
13
|
}
|
|
@@ -48,5 +48,3 @@ class ExtensionServer {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
export default ExtensionServer;
|
|
@@ -46,7 +46,7 @@ function generateURL(port, testUrl, options) {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export
|
|
49
|
+
export async function setup(url, browser, port, options) {
|
|
50
50
|
const configUrl = generateURL(port, url, options);
|
|
51
51
|
log.debug('Configuring browser plugin via %s', configUrl);
|
|
52
52
|
await browser.loadAndWait(configUrl);
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
desktop_sampling_interval
|
|
7
7
|
} from './settings/geckoProfilerDefaults.js';
|
|
8
8
|
import { isAndroidConfigured, Android } from '../android/index.js';
|
|
9
|
-
import pathToFolder from '../support/pathToFolder.js';
|
|
9
|
+
import { pathToFolder } from '../support/pathToFolder.js';
|
|
10
10
|
import { BrowserError } from '../support/errors.js';
|
|
11
11
|
const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
12
12
|
const log = intel.getLogger('browsertime.firefox');
|
|
@@ -32,7 +32,7 @@ async function timeout(promise, ms, errorMessage) {
|
|
|
32
32
|
})
|
|
33
33
|
]);
|
|
34
34
|
}
|
|
35
|
-
class GeckoProfiler {
|
|
35
|
+
export class GeckoProfiler {
|
|
36
36
|
constructor(runner, storageManager, firefoxConfig, options) {
|
|
37
37
|
this.runner = runner;
|
|
38
38
|
this.storageManager = storageManager;
|
|
@@ -73,14 +73,38 @@ class GeckoProfiler {
|
|
|
73
73
|
);
|
|
74
74
|
|
|
75
75
|
let script;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
switch (parameterLength) {
|
|
77
|
+
case 7: {
|
|
78
|
+
// Oldest profiler API. It was deprecated in Firefox 69.
|
|
79
|
+
script = `Services.profiler.StartProfiler(${bufferSize},${interval},${featureString},
|
|
80
|
+
${chosenFeatures.length},${threadString},${chosenThreads.length});`;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case 6: {
|
|
84
|
+
// Newest profiler API. It's being used since Firefox 72.
|
|
85
|
+
// `activeBrowserId` is useful for distinguishing browser tabs in the profiler UI.
|
|
86
|
+
const activeBrowserIdScript = `
|
|
87
|
+
const win = Services.wm.getMostRecentWindow("navigator:browser");
|
|
88
|
+
return win?.gBrowser?.selectedBrowser?.browsingContext?.browserId ?? 0;
|
|
89
|
+
`;
|
|
90
|
+
const activeBrowserId = await runner.runPrivilegedScript(
|
|
91
|
+
activeBrowserIdScript,
|
|
92
|
+
'Get activeBrowserId'
|
|
93
|
+
);
|
|
94
|
+
script = `Services.profiler.StartProfiler(${bufferSize},${interval},${featureString},
|
|
95
|
+
${threadString},${activeBrowserId});`;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case 5: {
|
|
99
|
+
// The profiler API that was used between Firefox 69 and 72.
|
|
100
|
+
script = `Services.profiler.StartProfiler(${bufferSize},${interval},${featureString},
|
|
101
|
+
${threadString});`;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
default: {
|
|
105
|
+
log.error('Unknown Gecko Profiler API');
|
|
106
|
+
throw new Error('Unknown Gecko Profiler API');
|
|
107
|
+
}
|
|
84
108
|
}
|
|
85
109
|
|
|
86
110
|
log.info(
|
|
@@ -140,16 +164,24 @@ class GeckoProfiler {
|
|
|
140
164
|
);
|
|
141
165
|
|
|
142
166
|
if (isAndroidConfigured(options)) {
|
|
167
|
+
log.info('Download profile file from Android.');
|
|
143
168
|
const android = new Android(options);
|
|
144
169
|
await android._downloadFile(deviceProfileFilename, destinationFilename);
|
|
145
170
|
}
|
|
146
171
|
|
|
147
172
|
// GZIP the profile and remove the old file
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
173
|
+
log.info('Gzip file the profile.');
|
|
174
|
+
await timeout(
|
|
175
|
+
storageManager.gzip(
|
|
176
|
+
destinationFilename,
|
|
177
|
+
join(profileDir, `geckoProfile-${index}.json.gz`),
|
|
178
|
+
true
|
|
179
|
+
),
|
|
180
|
+
300_000, // 5 minutes
|
|
181
|
+
'Could not gzip the profile.'
|
|
152
182
|
);
|
|
183
|
+
|
|
184
|
+
log.info('Done stopping GeckoProfiler.');
|
|
153
185
|
} catch (error) {
|
|
154
186
|
log.error(error.message);
|
|
155
187
|
}
|
|
@@ -157,5 +189,3 @@ class GeckoProfiler {
|
|
|
157
189
|
|
|
158
190
|
addMetaData() {}
|
|
159
191
|
}
|
|
160
|
-
|
|
161
|
-
export default GeckoProfiler;
|
package/lib/firefox/getHAR.js
CHANGED
|
@@ -3,7 +3,7 @@ const log = intel.getLogger('browsertime.firefox');
|
|
|
3
3
|
|
|
4
4
|
// Get the HAR from Firefox
|
|
5
5
|
// Using https://github.com/firefox-devtools/har-export-trigger
|
|
6
|
-
export
|
|
6
|
+
export async function getHAR(runner, includeResponseBodies) {
|
|
7
7
|
const script = `
|
|
8
8
|
const callback = arguments[arguments.length - 1];
|
|
9
9
|
async function triggerExport() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import intel from 'intel';
|
|
3
|
-
import pathToFolder from '../support/pathToFolder.js';
|
|
3
|
+
import { pathToFolder } from '../support/pathToFolder.js';
|
|
4
4
|
import { BrowserError } from '../support/errors.js';
|
|
5
5
|
import { isAndroidConfigured, Android } from '../android/index.js';
|
|
6
6
|
const delay = ms => new Promise(res => setTimeout(res, ms));
|