browsertime 16.15.0 → 16.15.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 CHANGED
@@ -1,5 +1,8 @@
1
1
  # Browsertime changelog (we do [semantic versioning](https://semver.org))
2
2
 
3
+ ## 16.15.1 - 2022-08-30
4
+ ### Fixed
5
+ * Make sure long tasks are collected direct after a test ends. On a slow device it sometimes happened that long tasks was browsertime running scripts to collect metrics [#1841](https://github.com/sitespeedio/browsertime/pull/1841).
3
6
  ## 16.15.0 - 2022-08-30
4
7
  ### Added
5
8
  * Always get the wifi name that your Android phone is using and add it to the result [#1839](https://github.com/sitespeedio/browsertime/pull/1839).
@@ -175,6 +175,39 @@ class Chromium {
175
175
  this.events = await this.cdpClient.stopTrace();
176
176
  }
177
177
 
178
+ // We get the long tasks early because on slow devices
179
+ // we want to make usre our own script isnt't picked up
180
+ let longTaskScript = `
181
+ const minLength = ${this.options.minLongTaskLength || 50};
182
+ const observer = new PerformanceObserver(list => {});
183
+ observer.observe({type: 'longtask', buffered: true});
184
+ const entries = observer.takeRecords();
185
+ const cleaned = [];
186
+ for (let event of entries) {
187
+ if (event.duration >= minLength) {
188
+ const e = {};
189
+ e.duration = event.duration;
190
+ e.name = event.name;
191
+ e.startTime = event.startTime;
192
+ e.attribution = [];
193
+ for (let at of event.attribution) {
194
+ const a = {};
195
+ a.containerId = at.containerId;
196
+ a.containerName = at.containerName;
197
+ a.containerSrc = at.containerSrc;
198
+ a.containerType = at.containerType;
199
+ e.attribution.push(a);
200
+ }
201
+ cleaned.push(e);
202
+ }
203
+ }
204
+ return cleaned;
205
+ `;
206
+ this.longTaskInfo = await runner.runScript(
207
+ longTaskScript,
208
+ 'GET_LONG_TASKS'
209
+ );
210
+
178
211
  if (this.android && this.options.androidPower) {
179
212
  result.power = await this.android.measurePowerUsage(
180
213
  this.chrome.android.package
@@ -261,6 +294,13 @@ class Chromium {
261
294
  * The URL/test is finished, all metrics are collected.
262
295
  */
263
296
  async afterEachURL(runner, index, result) {
297
+ // When we move long tasks to run direct after the test end
298
+ // we still want to keep the old structure
299
+ // this hack fixes that
300
+ if (result.browserScripts && result.browserScripts.pageinfo) {
301
+ result.browserScripts.pageinfo.longTask = this.longTaskInfo;
302
+ }
303
+
264
304
  if (this.chrome.collectNetLog && this.chrome.android) {
265
305
  // THIS needs to be unique per page
266
306
  const filename = path.join(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "description": "Browsertime",
3
- "version": "16.15.0",
3
+ "version": "16.15.1",
4
4
  "bin": "./bin/browsertime.js",
5
5
  "dependencies": {
6
6
  "@cypress/xvfb": "1.2.4",
@@ -33,7 +33,7 @@
33
33
  "jimp": "0.16.1"
34
34
  },
35
35
  "devDependencies": {
36
- "ava": "4.2.0",
36
+ "ava": "4.3.3",
37
37
  "eslint": "8.14.0",
38
38
  "eslint-config-prettier": "8.5.0",
39
39
  "eslint-plugin-prettier": "4.0.0",
@@ -1,29 +0,0 @@
1
- (function(minLength) {
2
- const supported = PerformanceObserver.supportedEntryTypes;
3
- if (!supported || supported.indexOf('longtask') === -1) {
4
- return;
5
- }
6
- const observer = new PerformanceObserver(list => {});
7
- observer.observe({type: 'longtask', buffered: true});
8
- const entries = observer.takeRecords();
9
- const cleaned = [];
10
- for (let event of entries) {
11
- if (event.duration >= minLength) {
12
- const e = {};
13
- e.duration = event.duration;
14
- e.name = event.name;
15
- e.startTime = event.startTime;
16
- e.attribution = [];
17
- for (let at of event.attribution) {
18
- const a = {};
19
- a.containerId = at.containerId;
20
- a.containerName = at.containerName;
21
- a.containerSrc = at.containerSrc;
22
- a.containerType = at.containerType;
23
- e.attribution.push(a);
24
- }
25
- cleaned.push(e);
26
- }
27
- }
28
- return cleaned;
29
- })(arguments[arguments.length - 1]);