browsertime 14.13.1 → 14.14.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,11 @@
1
1
  # Browsertime changelog (we do [semantic versioning](https://semver.org))
2
2
 
3
+ ## 14.14.0 - 2022-01-10
4
+ ### Added
5
+ * Add support for [Humble](https://calendar.perfplanet.com/2021/introducing-humble-the-raspberry-pi-wifi-network-link-conditioner/) as connectivity engine for mobile phone testing. Make sure to setup Humble on a Raspberry Pi 4 and the choose engine with `--connectivity.engine humble` and set the URL to your instance `--connectivity.humble.url http://raspberrypi.local:3000`. Added in [#1691](https://github.com/sitespeedio/browsertime/pull/1691).
6
+ * Upgraded to Chrome 97, Edge 97 and Firefox 95 in the Docker container.
7
+ * Upgraded to Chromedriver 97.
8
+
3
9
  ## 14.13.1 - 2022-01-01
4
10
  ### Fixed
5
11
  * Added missing `--chrome.appendToUserAgent` in the CLI help.
@@ -228,6 +228,15 @@ class Android {
228
228
  return this._runCommand('input keyevent KEYCODE_POWER');
229
229
  }
230
230
 
231
+ async getWifi() {
232
+ const rawWifiInfo = await this._runCommand(
233
+ `dumpsys netstats | grep -E 'iface=wlan.*networkId'`
234
+ );
235
+ const wifiInfo = (await adb.util.readAll(rawWifiInfo)).toString().trim();
236
+ const wifi = wifiInfo.match(/(?:"[^"]*"|^[^"]*$)/)[0].replace(/"/g, '');
237
+ return wifi;
238
+ }
239
+
231
240
  async closeAppNotRespondingPopup() {
232
241
  const result = await this._runCommandAndGet('dumpsys window windows');
233
242
  if (result.indexOf('Application Not Responding') > -1) {
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ const http = require('http');
4
+ const https = require('https');
5
+ const get = require('lodash.get');
6
+ const log = require('intel').getLogger('browsertime.connectivity.humble');
7
+
8
+ class Humble {
9
+ constructor(options) {
10
+ this.url = get(options.connectivity, 'humble.url');
11
+ this.profile = options.connectivity.profile;
12
+ }
13
+
14
+ async start(profile) {
15
+ const lib = this.url.startsWith('https') ? https : http;
16
+ const res = await new Promise(resolve => {
17
+ if (this.profile !== 'custom') {
18
+ lib.get(`${this.url}/api/${this.profile}`, resolve);
19
+ } else {
20
+ lib.get(
21
+ `${this.url}/api/custom?up=${profile.up}&down=${profile.down}&rtt=${profile.rtt}`,
22
+ resolve
23
+ );
24
+ }
25
+ });
26
+
27
+ let data = await new Promise((resolve, reject) => {
28
+ let data = '';
29
+ res.on('data', chunk => (data += chunk));
30
+ res.on('error', err => reject(err));
31
+ res.on('end', () => resolve(data));
32
+ });
33
+
34
+ if (res.statusCode !== 200) {
35
+ log.error('Humble response: %s', data);
36
+ } else {
37
+ log.info('Switch Humble at %s to use profile %s', this.url, this.profile);
38
+ }
39
+ }
40
+
41
+ async stop() {
42
+ const lib = this.url.startsWith('https') ? https : http;
43
+ const res = await new Promise(resolve => {
44
+ lib.get(`${this.url}/api/stop`, resolve);
45
+ });
46
+
47
+ let data = await new Promise((resolve, reject) => {
48
+ let data = '';
49
+ res.on('data', chunk => (data += chunk));
50
+ res.on('error', err => reject(err));
51
+ res.on('end', () => resolve(data));
52
+ });
53
+
54
+ if (res.statusCode !== 200) {
55
+ log.error('Humble response: %s', data);
56
+ } else {
57
+ log.info('Humble throttling stopped successfully');
58
+ }
59
+ }
60
+ }
61
+
62
+ module.exports = Humble;
@@ -5,8 +5,10 @@ const get = require('lodash.get');
5
5
  const throttle = require('@sitespeed.io/throttle');
6
6
  const log = require('intel').getLogger('browsertime.connectivity');
7
7
  const TSProxy = require('./tsProxy');
8
+ const Humble = require('./humble');
8
9
 
9
10
  let tsProxyInstance = null;
11
+ let humble = null;
10
12
 
11
13
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
12
14
  function getRandomIntInclusive(min, max) {
@@ -73,6 +75,10 @@ module.exports = {
73
75
  tsProxyInstance = new TSProxy(options);
74
76
  return tsProxyInstance.start(profile);
75
77
  }
78
+ case 'humble': {
79
+ humble = new Humble(options);
80
+ return humble.start(profile);
81
+ }
76
82
  }
77
83
  },
78
84
  getConnectivitySettings(options) {
@@ -96,6 +102,9 @@ module.exports = {
96
102
  case 'tsproxy': {
97
103
  return tsProxyInstance.stop();
98
104
  }
105
+ case 'humble': {
106
+ return humble.stop();
107
+ }
99
108
  }
100
109
  }
101
110
  };
@@ -180,6 +180,14 @@ class Engine {
180
180
  log.info('Battery temperature is %s, lets start the tests', temp);
181
181
  }
182
182
  }
183
+
184
+ if (
185
+ this.options.connectivity &&
186
+ this.options.connectivity.engine === 'humble'
187
+ ) {
188
+ const wifiName = await android.getWifi();
189
+ log.info('The phone is using the WiFi: %s', wifiName);
190
+ }
183
191
  }
184
192
 
185
193
  if (this.options.safari && this.options.safari.useSimulator) {
@@ -93,6 +93,12 @@ function validateInput(argv) {
93
93
  }
94
94
  }
95
95
 
96
+ if (argv.connectivity && argv.connectivity.engine === 'humble') {
97
+ if (!argv.connectivity.humble || !argv.connectivity.humble.url) {
98
+ return 'You need to specify the URL to Humble by using the --connectivity.humble.url option.';
99
+ }
100
+ }
101
+
96
102
  if (
97
103
  argv.firefox &&
98
104
  ((argv.firefox.nightly && argv.firefox.beta) ||
@@ -932,9 +938,9 @@ module.exports.parseCommandLine = function parseCommandLine() {
932
938
  })
933
939
  .option('connectivity.engine', {
934
940
  default: 'external',
935
- choices: ['external', 'throttle', 'tsproxy'],
941
+ choices: ['external', 'throttle', 'tsproxy', 'humble'],
936
942
  describe:
937
- 'The engine for connectivity. Throttle works on Mac and tc based Linux. Use external if you set the connectivity outside of Browsertime. The best way do to this is described in https://github.com/sitespeedio/browsertime#connectivity.',
943
+ 'The engine for connectivity. Throttle works on Mac and tc based Linux. For mobile you can use Humble if you have a Humble setup. Use external if you set the connectivity outside of Browsertime. The best way do to this is described in https://github.com/sitespeedio/browsertime#connectivity.',
938
944
  group: 'connectivity'
939
945
  })
940
946
  .option('connectivity.throttle.localhost', {
@@ -944,6 +950,12 @@ module.exports.parseCommandLine = function parseCommandLine() {
944
950
  'Add latency/delay on localhost. Perfect for testing with WebPageReplay',
945
951
  group: 'connectivity'
946
952
  })
953
+ .option('connectivity.humble.url', {
954
+ type: 'string',
955
+ describe:
956
+ 'The path to your Humble instance. For example http://raspberrypi:3000',
957
+ group: 'connectivity'
958
+ })
947
959
  .option('requestheader', {
948
960
  alias: 'r',
949
961
  describe:
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "description": "Browsertime",
3
- "version": "14.13.1",
3
+ "version": "14.14.0",
4
4
  "bin": "./bin/browsertime.js",
5
5
  "dependencies": {
6
6
  "@sitespeed.io/throttle": "3.0.0",
7
7
  "@devicefarmer/adbkit": "2.11.3",
8
8
  "btoa": "1.2.1",
9
- "@sitespeed.io/chromedriver": "96.0.4664-35",
9
+ "@sitespeed.io/chromedriver": "97.0.4692-71",
10
10
  "chrome-har": "0.12.0",
11
11
  "chrome-remote-interface": "0.31.0",
12
12
  "dayjs": "1.10.7",