@eyeo/get-browser-binary 0.14.0 → 0.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/.gitlab-ci.yml CHANGED
@@ -29,9 +29,9 @@ test:basic:
29
29
 
30
30
  test:browsers:linux:
31
31
  stage: test
32
- image: docker:20.10.16
32
+ image: docker:24.0.5
33
33
  services:
34
- - docker:20.10.16-dind
34
+ - docker:24.0.5-dind
35
35
  before_script:
36
36
  - docker build -f test/docker/Dockerfile -t browsers .
37
37
  script:
package/README.md CHANGED
@@ -133,20 +133,16 @@ docker run --shm-size=512m -e TEST_ARGS="--grep chromium.*latest --timeout 10000
133
133
 
134
134
  #### ARM architecture (M1/M2 Apple Silicon)
135
135
 
136
- ```shell
137
- docker build -f test/docker/arm64.Dockerfile -t browsers-arm .
138
- docker run --shm-size=512m -e TEST_ARGS="--grep (chromium|firefox).*latest" -it browsers-arm
139
- ```
136
+ The run is done emulating the AMD architecture. Requirements:
140
137
 
141
- Only latest Chromium and latest Firefox ESR versions are supported. Edge is not
142
- supported.
138
+ - macOS >= 13 (Ventura)
139
+ - Rosetta
140
+ - The feature "Use Rosetta for x86/amd64 emulation on Apple Silicon" enabled in Docker
143
141
 
144
- Regarding Firefox, it may be possible to run other versions using AMD emulation
145
- (unstable results):
142
+ The `--platform` option should be used when running the image:
146
143
 
147
144
  ```shell
148
- docker build -f test/docker/Dockerfile -t browsers-amd .
149
- docker run --platform linux/amd64 --shm-size=512m -e TEST_ARGS="--grep firefox.*68.0" -it browsers-amd
145
+ docker run --platform linux/amd64 --shm-size=512m -e TEST_ARGS="--grep chromium.*latest" -it browsers
150
146
  ```
151
147
 
152
148
  ## Building the documentation
package/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,13 @@
1
+ # 0.15.0
2
+
3
+ - Fixes the downloads of Chromium versions < 91 by replacing the remaining
4
+ usages of omahaproxy API (now removed) with chromiumdash (#55)
5
+ - Updates to selenium webdriver 4.15.0 (#66)
6
+
7
+ ### Testing
8
+
9
+ - Uses AMD emulation on ARM docker test runs (!93)
10
+
1
11
  # 0.14.0
2
12
 
3
13
  - Increases minimum supported browser versions (#64)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eyeo/get-browser-binary",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Install browser binaries and matching webdrivers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,7 +33,7 @@
33
33
  "geckodriver": "3.1.0",
34
34
  "got": "^12.5.3",
35
35
  "jimp": "^0.22.4",
36
- "selenium-webdriver": "^4.8.0"
36
+ "selenium-webdriver": "^4.15.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "eslint": "^8.33.0",
package/src/chromium.js CHANGED
@@ -85,10 +85,20 @@ export class Chromium extends Browser {
85
85
  let url;
86
86
  let chromiumBase;
87
87
  try {
88
- // https://gitlab.com/eyeo/developer-experience/get-browser-binary/-/issues/55
89
- if (getMajorVersion(chromiumVersion) < 91) {
90
- url = `https://omahaproxy.appspot.com/deps.json?version=${chromiumVersion}`;
91
- ({chromium_base_position: chromiumBase} = await got(url).json());
88
+ let majorVersion = getMajorVersion(chromiumVersion);
89
+ if (majorVersion < 91) {
90
+ // Below v91, base branch position only exists once per milestone in
91
+ // the /fetch_milestones endpoint
92
+ url = "https://chromiumdash.appspot.com/fetch_milestones?only_branched=true";
93
+ let data = await got(url).json();
94
+ for (let {milestone, chromium_main_branch_position: base} of data) {
95
+ if (milestone == majorVersion) {
96
+ chromiumBase = base;
97
+ break;
98
+ }
99
+ }
100
+ if (!chromiumBase)
101
+ throw new Error(`${errMsg.browserVersionCheck}: ${url}`);
92
102
  }
93
103
  else {
94
104
  url = `https://chromiumdash.appspot.com/fetch_version?version=${chromiumVersion}`;
@@ -128,10 +138,6 @@ export class Chromium extends Browser {
128
138
  let versionNumber;
129
139
  let base;
130
140
 
131
- // https://gitlab.com/eyeo/developer-experience/get-browser-binary/-/issues/46
132
- if (platformArch == "linux-arm64")
133
- return await Chromium.#getInstalledBrowserInfo("/usr/bin/chromium");
134
-
135
141
  checkVersion(version, MIN_VERSION, Chromium.#CHANNELS);
136
142
  versionNumber = await Chromium.#getVersionForChannel(version);
137
143
 
@@ -194,7 +200,6 @@ export class Chromium extends Browser {
194
200
  "win32-ia32": ["Win", "chromedriver_win32.zip", "chromedriver.exe"],
195
201
  "win32-x64": ["Win_x64", "chromedriver_win32.zip", "chromedriver.exe"],
196
202
  "linux-x64": ["Linux_x64", "chromedriver_linux64.zip", "chromedriver"],
197
- "linux-arm64": ["", "", "chromedriver"],
198
203
  "darwin-x64": ["Mac", "chromedriver_mac64.zip", "chromedriver"],
199
204
  "darwin-arm64": ["Mac_Arm", "chromedriver_mac64.zip", "chromedriver"]
200
205
  }[platformArch];
@@ -207,37 +212,22 @@ export class Chromium extends Browser {
207
212
  await extractZip(archive, {dir: cacheDir});
208
213
  }
209
214
  catch (e) { // zip file is either not cached or corrupted
210
- if (platformArch == "linux-arm64") {
211
- // https://gitlab.com/eyeo/developer-experience/get-browser-binary/-/issues/46
212
- // It's unclear how electron releases match Chromium versions. Once that
213
- // is figured out, the link below will depend on the Chromium version.
214
- // https://stackoverflow.com/questions/38732822/compile-chromedriver-on-arm
215
- let url = "https://github.com/electron/electron/releases/download/v26.2.0/chromedriver-v26.2.0-linux-arm64.zip";
215
+ let base = startBase;
216
+ while (true) {
217
+ let url = `https://commondatastorage.googleapis.com/chromium-browser-snapshots/${dir}/${base}/${zip}`;
216
218
  try {
217
219
  await download(url, archive);
220
+ break;
218
221
  }
219
222
  catch (err) {
220
- throw new Error(`${errMsg.driverDownload}: ${url}\n${err}`);
221
- }
222
- }
223
- else {
224
- let base = startBase;
225
- while (true) {
226
- let url = `https://commondatastorage.googleapis.com/chromium-browser-snapshots/${dir}/${base}/${zip}`;
227
- try {
228
- await download(url, archive);
229
- break;
223
+ if (err.name == "HTTPError") {
224
+ base--;
225
+ archive = path.join(cacheDir, `${base}-${zip}`);
226
+ if (base <= startBase - Chromium.#MAX_VERSION_DECREMENTS)
227
+ throw new Error(`${errMsg.driverDownload}: Chromium base ${startBase}`);
230
228
  }
231
- catch (err) {
232
- if (err.name == "HTTPError") {
233
- base--;
234
- archive = path.join(cacheDir, `${base}-${zip}`);
235
- if (base <= startBase - Chromium.#MAX_VERSION_DECREMENTS)
236
- throw new Error(`${errMsg.driverDownload}: Chromium base ${startBase}`);
237
- }
238
- else {
239
- throw new Error(`${errMsg.driverDownload}: ${url}\n${err}`);
240
- }
229
+ else {
230
+ throw new Error(`${errMsg.driverDownload}: ${url}\n${err}`);
241
231
  }
242
232
  }
243
233
  }
@@ -246,8 +236,6 @@ export class Chromium extends Browser {
246
236
 
247
237
  await killDriverProcess("chromedriver");
248
238
  let driverPath = path.join(cacheDir, zip.split(".")[0], driverBinary);
249
- if (platformArch == "linux-arm64")
250
- driverPath = path.join(cacheDir, driverBinary);
251
239
  await fs.promises.rm(driverPath, {force: true});
252
240
  await extractZip(archive, {dir: cacheDir});
253
241
 
package/src/firefox.js CHANGED
@@ -98,10 +98,6 @@ export class Firefox extends Browser {
98
98
  static async installBrowser(version = "latest", downloadTimeout = 0) {
99
99
  const MIN_VERSION = 68;
100
100
 
101
- // https://gitlab.com/eyeo/developer-experience/get-browser-binary/-/issues/46
102
- if (platformArch == "linux-arm64")
103
- return await Firefox.#getInstalledBrowserInfo("/usr/bin/firefox");
104
-
105
101
  checkVersion(version, MIN_VERSION, Firefox.#CHANNELS);
106
102
  let versionNumber = await Firefox.#getVersionForChannel(version);
107
103
 
package/test/browsers.js CHANGED
@@ -107,20 +107,12 @@ function getExtension(browser, version) {
107
107
  }
108
108
 
109
109
  async function getCachedTimes(browser) {
110
- let armLinux = process.platform == "linux" && process.arch == "arm64";
111
110
  let cacheDir = path.join(snapshotsBaseDir, browser, "cache");
112
- let cacheFiles;
113
- try {
114
- cacheFiles = await fs.promises.readdir(cacheDir);
115
- }
116
- catch (err) {
117
- if (!armLinux)
118
- throw err;
119
- }
111
+ let cacheFiles = await fs.promises.readdir(cacheDir);
120
112
 
121
113
  let browserCacheTime = null;
122
114
  // Browsers installed at OS level are not tested
123
- if (browser != "edge" && !armLinux) {
115
+ if (browser != "edge") {
124
116
  let installTypes = [".zip", ".dmg", ".bz2"];
125
117
  let browserZip =
126
118
  cacheFiles.find(elem => installTypes.some(type => elem.includes(type)));
@@ -130,8 +122,7 @@ async function getCachedTimes(browser) {
130
122
 
131
123
  let driverCacheTime = null;
132
124
  // geckodriver is installed by npm, that's why Firefox is not tested here
133
- // for chromiumdriver on arm linux, see https://gitlab.com/eyeo/developer-experience/get-browser-binary/-/issues/46
134
- if (browser != "firefox" && !armLinux) {
125
+ if (browser != "firefox") {
135
126
  let driverDir = cacheFiles.find(
136
127
  elem => !elem.endsWith(".zip") && !elem.endsWith(".pkg"));
137
128
  let driverFiles = await fs.promises.readdir(path.join(cacheDir, driverDir));
@@ -323,11 +314,5 @@ for (let browser of Object.keys(BROWSERS)) {
323
314
  .rejects.toThrow(`Unsupported browser version: ${unsupported}`);
324
315
  }
325
316
  });
326
-
327
- it("does not run not installed custom browsers", async() => {
328
- let customBrowserBinary = "not-installed";
329
- await expect(BROWSERS[browser].getDriver("latest", {customBrowserBinary}))
330
- .rejects.toThrow(/(Browser is not installed|binary is not a Firefox executable)/);
331
- });
332
317
  });
333
318
  }
@@ -1,27 +0,0 @@
1
- # Duplicated from registry.gitlab.com/eyeo/docker/get-browser-binary:node18
2
- # https://gitlab.com/eyeo/developer-experience/get-browser-binary/-/issues/46
3
- FROM node:18-bullseye-slim
4
- # General packages
5
- RUN apt-get update && apt-get install -y git procps wget unzip bzip2 gnupg
6
- # xvfb (headful browser run)
7
- RUN apt-get install -y libgtk-3-0 libxt6 xvfb libnss3 libxss1
8
- # General browser dependencies
9
- RUN apt-get install -y libgconf-2-4 libasound2 libgbm1
10
- # Edge dependencies
11
- RUN apt-get install -y fonts-liberation libatomic1 xdg-utils libu2f-udev
12
-
13
- # Chromium ARM
14
- RUN apt-get install -y chromium
15
- # https://askubuntu.com/questions/1360864/google-chrome-not-launching
16
- RUN mkdir -p "/root/.config/chromium/Crash Reports/pending/"
17
-
18
- # Firefox ARM
19
- RUN apt-get install -y firefox-esr
20
-
21
- COPY package*.json get-browser-binary/
22
- RUN cd get-browser-binary && npm install
23
-
24
- COPY . get-browser-binary/
25
-
26
- ENV TEST_ARGS="--grep Browser"
27
- ENTRYPOINT get-browser-binary/test/docker/entrypoint.sh