From fa7c86ab1b21aa31002054007b8216270ce3a495 Mon Sep 17 00:00:00 2001 From: soulgalore Date: Thu, 21 Dec 2023 22:21:12 +0100 Subject: [PATCH] Fix Firefox 121 start issue on Mac. See https://github.com/sitespeedio/browsertime/issues/2041 --- lib/firefox/webdriver/builder.js | 34 +++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/lib/firefox/webdriver/builder.js b/lib/firefox/webdriver/builder.js index 9d63022741..e311369fac 100644 --- a/lib/firefox/webdriver/builder.js +++ b/lib/firefox/webdriver/builder.js @@ -1,6 +1,7 @@ import { resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; import path from 'node:path'; +import { platform } from 'node:os'; import { ServiceBuilder, Options, @@ -168,9 +169,36 @@ export async function configureBuilder(builder, baseDir, options) { // https://bugzilla.mozilla.org/show_bug.cgi?id=1751196 if (!isAndroidConfigured(options)) { - ffOptions.setBinary( - firefoxTypes.length > 0 ? firefoxTypes[0] : Channel.RELEASE - ); + // Fix for https://github.com/sitespeedio/browsertime/issues/2041 + if (platform() === 'darwin') { + if ( + !firefoxConfig.binaryPath && + !firefoxConfig.nightly && + !firefoxConfig.beta && + !firefoxConfig.developer + ) { + ffOptions.setBinary('/Applications/Firefox.app/Contents/MacOS/firefox'); + } else if (firefoxConfig.nightly) { + ffOptions.setBinary( + '/Applications/Firefox Nightly.app/Contents/MacOS/firefox' + ); + } else if (firefoxConfig.beta) { + ffOptions.setBinary( + '/Applications/Firefox Nightly.app/Contents/MacOS/firefox' + ); + } else if (firefoxConfig.developer) { + ffOptions.setBinary( + '/Applications/FirefoxDeveloperEdition.app/Contents/MacOS/firefox' + ); + } else if (firefoxConfig.binaryPath) { + ffOptions.setBinary(firefoxConfig.binaryPath); + } + } else { + // See https://github.com/sitespeedio/browsertime/issues/2041 + ffOptions.setBinary( + firefoxTypes.length > 0 ? firefoxTypes[0] : Channel.RELEASE + ); + } } ffOptions.addArguments('-no-remote');