Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/background/handlers/attach-window-to-request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/background/handlers/attach-window-to-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading