browsertime 20.0.0 → 21.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 +23 -0
- package/README.md +2 -2
- package/bin/browsertime.js +9 -3
- package/browserscripts/pageinfo/interactionToNextPaintInfo.js +170 -143
- package/browserscripts/timings/interactionToNextPaint.js +49 -137
- package/lib/chrome/webdriver/setupChromiumOptions.js +0 -9
- package/lib/core/engine/collector.js +11 -0
- package/lib/core/engine/command/actions.js +52 -0
- package/lib/core/engine/command/addText.js +48 -30
- package/lib/core/engine/command/android.js +43 -4
- package/lib/core/engine/command/cache.js +39 -2
- package/lib/core/engine/command/chromeDevToolsProtocol.js +51 -1
- package/lib/core/engine/command/chromeTrace.js +34 -0
- package/lib/core/engine/command/click.js +102 -52
- package/lib/core/engine/command/debug.js +19 -2
- package/lib/core/engine/command/element.js +66 -0
- package/lib/core/engine/command/geckoProfiler.js +41 -1
- package/lib/core/engine/command/javaScript.js +43 -20
- package/lib/core/engine/command/measure.js +147 -15
- package/lib/core/engine/command/meta.js +17 -0
- package/lib/core/engine/command/mouse/clickAndHold.js +56 -29
- package/lib/core/engine/command/mouse/contextClick.js +30 -11
- package/lib/core/engine/command/mouse/doubleClick.js +35 -11
- package/lib/core/engine/command/mouse/mouseMove.js +38 -16
- package/lib/core/engine/command/mouse/singleClick.js +187 -12
- package/lib/core/engine/command/navigation.js +31 -3
- package/lib/core/engine/command/screenshot.js +33 -0
- package/lib/core/engine/command/scroll.js +35 -13
- package/lib/core/engine/command/select.js +55 -36
- package/lib/core/engine/command/set.js +51 -36
- package/lib/core/engine/command/stopWatch.js +30 -9
- package/lib/core/engine/command/switch.js +49 -11
- package/lib/core/engine/command/wait.js +50 -25
- package/lib/core/engine/commands.js +267 -0
- package/lib/core/engine/context.js +81 -0
- package/lib/core/engine/iteration.js +20 -102
- package/lib/firefox/geckoProfiler.js +49 -1
- package/lib/firefox/webdriver/builder.js +4 -9
- package/lib/firefox/webdriver/firefox.js +1 -1
- package/lib/support/cli.js +7 -0
- package/lib/support/statistics.js +11 -1
- package/package.json +17 -7
- package/types/android/index.d.ts +70 -0
- package/types/android/index.d.ts.map +1 -0
- package/types/chrome/parseCpuTrace.d.ts +21 -0
- package/types/chrome/parseCpuTrace.d.ts.map +1 -0
- package/types/chrome/traceCategoriesParser.d.ts +2 -0
- package/types/chrome/traceCategoriesParser.d.ts.map +1 -0
- package/types/chrome/webdriver/traceUtilities.d.ts +8 -0
- package/types/chrome/webdriver/traceUtilities.d.ts.map +1 -0
- package/types/core/engine/command/action.d.ts +73 -0
- package/types/core/engine/command/action.d.ts.map +1 -0
- package/types/core/engine/command/actions.d.ts +38 -0
- package/types/core/engine/command/actions.d.ts.map +1 -0
- package/types/core/engine/command/addText.d.ts +68 -0
- package/types/core/engine/command/addText.d.ts.map +1 -0
- package/types/core/engine/command/android.d.ts +39 -0
- package/types/core/engine/command/android.d.ts.map +1 -0
- package/types/core/engine/command/cache.d.ts +53 -0
- package/types/core/engine/command/cache.d.ts.map +1 -0
- package/types/core/engine/command/chromeDevToolsProtocol.d.ts +61 -0
- package/types/core/engine/command/chromeDevToolsProtocol.d.ts.map +1 -0
- package/types/core/engine/command/chromeTrace.d.ts +45 -0
- package/types/core/engine/command/chromeTrace.d.ts.map +1 -0
- package/types/core/engine/command/click.d.ts +151 -0
- package/types/core/engine/command/click.d.ts.map +1 -0
- package/types/core/engine/command/debug.d.ts +28 -0
- package/types/core/engine/command/debug.d.ts.map +1 -0
- package/types/core/engine/command/element.d.ts +49 -0
- package/types/core/engine/command/element.d.ts.map +1 -0
- package/types/core/engine/command/geckoProfiler.d.ts +46 -0
- package/types/core/engine/command/geckoProfiler.d.ts.map +1 -0
- package/types/core/engine/command/javaScript.d.ts +63 -0
- package/types/core/engine/command/javaScript.d.ts.map +1 -0
- package/types/core/engine/command/measure.d.ts +194 -0
- package/types/core/engine/command/measure.d.ts.map +1 -0
- package/types/core/engine/command/meta.d.ts +23 -0
- package/types/core/engine/command/meta.d.ts.map +1 -0
- package/types/core/engine/command/mouse/clickAndHold.d.ts +82 -0
- package/types/core/engine/command/mouse/clickAndHold.d.ts.map +1 -0
- package/types/core/engine/command/mouse/contextClick.d.ts +44 -0
- package/types/core/engine/command/mouse/contextClick.d.ts.map +1 -0
- package/types/core/engine/command/mouse/doubleClick.d.ts +51 -0
- package/types/core/engine/command/mouse/doubleClick.d.ts.map +1 -0
- package/types/core/engine/command/mouse/index.d.ts +6 -0
- package/types/core/engine/command/mouse/index.d.ts.map +1 -0
- package/types/core/engine/command/mouse/mouseMove.d.ts +56 -0
- package/types/core/engine/command/mouse/mouseMove.d.ts.map +1 -0
- package/types/core/engine/command/mouse/singleClick.d.ts +115 -0
- package/types/core/engine/command/mouse/singleClick.d.ts.map +1 -0
- package/types/core/engine/command/navigation.d.ts +45 -0
- package/types/core/engine/command/navigation.d.ts.map +1 -0
- package/types/core/engine/command/screenshot.d.ts +33 -0
- package/types/core/engine/command/screenshot.d.ts.map +1 -0
- package/types/core/engine/command/scroll.d.ts +52 -0
- package/types/core/engine/command/scroll.d.ts.map +1 -0
- package/types/core/engine/command/select.d.ts +81 -0
- package/types/core/engine/command/select.d.ts.map +1 -0
- package/types/core/engine/command/set.d.ts +74 -0
- package/types/core/engine/command/set.d.ts.map +1 -0
- package/types/core/engine/command/stopWatch.d.ts +49 -0
- package/types/core/engine/command/stopWatch.d.ts.map +1 -0
- package/types/core/engine/command/switch.d.ts +77 -0
- package/types/core/engine/command/switch.d.ts.map +1 -0
- package/types/core/engine/command/util/lcpHighlightScript.d.ts +2 -0
- package/types/core/engine/command/util/lcpHighlightScript.d.ts.map +1 -0
- package/types/core/engine/command/util/lsHighlightScript.d.ts +2 -0
- package/types/core/engine/command/util/lsHighlightScript.d.ts.map +1 -0
- package/types/core/engine/command/wait.d.ts +74 -0
- package/types/core/engine/command/wait.d.ts.map +1 -0
- package/types/core/engine/commands.d.ts +161 -0
- package/types/core/engine/commands.d.ts.map +1 -0
- package/types/core/engine/context.d.ts +87 -0
- package/types/core/engine/context.d.ts.map +1 -0
- package/types/firefox/geckoProfiler.d.ts +11 -0
- package/types/firefox/geckoProfiler.d.ts.map +1 -0
- package/types/firefox/settings/geckoProfilerDefaults.d.ts +8 -0
- package/types/firefox/settings/geckoProfilerDefaults.d.ts.map +1 -0
- package/types/scripting.d.ts +2 -0
- package/types/support/engineUtils.d.ts +5 -0
- package/types/support/engineUtils.d.ts.map +1 -0
- package/types/support/errors.d.ts +15 -0
- package/types/support/errors.d.ts.map +1 -0
- package/types/support/fileUtil.d.ts +10 -0
- package/types/support/fileUtil.d.ts.map +1 -0
- package/types/support/filters.d.ts +7 -0
- package/types/support/filters.d.ts.map +1 -0
- package/types/support/getViewPort.d.ts +2 -0
- package/types/support/getViewPort.d.ts.map +1 -0
- package/types/support/pathToFolder.d.ts +2 -0
- package/types/support/pathToFolder.d.ts.map +1 -0
- package/types/support/storageManager.d.ts +17 -0
- package/types/support/storageManager.d.ts.map +1 -0
- package/types/support/tcpdump.d.ts +10 -0
- package/types/support/tcpdump.d.ts.map +1 -0
- package/types/support/userTiming.d.ts +2 -0
- package/types/support/userTiming.d.ts.map +1 -0
- package/types/support/util.d.ts +6 -0
- package/types/support/util.d.ts.map +1 -0
- package/types/video/defaults.d.ts +7 -0
- package/types/video/defaults.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/addTextToVideo.d.ts +2 -0
- package/types/video/postprocessing/finetune/addTextToVideo.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/convertFps.d.ts +2 -0
- package/types/video/postprocessing/finetune/convertFps.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/getFont.d.ts +2 -0
- package/types/video/postprocessing/finetune/getFont.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/getTimingMetrics.d.ts +2 -0
- package/types/video/postprocessing/finetune/getTimingMetrics.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/index.d.ts +2 -0
- package/types/video/postprocessing/finetune/index.d.ts.map +1 -0
- package/types/video/postprocessing/finetune/removeOrange.d.ts +2 -0
- package/types/video/postprocessing/finetune/removeOrange.d.ts.map +1 -0
- package/types/video/postprocessing/visualmetrics/extraMetrics.d.ts +5 -0
- package/types/video/postprocessing/visualmetrics/extraMetrics.d.ts.map +1 -0
- package/types/video/postprocessing/visualmetrics/getVideoMetrics.d.ts +5 -0
- package/types/video/postprocessing/visualmetrics/getVideoMetrics.d.ts.map +1 -0
- package/types/video/postprocessing/visualmetrics/visualMetrics.d.ts +3 -0
- package/types/video/postprocessing/visualmetrics/visualMetrics.d.ts.map +1 -0
- package/types/video/screenRecording/android/recorder.d.ts +11 -0
- package/types/video/screenRecording/android/recorder.d.ts.map +1 -0
- package/types/video/screenRecording/desktop/convert.d.ts +2 -0
- package/types/video/screenRecording/desktop/convert.d.ts.map +1 -0
- package/types/video/screenRecording/desktop/desktopRecorder.d.ts +28 -0
- package/types/video/screenRecording/desktop/desktopRecorder.d.ts.map +1 -0
- package/types/video/screenRecording/desktop/ffmpegRecorder.d.ts +17 -0
- package/types/video/screenRecording/desktop/ffmpegRecorder.d.ts.map +1 -0
- package/types/video/screenRecording/desktop/osx/getSPDisplaysDataType.d.ts +2 -0
- package/types/video/screenRecording/desktop/osx/getSPDisplaysDataType.d.ts.map +1 -0
- package/types/video/screenRecording/desktop/osx/getScreen.d.ts +2 -0
- package/types/video/screenRecording/desktop/osx/getScreen.d.ts.map +1 -0
- package/types/video/screenRecording/firefox/firefoxWindowRecorder.d.ts +13 -0
- package/types/video/screenRecording/firefox/firefoxWindowRecorder.d.ts.map +1 -0
- package/types/video/screenRecording/ios/convertToMp4.d.ts +2 -0
- package/types/video/screenRecording/ios/convertToMp4.d.ts.map +1 -0
- package/types/video/screenRecording/ios/iosRecorder.d.ts +14 -0
- package/types/video/screenRecording/ios/iosRecorder.d.ts.map +1 -0
- package/types/video/screenRecording/iosSimulator/convertToMp4.d.ts +2 -0
- package/types/video/screenRecording/iosSimulator/convertToMp4.d.ts.map +1 -0
- package/types/video/screenRecording/iosSimulator/recorder.d.ts +9 -0
- package/types/video/screenRecording/iosSimulator/recorder.d.ts.map +1 -0
- package/types/video/screenRecording/recorder.d.ts +7 -0
- package/types/video/screenRecording/recorder.d.ts.map +1 -0
- package/types/video/screenRecording/setOrangeBackground.d.ts +2 -0
- package/types/video/screenRecording/setOrangeBackground.d.ts.map +1 -0
- package/types/video/video.d.ts +41 -0
- package/types/video/video.d.ts.map +1 -0
- package/browsersupport/firefox-profile/cert9.db +0 -0
- package/browsersupport/firefox-profile/chrome/userChrome.css +0 -4
- package/browsersupport/firefox-profile/key4.db +0 -0
- package/vendor/mac/x86/qvh +0 -0
- package/visualmetrics/__init__.py +0 -1
- package/visualmetrics/test_data/ms_000000.png +0 -0
- package/visualmetrics/test_data/ms_000920.png +0 -0
- package/visualmetrics/test_data/ms_001000.png +0 -0
- package/visualmetrics/test_data/ms_001080.png +0 -0
- package/visualmetrics/test_data/ms_001200.png +0 -0
- package/visualmetrics/test_data/ms_001240.png +0 -0
- package/visualmetrics/test_data/ms_001280.png +0 -0
- package/visualmetrics/test_data/ms_001360.png +0 -0
- package/visualmetrics/test_data/ms_001400.png +0 -0
- package/visualmetrics/test_data/ms_001520.png +0 -0
- package/visualmetrics/test_data/ms_002040.png +0 -0
- package/visualmetrics/test_data/ms_002600.png +0 -0
- package/visualmetrics/test_data/ms_003160.png +0 -0
- package/visualmetrics/test_data/ms_003720.png +0 -0
- package/visualmetrics/test_data/ms_004280.png +0 -0
- package/visualmetrics/test_data/ms_004880.png +0 -0
- package/visualmetrics/test_data/ms_005440.png +0 -0
- package/visualmetrics/test_data/ms_006000.png +0 -0
- package/visualmetrics/test_visualmetrics.py +0 -34
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// We disable these because they are needed for code completion
|
|
2
|
+
/* eslint no-unused-vars: "off" */
|
|
3
|
+
import { Actions as SeleniumActions } from 'selenium-webdriver/lib/input.js';
|
|
4
|
+
/**
|
|
5
|
+
* This class provides an abstraction layer for Selenium's action sequence functionality.
|
|
6
|
+
* It allows for easy interaction with web elements using different locating strategies
|
|
7
|
+
* and simulating complex user gestures like mouse movements, key presses, etc.
|
|
8
|
+
*
|
|
9
|
+
* @class
|
|
10
|
+
* @hideconstructor
|
|
11
|
+
* @see https://www.selenium.dev/documentation/webdriver/actions_api/
|
|
12
|
+
* @see https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/lib/input_exports_Actions.html
|
|
13
|
+
*/
|
|
14
|
+
export class Actions {
|
|
15
|
+
constructor(browser) {
|
|
16
|
+
/**
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
this.driver = browser.getDriver();
|
|
20
|
+
/**
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
this.actions = this.driver.actions({ async: true });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
* Clears the stored actions. You need to manually clear actions, before you start a new action.
|
|
28
|
+
*
|
|
29
|
+
* @returns {Promise<void>} A promise that will be resolved when the actions have been
|
|
30
|
+
* cleared.
|
|
31
|
+
*/
|
|
32
|
+
async clear() {
|
|
33
|
+
return this.driver.actions().clear();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves the current action sequence builder.
|
|
38
|
+
* The actions builder can be used to chain multiple browser actions.
|
|
39
|
+
* @returns {SeleniumActions} The current Selenium Actions builder object for chaining browser actions.
|
|
40
|
+
* @example
|
|
41
|
+
* // Example of using the actions builder to perform a drag-and-drop operation:
|
|
42
|
+
* const elementToDrag = await commands.action.getElementByCss('.draggable');
|
|
43
|
+
* const dropTarget = await commands.action.getElementByCss('.drop-target');
|
|
44
|
+
* await commands.action.getAction()
|
|
45
|
+
* .dragAndDrop(elementToDrag, dropTarget)
|
|
46
|
+
* .perform();
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
getActions() {
|
|
50
|
+
return this.actions;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -2,18 +2,28 @@ import { By } from 'selenium-webdriver';
|
|
|
2
2
|
import intel from 'intel';
|
|
3
3
|
const log = intel.getLogger('browsertime.command.addText');
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Provides functionality to add text to elements on a web page using various selectors.
|
|
7
|
+
* @class
|
|
8
|
+
* @hideconstructor
|
|
9
|
+
*/
|
|
5
10
|
export class AddText {
|
|
6
11
|
constructor(browser) {
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
7
15
|
this.browser = browser;
|
|
8
16
|
}
|
|
9
17
|
|
|
10
18
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
15
|
-
*
|
|
16
|
-
* @
|
|
19
|
+
* Adds text to an element identified by its ID.
|
|
20
|
+
*
|
|
21
|
+
* @async
|
|
22
|
+
* @example commands.addText.byId('mytext', 'id');
|
|
23
|
+
* @param {string} text - The text string to add.
|
|
24
|
+
* @param {string} id - The ID of the element.
|
|
25
|
+
* @returns {Promise<void>} A promise that resolves when the text has been added.
|
|
26
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
17
27
|
*/
|
|
18
28
|
async byId(text, id) {
|
|
19
29
|
const driver = this.browser.getDriver();
|
|
@@ -30,12 +40,14 @@ export class AddText {
|
|
|
30
40
|
}
|
|
31
41
|
|
|
32
42
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @
|
|
36
|
-
* @
|
|
37
|
-
*
|
|
38
|
-
* @
|
|
43
|
+
* Adds text to an element identified by its XPath.
|
|
44
|
+
*
|
|
45
|
+
* @async
|
|
46
|
+
* @example commands.addText.byXpath('mytext', 'xpath');
|
|
47
|
+
* @param {string} text - The text string to add.
|
|
48
|
+
* @param {string} xpath - The XPath of the element.
|
|
49
|
+
* @returns {Promise<void>} A promise that resolves when the text has been added.
|
|
50
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
39
51
|
*/
|
|
40
52
|
async byXpath(text, xpath) {
|
|
41
53
|
const driver = this.browser.getDriver();
|
|
@@ -52,12 +64,14 @@ export class AddText {
|
|
|
52
64
|
}
|
|
53
65
|
|
|
54
66
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* @
|
|
58
|
-
* @
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
67
|
+
* Adds text to an element identified by its CSS selector.
|
|
68
|
+
*
|
|
69
|
+
* @async
|
|
70
|
+
* @example commands.addText.bySelector('mytext', 'selector');
|
|
71
|
+
* @param {string} text - The text string to add.
|
|
72
|
+
* @param {string} selector - The CSS selector of the element.
|
|
73
|
+
* @returns {Promise<void>} A promise that resolves when the text has been added.
|
|
74
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
61
75
|
*/
|
|
62
76
|
async bySelector(text, selector) {
|
|
63
77
|
const driver = this.browser.getDriver();
|
|
@@ -74,12 +88,14 @@ export class AddText {
|
|
|
74
88
|
}
|
|
75
89
|
|
|
76
90
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* @
|
|
80
|
-
* @
|
|
81
|
-
*
|
|
82
|
-
* @
|
|
91
|
+
* Adds text to an element identified by its class name.
|
|
92
|
+
*
|
|
93
|
+
* @async
|
|
94
|
+
* @example commands.addText.byClassName('mytext', 'className');
|
|
95
|
+
* @param {string} text - The text string to add.
|
|
96
|
+
* @param {string} className - The class name of the element.
|
|
97
|
+
* @returns {Promise<void>} A promise that resolves when the text has been added.
|
|
98
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
83
99
|
*/
|
|
84
100
|
async byClassName(text, className) {
|
|
85
101
|
const driver = this.browser.getDriver();
|
|
@@ -96,12 +112,14 @@ export class AddText {
|
|
|
96
112
|
}
|
|
97
113
|
|
|
98
114
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* @
|
|
102
|
-
* @
|
|
103
|
-
*
|
|
104
|
-
* @
|
|
115
|
+
* Adds text to an element identified by its name attribute.
|
|
116
|
+
*
|
|
117
|
+
* @async
|
|
118
|
+
* @example commands.addText.byName('mytext', 'name');
|
|
119
|
+
* @param {string} text - The text string to add.
|
|
120
|
+
* @param {string} name - The name attribute of the element.
|
|
121
|
+
* @returns {Promise<void>} A promise that resolves when the text has been added.
|
|
122
|
+
* @throws {Error} Throws an error if the element is not found.
|
|
105
123
|
*/
|
|
106
124
|
async byName(text, name) {
|
|
107
125
|
const driver = this.browser.getDriver();
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import intel from 'intel';
|
|
2
2
|
import { Android, isAndroidConfigured } from '../../../android/index.js';
|
|
3
3
|
const log = intel.getLogger('browsertime.command.android');
|
|
4
|
+
/**
|
|
5
|
+
* Provides functionality to interact with an Android device through shell commands.
|
|
6
|
+
* @class
|
|
7
|
+
* @see https://www.sitespeed.io/documentation/sitespeed.io/mobile-phones/#test-on-android
|
|
8
|
+
* @hideconstructor
|
|
9
|
+
*/
|
|
4
10
|
export class AndroidCommand {
|
|
5
11
|
constructor(options) {
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
6
15
|
this.options = options;
|
|
7
16
|
}
|
|
8
17
|
|
|
9
18
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
19
|
+
* Runs a shell command on the connected Android device.
|
|
20
|
+
* This method requires the Android device to be properly configured.
|
|
21
|
+
*
|
|
22
|
+
* @async
|
|
23
|
+
* @example await commands.android.shell('');
|
|
24
|
+
* @param {string} command - The shell command to run on the Android device.
|
|
25
|
+
* @returns {Promise<string>} A promise that resolves with the result of the command or rejects if there's an error.
|
|
26
|
+
* @throws {Error} Throws an error if Android is not configured or if the command fails.
|
|
14
27
|
*/
|
|
15
28
|
async shell(command) {
|
|
16
29
|
if (isAndroidConfigured(this.options)) {
|
|
@@ -24,4 +37,30 @@ export class AndroidCommand {
|
|
|
24
37
|
}
|
|
25
38
|
} else throw new Error('Android is not configured');
|
|
26
39
|
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Runs a shell command on the connected Android device as the root user.
|
|
43
|
+
* This method requires the Android device to be properly configured and that you
|
|
44
|
+
* rooted the device.
|
|
45
|
+
*
|
|
46
|
+
* @async
|
|
47
|
+
* @example await commands.android.shellAsRoot('');
|
|
48
|
+
* @param {string} command - The shell command to run on the Android device as root.
|
|
49
|
+
* @returns {Promise<string>} A promise that resolves with the result of the command or rejects if there's an error.
|
|
50
|
+
* @throws {Error} Throws an error if Android is not configured or if the command fails.
|
|
51
|
+
*/
|
|
52
|
+
async shellAsRoot(command) {
|
|
53
|
+
if (isAndroidConfigured(this.options)) {
|
|
54
|
+
log.debug('Run %s', command);
|
|
55
|
+
try {
|
|
56
|
+
this.a = new Android(this.options);
|
|
57
|
+
return this.a._runAsRootAndGet(command);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
log.error('Could not run shell command as root %s', command, error);
|
|
60
|
+
throw new Error(
|
|
61
|
+
`Could not run Android shell commmand as root ${command}`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
} else throw new Error('Android is not configured');
|
|
65
|
+
}
|
|
27
66
|
}
|
|
@@ -1,15 +1,43 @@
|
|
|
1
1
|
import intel from 'intel';
|
|
2
2
|
const log = intel.getLogger('browsertime.command.cache');
|
|
3
|
+
/**
|
|
4
|
+
* Manage the browser cache.
|
|
5
|
+
* This class provides methods to clear the cache and cookies in different browsers.
|
|
6
|
+
*
|
|
7
|
+
* @class
|
|
8
|
+
* @hideconstructor
|
|
9
|
+
*/
|
|
3
10
|
export class Cache {
|
|
4
11
|
constructor(browser, browserName, extensionServer, cdp) {
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
5
15
|
this.browser = browser;
|
|
16
|
+
/**
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
6
19
|
this.browserName = browserName;
|
|
20
|
+
/**
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
7
23
|
this.extensionServer = extensionServer;
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
8
27
|
this.cdp = cdp;
|
|
9
28
|
}
|
|
10
29
|
|
|
11
30
|
/**
|
|
12
|
-
*
|
|
31
|
+
* Clears the browser cache. This includes both cache and cookies.
|
|
32
|
+
*
|
|
33
|
+
* For Firefox, it uses the extensionServer setup with specific options.
|
|
34
|
+
* For Chrome and Edge, it uses the Chrome DevTools Protocol (CDP) commands.
|
|
35
|
+
* If the browser is not supported, logs an error message.
|
|
36
|
+
*
|
|
37
|
+
* @async
|
|
38
|
+
* @example await commands.cache.clear();
|
|
39
|
+
* @throws Will throw an error if the browser is not supported.
|
|
40
|
+
* @returns {Promise<void>} A promise that resolves when the cache and cookies are cleared.
|
|
13
41
|
*/
|
|
14
42
|
async clear() {
|
|
15
43
|
if (this.browserName === 'firefox') {
|
|
@@ -28,7 +56,16 @@ export class Cache {
|
|
|
28
56
|
}
|
|
29
57
|
|
|
30
58
|
/**
|
|
31
|
-
*
|
|
59
|
+
* Clears the browser cache while keeping the cookies.
|
|
60
|
+
*
|
|
61
|
+
* For Firefox, it uses the extensionServer setup with specific options.
|
|
62
|
+
* For Chrome and Edge, it uses the Chrome DevTools Protocol (CDP) command to clear the cache.
|
|
63
|
+
* If the browser is not supported, logs an error message.
|
|
64
|
+
*
|
|
65
|
+
* @async
|
|
66
|
+
* @example await commands.cache.clearKeepCookies();
|
|
67
|
+
* @throws Will throw an error if the browser is not supported.
|
|
68
|
+
* @returns {Promise<void>} A promise that resolves when the cache is cleared but cookies are kept.
|
|
32
69
|
*/
|
|
33
70
|
async clearKeepCookies() {
|
|
34
71
|
if (this.browserName === 'firefox') {
|
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
import intel from 'intel';
|
|
2
2
|
const log = intel.getLogger('browsertime.command.devtoolsprotocol');
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Manages interactions with the Chrome DevTools Protocol for Chrome and Edge browsers.
|
|
6
|
+
* Allows sending commands and setting up event listeners via the protocol.
|
|
7
|
+
*
|
|
8
|
+
* @class
|
|
9
|
+
* @hideconstructor
|
|
10
|
+
* @see https://chromedevtools.github.io/devtools-protocol/
|
|
11
|
+
*/
|
|
5
12
|
export class ChromeDevelopmentToolsProtocol {
|
|
6
13
|
constructor(engineDelegate, browserName) {
|
|
14
|
+
/**
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
7
17
|
this.engineDelegate = engineDelegate;
|
|
18
|
+
/**
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
8
21
|
this.browserName = browserName;
|
|
9
22
|
}
|
|
10
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Sets up an event listener for a specific DevTools Protocol event.
|
|
26
|
+
*
|
|
27
|
+
* @async
|
|
28
|
+
* @param {string} event - The name of the event to listen for.
|
|
29
|
+
* @param {Function} f - The callback function to execute when the event is triggered.
|
|
30
|
+
* @throws {Error} Throws an error if the browser is not supported or if setting the listener fails.
|
|
31
|
+
*/
|
|
11
32
|
async on(event, f) {
|
|
12
33
|
if (this.browserName === 'chrome' || this.browserName === 'edge') {
|
|
13
34
|
try {
|
|
@@ -29,6 +50,17 @@ export class ChromeDevelopmentToolsProtocol {
|
|
|
29
50
|
}
|
|
30
51
|
}
|
|
31
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Sends a command to the DevTools Protocol and returns the result.
|
|
55
|
+
*
|
|
56
|
+
* @async
|
|
57
|
+
* @example const domCounters = await commands.cdp.sendAndGet('Memory.getDOMCounters');
|
|
58
|
+
* @see https://chromedevtools.github.io/devtools-protocol/
|
|
59
|
+
* @param {string} command - The DevTools Protocol command to send.
|
|
60
|
+
* @param {Object} arguments_ - The arguments for the command.
|
|
61
|
+
* @throws {Error} Throws an error if the browser is not supported or if the command fails.
|
|
62
|
+
* @returns {Promise<Object>} The result of the command execution.
|
|
63
|
+
*/
|
|
32
64
|
async sendAndGet(command, arguments_) {
|
|
33
65
|
if (this.browserName === 'chrome' || this.browserName === 'edge') {
|
|
34
66
|
try {
|
|
@@ -51,6 +83,13 @@ export class ChromeDevelopmentToolsProtocol {
|
|
|
51
83
|
}
|
|
52
84
|
}
|
|
53
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Retrieves the raw client for the DevTools Protocol.
|
|
88
|
+
* @example const cdpClient = commands.cdp.getRawClient();
|
|
89
|
+
* @returns {Object} The raw DevTools Protocol client.
|
|
90
|
+
* @throws {Error} Throws an error if the browser is not supported.
|
|
91
|
+
* @see https://github.com/cyrus-and/chrome-remote-interface
|
|
92
|
+
*/
|
|
54
93
|
getRawClient() {
|
|
55
94
|
if (this.browserName === 'chrome' || this.browserName === 'edge') {
|
|
56
95
|
return this.engineDelegate.getCDPClient().getRawClient();
|
|
@@ -59,6 +98,17 @@ export class ChromeDevelopmentToolsProtocol {
|
|
|
59
98
|
}
|
|
60
99
|
}
|
|
61
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Sends a command to the DevTools Protocol.
|
|
103
|
+
*
|
|
104
|
+
* @async
|
|
105
|
+
* @example await commands.cdp.send('');
|
|
106
|
+
* @see https://chromedevtools.github.io/devtools-protocol/
|
|
107
|
+
* @param {string} command - The DevTools Protocol command to send.
|
|
108
|
+
* @param {Object} arguments_ - The arguments for the command.
|
|
109
|
+
* @throws {Error} Throws an error if the browser is not supported or if the command fails.
|
|
110
|
+
* @returns {Promise<void>} A promise that resolves when the command has been sent.
|
|
111
|
+
*/
|
|
62
112
|
async send(command, arguments_) {
|
|
63
113
|
if (this.browserName === 'chrome' || this.browserName === 'edge') {
|
|
64
114
|
try {
|
|
@@ -4,14 +4,40 @@ import { getRenderBlocking } from '../../../chrome/webdriver/traceUtilities.js';
|
|
|
4
4
|
import { parse } from '../../../chrome/traceCategoriesParser.js';
|
|
5
5
|
import { parseCPUTrace } from '../../../chrome/parseCpuTrace.js';
|
|
6
6
|
const log = intel.getLogger('browsertime.command.chrometrace');
|
|
7
|
+
/**
|
|
8
|
+
* Manages Chrome trace functionality, enabling custom profiling and trace collection in Chrome.
|
|
9
|
+
*
|
|
10
|
+
* @class
|
|
11
|
+
* @hideconstructor
|
|
12
|
+
*/
|
|
7
13
|
export class ChromeTrace {
|
|
8
14
|
constructor(engineDelegate, index, options, result) {
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
9
18
|
this.engineDelegate = engineDelegate;
|
|
19
|
+
/**
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
10
22
|
this.options = options;
|
|
23
|
+
/**
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
11
26
|
this.result = result;
|
|
27
|
+
/**
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
12
30
|
this.index = index;
|
|
13
31
|
}
|
|
14
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Starts the Chrome trace collection.
|
|
35
|
+
*
|
|
36
|
+
* @async
|
|
37
|
+
* @example await commands.trace.start();
|
|
38
|
+
* @returns {Promise<void>} A promise that resolves when tracing is started.
|
|
39
|
+
* @throws {Error} Throws an error if not running Chrome or if configuration is not set for custom tracing.
|
|
40
|
+
*/
|
|
15
41
|
async start() {
|
|
16
42
|
if (this.options.browser === 'chrome') {
|
|
17
43
|
if (this.options.chrome.timelineRecordingType === 'custom') {
|
|
@@ -26,6 +52,14 @@ export class ChromeTrace {
|
|
|
26
52
|
}
|
|
27
53
|
}
|
|
28
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Stops the Chrome trace collection, processes the collected data, and attaches it to the result object.
|
|
57
|
+
*
|
|
58
|
+
* @async
|
|
59
|
+
* @example await commands.trace.stop();
|
|
60
|
+
* @returns {Promise<void>} A promise that resolves when tracing is stopped and data is processed.
|
|
61
|
+
* @throws {Error} Throws an error if not running Chrome or if custom tracing was not started.
|
|
62
|
+
*/
|
|
29
63
|
async stop() {
|
|
30
64
|
if (this.options.browser === 'chrome') {
|
|
31
65
|
if (this.options.chrome.timelineRecordingType === 'custom') {
|