Skip to content

Commit a66946b

Browse files
authored
Use Mac arm64 EdgeDriver when available (#716)
1 parent 7cdc932 commit a66946b

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

lib/compute-download-urls.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async function computeDownloadUrls(opts) {
101101
urls.chromiumedge,
102102
opts.drivers.chromiumedge.baseURL,
103103
opts.drivers.chromiumedge.version,
104-
getChromiumEdgeDriverArchitecture(opts.drivers.chromiumedge.arch)
104+
getChromiumEdgeDriverArchitecture(opts.drivers.chromiumedge.arch, opts.drivers.chromiumedge.version)
105105
);
106106
}
107107

@@ -182,13 +182,18 @@ function getEdgeDriverUrl(version) {
182182
return release.url;
183183
}
184184

185-
function getChromiumEdgeDriverArchitecture(wantedArchitecture) {
185+
function getChromiumEdgeDriverArchitecture(wantedArchitecture, version) {
186186
let platform;
187187

188188
if (process.platform === 'linux') {
189189
platform = 'linux64';
190190
} else if (process.platform === 'darwin') {
191-
platform = 'mac64';
191+
if (process.arch === 'arm64') {
192+
const [major] = version.split('.');
193+
platform = parseInt(major, 10) > 104 ? 'mac64_m1' : 'mac64';
194+
} else {
195+
platform = 'mac64';
196+
}
192197
} else if (wantedArchitecture === 'x32') {
193198
platform = 'win32';
194199
} else {

test/compute-download-urls-test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,28 @@ describe('compute-download-urls', () => {
544544
const actual = await computeDownloadUrls(opts);
545545
assert.strictEqual(actual.chromiumedge, 'https://localhost/86.0.600.0/edgedriver_mac64.zip');
546546
});
547+
548+
it('Use `mac64` on arm64 before Edge 105', async () => {
549+
opts.drivers.chromiumedge = {
550+
baseURL: 'https://localhost',
551+
version: '104.0.1293.70',
552+
arch: 'arm64',
553+
};
554+
555+
const actual = await computeDownloadUrls(opts);
556+
assert.strictEqual(actual.chromiumedge, 'https://localhost/104.0.1293.70/edgedriver_mac64.zip');
557+
});
558+
559+
it('Use `mac64_m1` on arm64 starting from Edge 105', async () => {
560+
opts.drivers.chromiumedge = {
561+
baseURL: 'https://localhost',
562+
version: '105.0.1343.34',
563+
arch: 'arm64',
564+
};
565+
566+
const actual = await computeDownloadUrls(opts);
567+
assert.strictEqual(actual.chromiumedge, 'https://localhost/105.0.1343.34/edgedriver_mac64_m1.zip');
568+
});
547569
});
548570

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

0 commit comments

Comments
 (0)