browsertime 14.14.1 → 14.15.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,8 @@
1
1
  # Browsertime changelog (we do [semantic versioning](https://semver.org))
2
2
 
3
+ ## 14.15.0 - 2022-01-12
4
+ ### Added
5
+ * Added so you can append a String to Firefox User Agent [#1694](https://github.com/sitespeedio/browsertime/pull/1694), thank you [Henrik Skupin](https://github.com/whimboo) for pointing me in the right direction. With [#1695](https://github.com/sitespeedio/browsertime/pull/1695) we now have `--appendToUserAgent` that works in Chrome/Edge and Firefox.
3
6
  ## 14.14.1 - 2022-01-12
4
7
  ### Fixed
5
8
  * Updated Chromedriver library that pickup already installed driver on Raspberry Pis. This makes it easier to run tests on an Android device from a Raspberry Pi.
@@ -105,13 +105,15 @@ class Chromium {
105
105
  await this.cdpClient.setupCPUThrottling(this.chrome.CPUThrottlingRate);
106
106
  }
107
107
 
108
- if (this.chrome.appendToUserAgent) {
108
+ if (this.chrome.appendToUserAgent || this.options.appendToUserAgent) {
109
109
  const currentUserAgent = await runner.runScript(
110
110
  'return navigator.userAgent;',
111
111
  'GET_USER_AGENT'
112
112
  );
113
113
  await this.cdpClient.setUserAgent(
114
- currentUserAgent + ' ' + this.chrome.appendToUserAgent
114
+ currentUserAgent +
115
+ ' ' +
116
+ (this.chrome.appendToUserAgent || this.options.appendToUserAgent)
115
117
  );
116
118
  } else if (this.chrome.mobileEmulation && this.options.userAgent) {
117
119
  // Hack to set user agent for mobile emulation
@@ -55,7 +55,21 @@ class Firefox {
55
55
  /**
56
56
  * Before the first iteration of your tests start.
57
57
  */
58
- async beforeStartIteration() {}
58
+ async beforeStartIteration(runner) {
59
+ if (
60
+ this.firefoxConfig.appendToUserAgent ||
61
+ this.options.appendToUserAgent
62
+ ) {
63
+ const currentUserAgent = await runner.runScript(
64
+ 'return navigator.userAgent;',
65
+ 'GET_USER_AGENT'
66
+ );
67
+ let script = `Services.prefs.setStringPref('general.useragent.override', '${currentUserAgent} ${
68
+ this.firefoxConfig.appendToUserAgent || this.options.appendToUserAgent
69
+ }');`;
70
+ return runner.runPrivilegedScript(script, 'SET_USER_AGENT');
71
+ }
72
+ }
59
73
 
60
74
  /**
61
75
  * Before each URL/test runs.
@@ -361,6 +361,11 @@ module.exports.parseCommandLine = function parseCommandLine() {
361
361
  group: 'firefox'
362
362
  })
363
363
 
364
+ .option('firefox.appendToUserAgent', {
365
+ type: 'string',
366
+ describe: 'Append to the user agent.',
367
+ group: 'firefox'
368
+ })
364
369
  .option('firefox.nightly', {
365
370
  describe:
366
371
  'Use Firefox Nightly. Works on OS X. For Linux you need to set the binary path.',
@@ -1019,6 +1024,10 @@ module.exports.parseCommandLine = function parseCommandLine() {
1019
1024
  .option('userAgent', {
1020
1025
  describe: 'Override user agent'
1021
1026
  })
1027
+ .option('appendToUserAgent', {
1028
+ describe:
1029
+ 'Append a String to the user agent. Works in Chrome/Edge and Firefox.'
1030
+ })
1022
1031
  .option('silent', {
1023
1032
  alias: 'q',
1024
1033
  type: 'count',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "description": "Browsertime",
3
- "version": "14.14.1",
3
+ "version": "14.15.0",
4
4
  "bin": "./bin/browsertime.js",
5
5
  "dependencies": {
6
6
  "@sitespeed.io/throttle": "3.0.0",