browsertime 22.5.5 → 22.7.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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # Browsertime changelog (we do [semantic versioning](https://semver.org))
2
2
 
3
+ ## 22.7.0 - 2024-07-25
4
+ ### Added
5
+ * Updated to Chrome and Chromedriover 127 [#2164](https://github.com/sitespeedio/browsertime/pull/2164).
6
+
7
+ ### Fixed
8
+ * Updated to Selenium 4.23.0 [#2161](https://github.com/sitespeedio/browsertime/pull/2161).
9
+ * Add extra check if the HAR file page misses an URL [#2160](https://github.com/sitespeedio/browsertime/pull/2160).
10
+
11
+ ## 22.6.0 - 2024-07-15
12
+ ### Added
13
+ * Updated to Firefox 128 and Edge 126 in the Docker container [#2158](https://github.com/sitespeedio/browsertime/pull/2158).
14
+ * Add request header using Bidi for Firefox (needs Firefox 128 or later) [#2108](https://github.com/sitespeedio/browsertime/pull/2108).
15
+
16
+ ### Fixed
17
+ * Updated to Chrome HAR 0.13.5 [#2157](https://github.com/sitespeedio/browsertime/pull/2157)
18
+
3
19
  ## 22.5.5 - 2024-07-07
4
20
  ### Fixed
5
21
  * Fix stopping --tcpdump [#2155](https://github.com/sitespeedio/browsertime/pull/2155).
@@ -344,7 +344,13 @@ export class Engine {
344
344
  ) {
345
345
  const fullyLoadedPerUrl = getFullyLoaded(extras.har);
346
346
  for (let data of fullyLoadedPerUrl) {
347
- collector.addFullyLoaded(data.url, data.fullyLoaded);
347
+ if (data.url === undefined) {
348
+ log.error(
349
+ 'There is an page without an URL in the HAR. Please inspect the HAR file and check whats wrong'
350
+ );
351
+ } else {
352
+ collector.addFullyLoaded(data.url, data.fullyLoaded);
353
+ }
348
354
  }
349
355
 
350
356
  // Add the timings from the main document
@@ -78,6 +78,7 @@ export class FirefoxBidi {
78
78
  }
79
79
  });
80
80
  }
81
+
81
82
  async setBasicAuth(basicAuth) {
82
83
  const parts = basicAuth.split('@');
83
84
  const bidi = new Bidi(this.driver, this.options.browser);
@@ -146,4 +147,52 @@ export class FirefoxBidi {
146
147
  }
147
148
  }
148
149
  }
150
+
151
+ async setRequestHeaders(requestHeaders) {
152
+ const headersArray = toArray(requestHeaders);
153
+ const headers = [];
154
+ for (let header of headersArray) {
155
+ if (header.indexOf && header.includes(':')) {
156
+ const parts = header.split(':');
157
+ headers.push({
158
+ name: parts[0],
159
+ value: {
160
+ type: 'string',
161
+ value: parts[1]
162
+ }
163
+ });
164
+ } else {
165
+ log.error(
166
+ 'Request headers need to be of the format key:value not ' + header
167
+ );
168
+ }
169
+ }
170
+
171
+ const command = {
172
+ method: 'network.addIntercept',
173
+ params: {
174
+ phases: ['beforeRequestSent']
175
+ }
176
+ };
177
+ const bidi = new Bidi(this.driver, this.options.browser);
178
+
179
+ await bidi.send(command);
180
+ await bidi.subscribe('network.beforeRequestSent');
181
+ await bidi.onMessage(async function (event) {
182
+ const parsedEvent = JSON.parse(Buffer.from(event.toString()));
183
+ if (parsedEvent.method === 'network.beforeRequestSent') {
184
+ const continueRequest = {
185
+ method: 'network.continueRequest',
186
+ params: {
187
+ request: parsedEvent.params.request.request,
188
+ headers: [...parsedEvent.params.request.headers, ...headers]
189
+ }
190
+ };
191
+ const result = await bidi.send(continueRequest);
192
+ if (result.type != 'success') {
193
+ log.error(result);
194
+ }
195
+ }
196
+ });
197
+ }
149
198
  }
@@ -102,22 +102,25 @@ export class Firefox {
102
102
  await this.browsertimeBidi.setBasicAuth(this.options.basicAuth);
103
103
  }
104
104
 
105
- if (this.options.block) {
106
- await this.browsertimeBidi.blockUrls(this.options.block);
107
- }
105
+ if (this.options.requestheader) {
106
+ await this.browsertimeBidi.setRequestHeaders(this.options.requestheader);
107
+ if (this.options.block) {
108
+ await this.browsertimeBidi.blockUrls(this.options.block);
109
+ }
108
110
 
109
- if (
110
- this.firefoxConfig.appendToUserAgent ||
111
- this.options.appendToUserAgent
112
- ) {
113
- const currentUserAgent = await runner.runScript(
114
- 'return navigator.userAgent;',
115
- 'GET_USER_AGENT'
116
- );
117
- let script = `Services.prefs.setStringPref('general.useragent.override', '${currentUserAgent} ${
118
- this.firefoxConfig.appendToUserAgent || this.options.appendToUserAgent
119
- }');`;
120
- return runner.runPrivilegedScript(script, 'SET_USER_AGENT');
111
+ if (
112
+ this.firefoxConfig.appendToUserAgent ||
113
+ this.options.appendToUserAgent
114
+ ) {
115
+ const currentUserAgent = await runner.runScript(
116
+ 'return navigator.userAgent;',
117
+ 'GET_USER_AGENT'
118
+ );
119
+ let script = `Services.prefs.setStringPref('general.useragent.override', '${currentUserAgent} ${
120
+ this.firefoxConfig.appendToUserAgent || this.options.appendToUserAgent
121
+ }');`;
122
+ return runner.runPrivilegedScript(script, 'SET_USER_AGENT');
123
+ }
121
124
  }
122
125
  }
123
126
 
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "browsertime",
3
3
  "description": "Get performance metrics from your web page using Browsertime.",
4
- "version": "22.5.5",
4
+ "version": "22.7.0",
5
5
  "bin": "./bin/browsertime.js",
6
6
  "type": "module",
7
7
  "types": "./types/scripting.d.ts",
8
8
  "dependencies": {
9
9
  "@cypress/xvfb": "1.2.4",
10
10
  "@devicefarmer/adbkit": "3.2.6",
11
- "@sitespeed.io/chromedriver": "126.0.6478-55 ",
11
+ "@sitespeed.io/chromedriver": "127.0.6533-72",
12
12
  "@sitespeed.io/edgedriver": "125.0.2535-47",
13
13
  "@sitespeed.io/geckodriver": "0.34.0",
14
14
  "@sitespeed.io/throttle": "5.0.0",
15
15
  "@sitespeed.io/tracium": "0.3.3",
16
16
  "btoa": "1.2.1",
17
- "chrome-har": "0.13.3",
17
+ "chrome-har": "0.13.5",
18
18
  "chrome-remote-interface": "0.33.2",
19
19
  "dayjs": "1.11.11",
20
20
  "execa": "9.3.0",
@@ -30,7 +30,7 @@
30
30
  "lodash.merge": "4.6.2",
31
31
  "lodash.pick": "4.4.0",
32
32
  "lodash.set": "4.3.2",
33
- "selenium-webdriver": "4.22.0",
33
+ "selenium-webdriver": "4.23.0",
34
34
  "usb-power-profiling": "^1.2.0",
35
35
  "yargs": "17.7.2"
36
36
  },