From 11f76118dbdf1f6ca9226790550f368e105799eb Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Fri, 10 Oct 2025 12:48:44 +0200 Subject: [PATCH] fix: unexpected `openExternal` dialog on macOS Tahoe (#48502) fix: unexpected openExternal dialog on macOS Tahoe --- shell/common/platform_util_mac.mm | 6 ++++++ spec/api-shell-spec.ts | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/shell/common/platform_util_mac.mm b/shell/common/platform_util_mac.mm index 001d17b3ff..153334f7f1 100644 --- a/shell/common/platform_util_mac.mm +++ b/shell/common/platform_util_mac.mm @@ -148,6 +148,12 @@ void OpenExternal(const GURL& url, return; } + // Check this to prevent system dialog from popping up on macOS Tahoe. + if (![[NSWorkspace sharedWorkspace] URLForApplicationToOpenURL:ns_url]) { + std::move(callback).Run("No application found to open URL"); + return; + } + NSWorkspaceOpenConfiguration* configuration = [NSWorkspaceOpenConfiguration configuration]; configuration.activates = options.activate; diff --git a/spec/api-shell-spec.ts b/spec/api-shell-spec.ts index 643c780ed4..eef14040b0 100644 --- a/spec/api-shell-spec.ts +++ b/spec/api-shell-spec.ts @@ -82,6 +82,11 @@ describe('shell module', () => { ]); }); + ifit(process.platform === 'darwin')('throws when there is no application registered to open the URL', async () => { + const url = `unknownscheme-${Date.now()}://test`; + await expect(shell.openExternal(url)).to.eventually.be.rejectedWith(/No application found to open URL/); + }); + it('opens an external link in the renderer', async () => { const { url, requestReceived } = await urlOpened(); const w = new BrowserWindow({ show: false, webPreferences: { sandbox: false, contextIsolation: false, nodeIntegration: true } });