browsertime 15.0.0 → 15.1.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,17 @@
1
1
  # Browsertime changelog (we do [semantic versioning](https://semver.org))
2
2
 
3
+ ## 15.1.1 - 2022-02-24
4
+ ### Fixed
5
+ * Updated Chromedriver dependency that fixes installation on M1 and [some send keys issues](https://chromedriver.storage.googleapis.com/98.0.4758.102/notes.txt).
6
+ ## 15.1.0 - 2022-02-24
7
+ ### Added
8
+ * Collect timings from main document. The result includes a field named mainDocumentTimings and contains blocked, dns, connect, send, wait, receive, ssl as long as you get a HAR file from the browser [#1735](https://github.com/sitespeedio/browsertime/pull/1735).
9
+
10
+ ### Tech
11
+ * Cleaned the DNS flush code [#1734](https://github.com/sitespeedio/browsertime/pull/1734).
12
+ ## 15.0.1 - 2022-02-21
13
+ ### Fixed
14
+ * Make sure connectivity is only set before the test begins [#1733](https://github.com/sitespeedio/browsertime/pull/1733).
3
15
  ## 15.0.0 - 2022-02-20
4
16
  ### Changed
5
17
  * Removed the built in support for TSProxy [#1718](https://github.com/sitespeedio/browsertime/pull/1718). TSProxy only worked with Python 2.7 and we want to remove that dependency.
@@ -47,6 +47,7 @@ function getNewResult(url, options) {
47
47
  googleWebVitals: [],
48
48
  extras: [],
49
49
  fullyLoaded: [],
50
+ mainDocumentTimings: [],
50
51
  errors: []
51
52
  };
52
53
  }
@@ -114,6 +115,23 @@ class Collector {
114
115
  }
115
116
  }
116
117
 
118
+ addMainDocumentTimings(url, timings) {
119
+ const statistics =
120
+ this.allStats[url] || this.allStats[this.urlAndActualUrl[url]];
121
+ const results =
122
+ this.allResults[url] || this.allResults[this.urlAndActualUrl[url]];
123
+ if (results) {
124
+ results.mainDocumentTimings.push(timings);
125
+ }
126
+ if (timings && statistics) {
127
+ statistics.addDeep({
128
+ timings: {
129
+ mainDocumentTimings: timings
130
+ }
131
+ });
132
+ }
133
+ }
134
+
117
135
  /**
118
136
  * Collect all individual runs, add it to the statistics, and store
119
137
  * data that needs to be on disk (trace logs, sceenshots etc).
@@ -297,6 +297,11 @@ class Engine {
297
297
  for (let data of fullyLoadedPerUrl) {
298
298
  collector.addFullyLoaded(data.url, data.fullyLoaded);
299
299
  }
300
+ // Add the timings from the main document
301
+ const timings = harUtil.getMainDocumentTimings(extras.har);
302
+ for (let timing of timings) {
303
+ collector.addMainDocumentTimings(timing.url, timing.timings);
304
+ }
300
305
  }
301
306
 
302
307
  const totalResult = collector.getResults();
@@ -105,7 +105,9 @@ class Iteration {
105
105
  if (!options.disableDNSFlush === true) {
106
106
  await flushDNS(options);
107
107
  }
108
- await addConnectivity(options);
108
+ if (options.connectivity && options.connectivity.variance) {
109
+ await addConnectivity(options);
110
+ }
109
111
 
110
112
  await engineDelegate.beforeBrowserStart();
111
113
  await browser.start();
@@ -3,6 +3,7 @@
3
3
  const execa = require('execa');
4
4
  const log = require('intel').getLogger('browsertime.dns');
5
5
  const { isAndroidConfigured } = require('../android');
6
+
6
7
  module.exports = async function (options) {
7
8
  if (isAndroidConfigured(options)) {
8
9
  return;
@@ -13,32 +14,26 @@ module.exports = async function (options) {
13
14
  }
14
15
 
15
16
  if (process.platform === 'darwin') {
16
- try {
17
- await execa('sudo', ['killall', '-HUP', 'mDNSResponder'], {
18
- reject: false
19
- });
20
- await execa('sudo', ['dscacheutil', '-flushcache'], {
21
- reject: false
22
- });
23
- return execa('sudo', ['lookupd', '-flushcache'], {
24
- reject: false
25
- });
26
- } catch (err) {
27
- log.error('Could not flush dns cache', err);
28
- }
17
+ log.debug('Flush DNS cache on MacOS');
18
+ await execa('sudo', ['killall', '-HUP', 'mDNSResponder'], {
19
+ reject: false
20
+ });
21
+ await execa('sudo', ['dscacheutil', '-flushcache'], {
22
+ reject: false
23
+ });
24
+ return execa('sudo', ['lookupd', '-flushcache'], {
25
+ reject: false
26
+ });
29
27
  } else if (process.platform === 'linux') {
30
- try {
31
- await execa('sudo', ['service', 'dnsmasq', 'restart'], {
32
- reject: false
33
- });
34
- await execa('sudo', ['rndc', 'restart'], {
35
- reject: false
36
- });
37
- return execa('sudo', ['systemd-resolve', '--flush-caches'], {
38
- reject: false
39
- });
40
- } catch (err) {
41
- log.error('Could not flush dns cache', err);
42
- }
28
+ log.debug('Flush DNS cache on Linux');
29
+ await execa('sudo', ['systemd-resolve', '--flush-caches'], {
30
+ reject: false
31
+ });
32
+ await execa('sudo', ['service', 'dnsmasq', 'restart'], {
33
+ reject: false
34
+ });
35
+ await execa('sudo', ['rndc', 'restart'], {
36
+ reject: false
37
+ });
43
38
  }
44
39
  };
@@ -18,6 +18,30 @@ function generateUniquePageId(baseId, existingIdMap) {
18
18
  return newId;
19
19
  }
20
20
 
21
+ function getDocumentRequests(entries, pageId) {
22
+ let pageEntries = Array.from(entries);
23
+ if (pageId) {
24
+ pageEntries = Array.from(entries.filter(entry => entry.pageref === pageId));
25
+ }
26
+
27
+ const requests = [];
28
+ let entry;
29
+
30
+ do {
31
+ entry = pageEntries.shift();
32
+ requests.push(entry);
33
+ } while (entry.response.redirectURL);
34
+
35
+ return requests;
36
+ }
37
+
38
+ function getFinalURL(entries, pageref) {
39
+ const requests = getDocumentRequests(entries, pageref);
40
+
41
+ const finalEntry = requests.pop();
42
+ return finalEntry.request.url;
43
+ }
44
+
21
45
  function addExtrasToHAR(
22
46
  harPage,
23
47
  visualMetricsData,
@@ -160,6 +184,27 @@ module.exports = {
160
184
  return har;
161
185
  },
162
186
 
187
+ getMainDocumentTimings: function (har) {
188
+ const timings = [];
189
+ const entries = Array.from(har.log.entries);
190
+
191
+ for (let page of har.log.pages) {
192
+ const pageId = page.id;
193
+ const url = page._url;
194
+
195
+ let pageEntries = Array.from(entries);
196
+ const finalURL = getFinalURL(pageEntries, pageId);
197
+
198
+ pageEntries = Array.from(
199
+ pageEntries.filter(
200
+ entry => entry.pageref === pageId && entry.request.url === finalURL
201
+ )
202
+ );
203
+
204
+ timings.push({ url, timings: pageEntries[0].timings });
205
+ }
206
+ return timings;
207
+ },
163
208
  getFullyLoaded: function (har) {
164
209
  const fullyLoaded = [];
165
210
  const entries = Array.from(har.log.entries);
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "description": "Browsertime",
3
- "version": "15.0.0",
3
+ "version": "15.1.1",
4
4
  "bin": "./bin/browsertime.js",
5
5
  "dependencies": {
6
6
  "@cypress/xvfb": "1.2.4",
7
7
  "@devicefarmer/adbkit": "2.11.3",
8
- "@sitespeed.io/chromedriver": "98.0.4758-48b",
8
+ "@sitespeed.io/chromedriver": "98.0.4758-102b",
9
9
  "@sitespeed.io/edgedriver": "98.0.1108-43",
10
10
  "@sitespeed.io/geckodriver": "0.30.0",
11
11
  "@sitespeed.io/throttle": "3.0.0",