@eyeo/get-browser-binary 0.12.0 → 0.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/.gitlab-ci.yml +2 -2
- package/README.md +41 -19
- package/RELEASE_NOTES.md +40 -0
- package/index.js +19 -2
- package/package.json +7 -4
- package/src/browser.js +134 -0
- package/src/chromium.js +336 -0
- package/src/edge.js +308 -0
- package/src/firefox.js +216 -0
- package/src/utils.js +43 -0
- package/test/browsers.js +69 -40
- package/test/docker/Dockerfile +1 -1
- package/test/docker/arm64.Dockerfile +7 -2
- package/test/extension/mv3/manifest.json +2 -1
- package/test/pages/basic.html +1 -0
- package/test/pages/download-test.txt +1 -0
- package/test/pages/long.html +41 -0
- package/test/runner.js +74 -0
- package/test/start-server.js +20 -0
- package/test/test-server.js +37 -0
- package/test/utils.js +5 -4
- package/src/browsers.js +0 -919
package/.gitlab-ci.yml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
default:
|
|
2
|
-
image: registry.gitlab.com/eyeo/docker/get-browser-binary:
|
|
2
|
+
image: registry.gitlab.com/eyeo/docker/get-browser-binary:node18
|
|
3
3
|
interruptible: true
|
|
4
4
|
|
|
5
5
|
stages:
|
|
@@ -48,7 +48,7 @@ test:browsers:windows:
|
|
|
48
48
|
-OutFile 'MicrosoftEdgeEnterpriseX64.msi'
|
|
49
49
|
- Start-Process msiexec
|
|
50
50
|
-ArgumentList "/i MicrosoftEdgeEnterpriseX64.msi /norestart /qn" -Wait
|
|
51
|
-
- choco upgrade -y nodejs --version
|
|
51
|
+
- choco upgrade -y --no-progress nodejs --version 18.17.1
|
|
52
52
|
- npm install
|
|
53
53
|
script:
|
|
54
54
|
# Running Edge tests only on the preinstalled version
|
package/README.md
CHANGED
|
@@ -30,20 +30,25 @@ the right side.
|
|
|
30
30
|
|
|
31
31
|
### Supported browser versions
|
|
32
32
|
|
|
33
|
-
- Chromium >=
|
|
34
|
-
- Firefox >=
|
|
33
|
+
- Chromium >= 77 (Chromium ARM >= 92)
|
|
34
|
+
- Firefox >= 68
|
|
35
35
|
- Edge >= 95
|
|
36
36
|
|
|
37
37
|
Note: Installing Edge is not supported on Windows. It is assumed to be installed
|
|
38
38
|
because it is the default browser on that platform. On macOS, only the latest
|
|
39
39
|
Edge version is supported.
|
|
40
40
|
|
|
41
|
+
### Verbose logging
|
|
42
|
+
|
|
43
|
+
Set the `VERBOSE` environment variable to `"true"` to get verbose logging on
|
|
44
|
+
download requests.
|
|
45
|
+
|
|
41
46
|
## Development
|
|
42
47
|
|
|
43
48
|
### Prerequisites
|
|
44
49
|
|
|
45
|
-
- Node >=
|
|
46
|
-
- npm >=
|
|
50
|
+
- Node >= 18
|
|
51
|
+
- npm >= 9
|
|
47
52
|
|
|
48
53
|
### Installing/Updating dependencies
|
|
49
54
|
|
|
@@ -70,6 +75,8 @@ Running all tests:
|
|
|
70
75
|
npm test
|
|
71
76
|
```
|
|
72
77
|
|
|
78
|
+
### Options
|
|
79
|
+
|
|
73
80
|
The `grep` option filters the tests to run with a regular expression. Example:
|
|
74
81
|
|
|
75
82
|
```shell
|
|
@@ -83,6 +90,29 @@ Increasing the timeout may be useful on slow connection environments:
|
|
|
83
90
|
npm test -- --timeout <ms>
|
|
84
91
|
```
|
|
85
92
|
|
|
93
|
+
By default, tests delete the `./browser-snapshots` before each `Browser` suite
|
|
94
|
+
runs. To change that behavior you may set the `TEST_KEEP_SNAPSHOTS` environment
|
|
95
|
+
variable to `true`. Example:
|
|
96
|
+
|
|
97
|
+
```shell
|
|
98
|
+
TEST_KEEP_SNAPSHOTS=true npm test
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Test server
|
|
102
|
+
|
|
103
|
+
Tests use a local http server, which is managed by the `npm test` command. If
|
|
104
|
+
needed, the test server can also run independently:
|
|
105
|
+
|
|
106
|
+
```shell
|
|
107
|
+
npm run test-server
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Then tests may be executed on a separate session. Example:
|
|
111
|
+
|
|
112
|
+
```shell
|
|
113
|
+
npm run test-suite -- --grep "chromium.*latest"
|
|
114
|
+
```
|
|
115
|
+
|
|
86
116
|
### Running tests on Docker
|
|
87
117
|
|
|
88
118
|
Useful to reproduce the CI environment of the `test:browsers:linux` job.
|
|
@@ -101,32 +131,24 @@ parameter:
|
|
|
101
131
|
docker run --shm-size=512m -e TEST_ARGS="--grep chromium.*latest --timeout 100000" -it browsers
|
|
102
132
|
```
|
|
103
133
|
|
|
104
|
-
By default, tests delete the `./browser-snapshots` before each `Browser` suite
|
|
105
|
-
runs. To change that behavior you may set the `TEST_KEEP_SNAPSHOTS` environment
|
|
106
|
-
variable to `true`. Example:
|
|
107
|
-
|
|
108
|
-
```shell
|
|
109
|
-
TEST_KEEP_SNAPSHOTS=true npm test
|
|
110
|
-
```
|
|
111
|
-
|
|
112
134
|
#### ARM architecture (M1/M2 Apple Silicon)
|
|
113
135
|
|
|
114
|
-
Chromium (ARM native):
|
|
115
|
-
|
|
116
136
|
```shell
|
|
117
137
|
docker build -f test/docker/arm64.Dockerfile -t browsers-arm .
|
|
118
|
-
docker run --shm-size=512m -e TEST_ARGS="--grep chromium.*latest" -it browsers-arm
|
|
138
|
+
docker run --shm-size=512m -e TEST_ARGS="--grep (chromium|firefox).*latest" -it browsers-arm
|
|
119
139
|
```
|
|
120
140
|
|
|
121
|
-
Firefox
|
|
141
|
+
Only latest Chromium and latest Firefox ESR versions are supported. Edge is not
|
|
142
|
+
supported.
|
|
143
|
+
|
|
144
|
+
Regarding Firefox, it may be possible to run other versions using AMD emulation
|
|
145
|
+
(unstable results):
|
|
122
146
|
|
|
123
147
|
```shell
|
|
124
148
|
docker build -f test/docker/Dockerfile -t browsers-amd .
|
|
125
|
-
docker run --platform linux/amd64 --shm-size=512m -e TEST_ARGS="--grep firefox.*
|
|
149
|
+
docker run --platform linux/amd64 --shm-size=512m -e TEST_ARGS="--grep firefox.*68.0" -it browsers-amd
|
|
126
150
|
```
|
|
127
151
|
|
|
128
|
-
Edge: Not supported
|
|
129
|
-
|
|
130
152
|
## Building the documentation
|
|
131
153
|
|
|
132
154
|
```shell
|
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
# 0.14.0
|
|
2
|
+
|
|
3
|
+
- Increases minimum supported browser versions (#64)
|
|
4
|
+
- Sets a minimum supported version for Chromium ARM (#54)
|
|
5
|
+
- Upgrades minimum node version to node 18 (#63)
|
|
6
|
+
- Fixes an occasional issue where the latest Edge on Windows could not find its
|
|
7
|
+
version on Chromium Dash (#61)
|
|
8
|
+
- Enables `dom.promise_rejection_events.enabled` for Firefox 68 (#49)
|
|
9
|
+
- Adds optional verbose logging on download requests (!79)
|
|
10
|
+
- Refactors `src/browsers.js` file (#65)
|
|
11
|
+
|
|
12
|
+
### Testing
|
|
13
|
+
|
|
14
|
+
- Adds a local http server for tests (#50)
|
|
15
|
+
- Allows running Firefox ARM in the Docker ARM image (!84)
|
|
16
|
+
- Skip other browser tests when install fails (#58)
|
|
17
|
+
- Fixes an issue where Linux Edge tests would fail when not following a very
|
|
18
|
+
specific order (#57)
|
|
19
|
+
- Reduces the size of the Windows CI log (#62)
|
|
20
|
+
|
|
21
|
+
### Notes for integrators
|
|
22
|
+
|
|
23
|
+
- The minimum broser versions are now Chromium >= 77 (Chromium ARM >= 92) and
|
|
24
|
+
Firefox >= 68. Edge keeps the same version (>= 95)
|
|
25
|
+
- The minimum required node version is now 18
|
|
26
|
+
|
|
27
|
+
# 0.13.0
|
|
28
|
+
|
|
29
|
+
- Fixes an issue that prevented the webdriver from locating the Edge binary on
|
|
30
|
+
Linux (#60)
|
|
31
|
+
- Uses headless new mode on Edge >= 116 (!74)
|
|
32
|
+
- Replaces omahaproxy API (deprecated) with chromiumdash (!73)
|
|
33
|
+
- Throws a `browser not installed` error when `customBinaryPath` doesn't exist
|
|
34
|
+
(!72)
|
|
35
|
+
|
|
36
|
+
### Testing
|
|
37
|
+
|
|
38
|
+
- Changes the test extension in incognito mode from spanning to split (#59)
|
|
39
|
+
- Runs Linux Edge tests in a different browser version order (!71)
|
|
40
|
+
|
|
1
41
|
# 0.12.0
|
|
2
42
|
|
|
3
43
|
- Adds a new field `customBrowserBinary` to `getDriver()` options parameter that
|
package/index.js
CHANGED
|
@@ -15,5 +15,22 @@
|
|
|
15
15
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
import {Chromium} from "./src/chromium.js";
|
|
19
|
+
import {Firefox} from "./src/firefox.js";
|
|
20
|
+
import {Edge} from "./src/edge.js";
|
|
21
|
+
|
|
22
|
+
export {download, takeFullPageScreenshot, snapshotsBaseDir}
|
|
23
|
+
from "./src/utils.js";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @type {Object}
|
|
27
|
+
* @property {Chromium} chromium Browser and webdriver functionality for
|
|
28
|
+
* Chromium.
|
|
29
|
+
* @property {Firefox} firefox Browser and webdriver functionality for Firefox.
|
|
30
|
+
* @property {Edge} edge Browser and webdriver functionality for Edge.
|
|
31
|
+
*/
|
|
32
|
+
export const BROWSERS = {
|
|
33
|
+
chromium: Chromium,
|
|
34
|
+
firefox: Firefox,
|
|
35
|
+
edge: Edge
|
|
36
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eyeo/get-browser-binary",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Install browser binaries and matching webdrivers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"author": "eyeo GmbH",
|
|
10
10
|
"license": "GPL-3.0",
|
|
11
11
|
"engines": {
|
|
12
|
-
"node": ">=
|
|
13
|
-
"npm": ">=
|
|
12
|
+
"node": ">=18",
|
|
13
|
+
"npm": ">=9"
|
|
14
14
|
},
|
|
15
15
|
"type": "module",
|
|
16
16
|
"main": "index.js",
|
|
@@ -39,12 +39,15 @@
|
|
|
39
39
|
"eslint": "^8.33.0",
|
|
40
40
|
"eslint-config-eyeo": "^3.2.0",
|
|
41
41
|
"expect": "^29.4.2",
|
|
42
|
+
"express": "^4.18.2",
|
|
42
43
|
"jsdoc": "^4.0.0",
|
|
43
44
|
"mocha": "^10.2.0"
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|
|
46
47
|
"docs": "jsdoc --readme README.md --destination docs src/*.js",
|
|
47
48
|
"lint": "eslint --ext js .",
|
|
48
|
-
"test": "
|
|
49
|
+
"test": "node test/runner.js --",
|
|
50
|
+
"test-suite": "mocha --exclude test/start-server.js --exclude test/test-server.js --exclude test/runner.js --",
|
|
51
|
+
"test-server": "node test/start-server.js"
|
|
49
52
|
}
|
|
50
53
|
}
|
package/src/browser.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2006-present eyeo GmbH
|
|
3
|
+
*
|
|
4
|
+
* This module is free software: you can redistribute it and/or modify
|
|
5
|
+
* it under the terms of the GNU General Public License as published by
|
|
6
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
* (at your option) any later version.
|
|
8
|
+
*
|
|
9
|
+
* This program is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License
|
|
15
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import {exec, execFile} from "child_process";
|
|
19
|
+
import {promisify} from "util";
|
|
20
|
+
|
|
21
|
+
import {errMsg} from "./utils.js";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Base class for browser and webdriver functionality. Please see subclasses for
|
|
25
|
+
* browser specific details. All classes can be used statically.
|
|
26
|
+
* @hideconstructor
|
|
27
|
+
*/
|
|
28
|
+
export class Browser {
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {Object} BrowserBinary
|
|
31
|
+
* @property {string} binary The path to the browser binary.
|
|
32
|
+
* @property {string} versionNumber The version number of the browser binary.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Installs the browser. The installation process is detailed on the
|
|
37
|
+
* subclasses.
|
|
38
|
+
* @param {string} [version=latest] Either full version number or
|
|
39
|
+
* channel/release. Please find examples on the subclasses.
|
|
40
|
+
* @param {number} [downloadTimeout=0] Allowed time in ms for the download of
|
|
41
|
+
* install files to complete. When set to 0 there is no time limit.
|
|
42
|
+
* @return {BrowserBinary}
|
|
43
|
+
* @throws {Error} Unsupported browser version, Unsupported platform, Browser
|
|
44
|
+
* download failed.
|
|
45
|
+
*/
|
|
46
|
+
static async installBrowser(version, downloadTimeout = 0) {
|
|
47
|
+
// to be implemented by the subclass
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Gets the installed version returned by the browser binary.
|
|
52
|
+
* @param {string} binary The path to the browser binary.
|
|
53
|
+
* @return {string} Installed browser version.
|
|
54
|
+
* @throws {Error} Browser is not installed.
|
|
55
|
+
*/
|
|
56
|
+
static async getInstalledVersion(binary) {
|
|
57
|
+
try {
|
|
58
|
+
let stdout;
|
|
59
|
+
let stderr;
|
|
60
|
+
if (process.platform == "win32") {
|
|
61
|
+
({stdout, stderr} = await promisify(exec)(
|
|
62
|
+
`(Get-ItemProperty ${binary}).VersionInfo.ProductVersion`,
|
|
63
|
+
{shell: "powershell.exe"})
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
({stdout, stderr} = await promisify(execFile)(binary, ["--version"]));
|
|
68
|
+
}
|
|
69
|
+
if (stderr)
|
|
70
|
+
throw new Error(stderr);
|
|
71
|
+
|
|
72
|
+
return stdout.trim();
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
throw new Error(`${errMsg.browserNotInstalled}.\nBinary path: ${binary}\n${err}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @typedef {Object} webdriver
|
|
81
|
+
* @see https://www.selenium.dev/selenium/docs/api/javascript/index.html
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @typedef {Object} driverOptions
|
|
86
|
+
* @property {boolean} [headless=true] Run the browser in headless mode,
|
|
87
|
+
* or not. In Chromium >= 111, the
|
|
88
|
+
* {@link https://developer.chrome.com/articles/new-headless/ new headless mode}
|
|
89
|
+
* is used.
|
|
90
|
+
* @property {Array.<string>} [extensionPaths=[]] Loads extensions to the
|
|
91
|
+
* browser.
|
|
92
|
+
* @property {boolean} [incognito=false] Runs the browser in incognito mode,
|
|
93
|
+
* or not.
|
|
94
|
+
* @property {boolean} [insecure=false] Forces the browser to accept insecure
|
|
95
|
+
* certificates, or not.
|
|
96
|
+
* @property {Array.<string>} [extraArgs=[]] Additional arguments to start
|
|
97
|
+
* the browser with.
|
|
98
|
+
* @property {string} [customBrowserBinary] Path to the browser binary to be
|
|
99
|
+
* used, instead of the browser installed by installBrowser(). This option
|
|
100
|
+
* overrides the version parameter in getDriver().
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Installs the webdriver matching the browser version and runs the
|
|
105
|
+
* browser. If needed, the browser binary is also installed.
|
|
106
|
+
* @param {string} [version=latest] Either full version number or
|
|
107
|
+
* channel/release. Please find examples on the subclasses.
|
|
108
|
+
* @param {driverOptions} [options={}] Options to start the browser with.
|
|
109
|
+
* @param {number} [downloadTimeout=0] Allowed time in ms for the download of
|
|
110
|
+
* browser install files to complete. When set to 0 there is no time limit.
|
|
111
|
+
* @return {webdriver}
|
|
112
|
+
* @throws {Error} Unsupported browser version, Unsupported platform, Browser
|
|
113
|
+
* download failed, Driver download failed, Unable to start driver.
|
|
114
|
+
*/
|
|
115
|
+
static async getDriver(version, options = {}, downloadTimeout = 0) {
|
|
116
|
+
// to be implemented by the subclass
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* By default, extensions are disabled in incognito mode. This function
|
|
121
|
+
* enables the extension when loaded in incognito.
|
|
122
|
+
* @param {webdriver} driver The driver controlling the browser.
|
|
123
|
+
* @param {string} extensionTitle Title of the extension to be enabled.
|
|
124
|
+
* @return {webdriver}
|
|
125
|
+
* @throws {Error} Unsupported browser version, Extension not found, HTML
|
|
126
|
+
* element not found.
|
|
127
|
+
*/
|
|
128
|
+
static async enableExtensionInIncognito(driver, extensionTitle) {
|
|
129
|
+
// Allowing the extension in incognito mode can't happen programmatically:
|
|
130
|
+
// https://stackoverflow.com/questions/57419654
|
|
131
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1729315
|
|
132
|
+
// That is done through the UI, to be implemented by the subclass
|
|
133
|
+
}
|
|
134
|
+
}
|