From 64843b88853210314677ab1b434729513ce615a7 Mon Sep 17 00:00:00 2001 From: robrobrobrob <34566744+robrobrobrob@users.noreply.github.com> Date: Mon, 19 Sep 2022 00:24:34 -0700 Subject: [PATCH] fix: use win64 version of chromium when on arm64 windows (#8927) * fix: use win64 version of chromium when on arm64 windows no Win_arm available on storage.googleapis.com yet, and it currently defaults to win32 * fix: lint trailing space * fix: use x64 chromium on Windows 11 for ARM * fix: detect windows 11 without semver --- src/node/BrowserFetcher.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/node/BrowserFetcher.ts b/src/node/BrowserFetcher.ts index 2e2fb6419a4..7eeae6ee7d1 100644 --- a/src/node/BrowserFetcher.ts +++ b/src/node/BrowserFetcher.ts @@ -237,7 +237,12 @@ export class BrowserFetcher { this.#platform = 'linux'; break; case 'win32': - this.#platform = os.arch() === 'x64' ? 'win64' : 'win32'; + this.#platform = + os.arch() === 'x64' || + // Windows 11 for ARM supports x64 emulation + (os.arch() === 'arm64' && _isWindows11(os.release())) + ? 'win64' + : 'win32'; return; default: assert(false, 'Unsupported platform: ' + platform); @@ -497,6 +502,25 @@ function parseFolderPath( return {product, platform, revision}; } +/** + * Windows 11 is identified by 10.0.22000 or greater + * @internal + */ +function _isWindows11(version: string): boolean { + const parts = version.split('.'); + if (parts.length > 2) { + const major = parseInt(parts[0] as string, 10); + const minor = parseInt(parts[1] as string, 10); + const patch = parseInt(parts[2] as string, 10); + return ( + major > 10 || + (major === 10 && minor > 0) || + (major === 10 && minor === 0 && patch >= 22000) + ); + } + return false; +} + /** * @internal */