@eyeo/get-browser-binary 0.10.0 → 0.11.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/README.md CHANGED
@@ -84,7 +84,9 @@ npm test -- --timeout <ms>
84
84
 
85
85
  ### Running tests on Docker
86
86
 
87
- Useful to reproduce the CI environment of the `test:browsers:linux` job:
87
+ Useful to reproduce the CI environment of the `test:browsers:linux` job.
88
+
89
+ #### Intel/AMD architecture
88
90
 
89
91
  ```shell
90
92
  docker build -f test/docker/Dockerfile -t browsers .
@@ -106,6 +108,24 @@ variable to `true`. Example:
106
108
  TEST_KEEP_SNAPSHOTS=true npm test
107
109
  ```
108
110
 
111
+ #### ARM architecture (M1/M2 Apple Silicon)
112
+
113
+ Chromium (ARM native):
114
+
115
+ ```shell
116
+ docker build -f test/docker/arm64.Dockerfile -t browsers-arm .
117
+ docker run --shm-size=512m -e TEST_ARGS="--grep chromium.*latest" -it browsers-arm
118
+ ```
119
+
120
+ Firefox (AMD emulation):
121
+
122
+ ```shell
123
+ docker build -f test/docker/Dockerfile -t browsers-amd .
124
+ docker run --platform linux/amd64 --shm-size=512m -e TEST_ARGS="--grep firefox.*latest" -it browsers-amd
125
+ ```
126
+
127
+ Edge: Not supported
128
+
109
129
  ## Building the documentation
110
130
 
111
131
  ```shell
package/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,14 @@
1
+ # 0.11.0
2
+
3
+ - Fixes an issue on arm64 edgedriver links that prevented the driver to run on
4
+ M1/M2 machines (!62)
5
+
6
+ ### Testing
7
+
8
+ - Enables running docker tests on arm64 platforms on Chromium (partially) and
9
+ Firefox (!61)
10
+ - Changes `TEST_URL` to a specific testpages url (!62)
11
+
1
12
  # 0.10.0
2
13
 
3
14
  - Added handling of the new headless mode in Chromium (#45)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eyeo/get-browser-binary",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Install browser binaries and matching webdrivers",
5
5
  "repository": {
6
6
  "type": "git",
package/src/browsers.js CHANGED
@@ -229,12 +229,30 @@ class Chromium extends Browser {
229
229
  const MIN_VERSION = 75;
230
230
  const MAX_VERSION_DECREMENTS = 200;
231
231
 
232
+ let binary;
233
+ let versionNumber;
234
+ let base;
235
+
236
+ async function getBase(chromiumVersion) {
237
+ let {chromium_base_position: chromiumBase} =
238
+ await got(`https://omahaproxy.appspot.com/deps.json?version=${chromiumVersion}`).json();
239
+ return parseInt(chromiumBase, 10);
240
+ }
241
+
242
+ // https://gitlab.com/eyeo/developer-experience/get-browser-binary/-/issues/46
243
+ if (platformArch == "linux-arm64") {
244
+ binary = "/usr/bin/chromium";
245
+ let installedVersion = await Chromium.getInstalledVersion(binary);
246
+ // installedVersion example: "Chromium 112.0.5615.49 built on Debian 11.6"
247
+ versionNumber = installedVersion.split(" ")[1];
248
+ base = await getBase(versionNumber);
249
+ return {binary, versionNumber, base};
250
+ }
251
+
232
252
  checkVersion(version, MIN_VERSION, Chromium.#CHANNELS);
233
- let versionNumber = await Chromium.#getVersionForChannel(version);
253
+ versionNumber = await Chromium.#getVersionForChannel(version);
234
254
 
235
- let {chromium_base_position: chromiumBase} =
236
- await got(`https://omahaproxy.appspot.com/deps.json?version=${versionNumber}`).json();
237
- let base = parseInt(chromiumBase, 10);
255
+ base = await getBase(versionNumber);
238
256
  let startBase = base;
239
257
  let [platformDir, fileName] = {
240
258
  "win32-ia32": ["Win", "chrome-win.zip"],
@@ -246,7 +264,6 @@ class Chromium extends Browser {
246
264
  let archive;
247
265
  let browserDir;
248
266
  let snapshotsDir = path.join(snapshotsBaseDir, "chromium");
249
- let binary;
250
267
 
251
268
  while (true) {
252
269
  browserDir = path.join(snapshotsDir, `chromium-${platformArch}-${base}`);
@@ -294,6 +311,7 @@ class Chromium extends Browser {
294
311
  "win32-ia32": ["Win", "chromedriver_win32.zip", "chromedriver.exe"],
295
312
  "win32-x64": ["Win_x64", "chromedriver_win32.zip", "chromedriver.exe"],
296
313
  "linux-x64": ["Linux_x64", "chromedriver_linux64.zip", "chromedriver"],
314
+ "linux-arm64": ["", "", "chromedriver"],
297
315
  "darwin-x64": ["Mac", "chromedriver_mac64.zip", "chromedriver"],
298
316
  "darwin-arm64": ["Mac_Arm", "chromedriver_mac64.zip", "chromedriver"]
299
317
  }[platformArch];
@@ -308,6 +326,13 @@ class Chromium extends Browser {
308
326
  }
309
327
  catch (e) { // zip file is either not cached or corrupted
310
328
  let url = `https://commondatastorage.googleapis.com/chromium-browser-snapshots/${dir}/${base}/${zip}`;
329
+ // https://gitlab.com/eyeo/developer-experience/get-browser-binary/-/issues/46
330
+ // It is unclear how electron releases match Chromium versions. Once that
331
+ // is figured out, the link below will depend on the Chromium version.
332
+ // https://stackoverflow.com/questions/38732822/compile-chromedriver-on-arm
333
+ if (platformArch == "linux-arm64")
334
+ url = "https://github.com/electron/electron/releases/download/v24.1.2/chromedriver-v24.1.2-linux-arm64.zip";
335
+
311
336
  try {
312
337
  await download(url, archive);
313
338
  }
@@ -319,6 +344,8 @@ class Chromium extends Browser {
319
344
 
320
345
  await killDriverProcess("chromedriver");
321
346
  let driverPath = path.join(cacheDir, zip.split(".")[0], driverBinary);
347
+ if (platformArch == "linux-arm64")
348
+ driverPath = path.join(cacheDir, driverBinary);
322
349
  await fs.promises.rm(driverPath, {force: true});
323
350
  await extractZip(archive, {dir: cacheDir});
324
351
 
@@ -705,7 +732,7 @@ class Edge extends Browser {
705
732
  "win32-x64": ["edgedriver_win64.zip", "msedgedriver.exe"],
706
733
  "linux-x64": ["edgedriver_linux64.zip", "msedgedriver"],
707
734
  "darwin-x64": ["edgedriver_mac64.zip", "msedgedriver"],
708
- "darwin-arm64": ["edgedriver_arm64.zip", "msedgedriver"]
735
+ "darwin-arm64": ["edgedriver_mac64_m1.zip", "msedgedriver"]
709
736
  }[platformArch];
710
737
  let cacheDir = path.join(snapshotsBaseDir, "edge", "cache",
711
738
  `edgedriver-${versionNumber}`);
package/test/browsers.js CHANGED
@@ -30,7 +30,7 @@ const VERSIONS = {
30
30
  firefox: ["latest", "60.0", "beta"],
31
31
  edge: ["latest", "95.0.1020.40", "beta", "dev"]
32
32
  };
33
- const TEST_URL = "https://gitlab.com/eyeo/developer-experience/get-browser-binary";
33
+ const TEST_URL = "https://abptestpages.org/en/exceptions/iframe_subdomains";
34
34
  const TEST_URL_LONG_PAGE = "https://abptestpages.org/";
35
35
 
36
36
  async function switchToHandle(driver, testFn) {
@@ -105,12 +105,14 @@ function getExtension(browser, version) {
105
105
  }
106
106
 
107
107
  async function getCachedTimes(browser) {
108
+ let armLinuxChromium = browser == "chromium" &&
109
+ process.platform == "linux" && process.arch == "arm64";
108
110
  let cacheDir = path.join(snapshotsBaseDir, browser, "cache");
109
111
  let cacheFiles = await fs.promises.readdir(cacheDir);
110
112
 
111
113
  let browserCacheTime = null;
112
114
  // Edge gets installed at OS level, that's why it's not tested here
113
- if (browser != "edge") {
115
+ if (browser != "edge" && !armLinuxChromium) {
114
116
  let installTypes = [".zip", ".dmg", ".bz2"];
115
117
  let browserZip =
116
118
  cacheFiles.find(elem => installTypes.some(type => elem.includes(type)));
@@ -120,7 +122,7 @@ async function getCachedTimes(browser) {
120
122
 
121
123
  let driverCacheTime = null;
122
124
  // Firefox install file includes the driver, that's why it's not tested here
123
- if (browser != "firefox") {
125
+ if (browser != "firefox" && !armLinuxChromium) {
124
126
  let driverDir = cacheFiles.find(elem => !elem.endsWith(".zip"));
125
127
  let driverFiles = await fs.promises.readdir(path.join(cacheDir, driverDir));
126
128
  let driverZip = driverFiles.find(elem => elem.endsWith(".zip"));
@@ -210,7 +212,13 @@ for (let browser of Object.keys(BROWSERS)) {
210
212
  expect(existingCacheTimes).toEqual(emptyCacheTimes);
211
213
  });
212
214
 
213
- it("supports extra args", async() => {
215
+ it("supports extra args", async function() {
216
+ // https://gitlab.com/eyeo/developer-experience/get-browser-binary/-/issues/48
217
+ // To be removed when Edge latest version > 112
218
+ if (browser == "edge" && version == "latest" &&
219
+ process.platform == "linux")
220
+ this.skip();
221
+
214
222
  let headless = false;
215
223
  let extraArgs = browser == "firefox" ?
216
224
  ["--devtools"] : ["auto-open-devtools-for-tabs"];
@@ -0,0 +1,22 @@
1
+ # Duplicated from registry.gitlab.com/eyeo/docker/get-browser-binary:node16
2
+ # https://gitlab.com/eyeo/developer-experience/get-browser-binary/-/issues/46
3
+ FROM node:16-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
+
16
+ COPY package*.json get-browser-binary/
17
+ RUN cd get-browser-binary && npm install
18
+
19
+ COPY . get-browser-binary/
20
+
21
+ ENV TEST_ARGS="--grep Browser"
22
+ ENTRYPOINT get-browser-binary/test/docker/entrypoint.sh