diff --git a/src/background/handlers/attach-window-to-request.test.ts b/src/background/handlers/attach-window-to-request.test.ts index fed077951..b458dae6e 100644 --- a/src/background/handlers/attach-window-to-request.test.ts +++ b/src/background/handlers/attach-window-to-request.test.ts @@ -99,6 +99,20 @@ describe('a window that is not ours must not own a request', () => { expect(cancelMock).not.toHaveBeenCalled(); }); + it('does not undo the attach when the tab is still at about:blank', async () => { + // Firefox has no `pendingUrl` and reports a freshly created window's tab + // as `about:blank` until the navigation commits, so on a cold open there + // the probe lands on exactly this shape (WALLET-1439). Repairing on it + // cancelled the request whose window was on screen. + getMock.mockResolvedValue({ id: 7, tabs: [{ url: 'about:blank' }] }); + const { store } = makeStore(); + + attachWindowToRequest(store, 'r1', 7); + await flush(); + + expect(cancelMock).not.toHaveBeenCalled(); + }); + it('warns when our window carries no requestId at all', async () => { // Without this the ownership check establishes "one of our windows" and // says nothing about "the window showing THIS request" — and the two are diff --git a/src/background/handlers/attach-window-to-request.ts b/src/background/handlers/attach-window-to-request.ts index 4c71028d7..6c716e531 100644 --- a/src/background/handlers/attach-window-to-request.ts +++ b/src/background/handlers/attach-window-to-request.ts @@ -67,7 +67,11 @@ export function attachWindowToRequest( const tab = browserWindow.tabs?.[0]; const tabUrl = tab?.url ?? tab?.pendingUrl; - if (tabUrl == null || tabUrl === '') { + // Every not-yet-settled shape, per browser: Chrome reports a navigating + // tab as `url: ''` (the target in `pendingUrl`); Firefox has no + // `pendingUrl` and reports `about:blank` until the navigation commits, + // which is what a freshly created window's tab shows when probed. + if (tabUrl == null || tabUrl === '' || tabUrl === 'about:blank') { return; }