Skip to content

Commit f1bcc44

Browse files
authored
Fixes #709, #710: broken download link for Chrome 106+ in ARM Macs (#711)
* Fixes #709, #710: broken download link for Chrome 106+ in ARM Macs due to https://bugs.chromium.org/p/chromedriver/issues/detail?id=4215 * Fixes another test
1 parent 353a822 commit f1bcc44

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

lib/compute-download-urls.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async function computeDownloadUrls(opts) {
5959
urls.chrome,
6060
opts.drivers.chrome.baseURL,
6161
opts.drivers.chrome.version,
62-
getChromeDriverArchitecture(opts.drivers.chrome.arch)
62+
getChromeDriverArchitecture(opts.drivers.chrome.arch, opts.drivers.chrome.version)
6363
);
6464
}
6565
if (opts.drivers.ie) {
@@ -108,13 +108,18 @@ async function computeDownloadUrls(opts) {
108108
return downloadUrls;
109109
}
110110

111-
function getChromeDriverArchitecture() {
111+
function getChromeDriverArchitecture(wantedArchitecture, version) {
112112
let platform;
113113

114114
if (process.platform === 'linux') {
115115
platform = 'linux64';
116116
} else if (process.platform === 'darwin') {
117-
platform = 'mac64' + (process.arch === 'arm64' ? '_m1' : '');
117+
if (process.arch === 'arm64') {
118+
const [major] = version.split('.');
119+
platform = parseInt(major, 10) > 105 ? 'mac_arm64' : 'mac64_m1';
120+
} else {
121+
platform = 'mac64';
122+
}
118123
} else {
119124
platform = 'win32';
120125
}

test/compute-download-urls-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,20 @@ describe('compute-download-urls', () => {
218218
const actual = await computeDownloadUrls(opts);
219219
assert.strictEqual(actual.chrome, 'https://localhost/91.0.864.53/chromedriver_mac64_m1.zip');
220220
});
221+
222+
it('Use `mac_arm64` starting from Chrome 106', async () => {
223+
opts.drivers.chrome = {
224+
baseURL: 'https://localhost',
225+
version: '106.0.5249.61',
226+
};
227+
228+
Object.defineProperty(process, 'arch', {
229+
value: 'arm64',
230+
});
231+
232+
const actual = await computeDownloadUrls(opts);
233+
assert.strictEqual(actual.chrome, 'https://localhost/106.0.5249.61/chromedriver_mac_arm64.zip');
234+
});
221235
});
222236

223237
describe('win', () => {

test/default-downloads-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ describe('default-downloads', function () {
157157
it('x64 download exists', async () => {
158158
computedUrls = await computeDownloadUrls(opts);
159159

160-
assert(computedUrls.chrome.indexOf('mac64') > 0);
160+
assert(computedUrls.chrome.indexOf('mac_arm64') > 0);
161161
await doesDownloadExist(computedUrls.chrome);
162162
});
163163
});

0 commit comments

Comments
 (0)