Fix #4000: use a safer URL for dummy tabs

This commit is contained in:
Oliver Blanthorn 2026-07-23 16:52:16 +02:00
parent 07fea47e43
commit da03de2109
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
2 changed files with 16 additions and 3 deletions

View file

@ -21,10 +21,13 @@ Object.assign(browser.tabs, {
onActivated: tabEvent,
})
Object.defineProperty(browser, "windows", {
value: { getCurrent: jest.fn().mockReturnValue({ incognito: false }) },
value: {
create: jest.fn().mockResolvedValue({ tabs: [{ id: 42 }] }),
getCurrent: jest.fn().mockReturnValue({ incognito: false }),
},
})
const { set, tabopen } = require("@src/.excmds_background.generated")
const { set, tabopen, winopen } = require("@src/.excmds_background.generated")
test("`set` preserves deep custom arrays", async () => {
await config.set("custom", "deep", "array", [0])
@ -51,3 +54,13 @@ test.each(["none", "somecnt"])(
expect(queryAndURLwrangler).toHaveBeenLastCalledWith([])
},
)
test("`winopen` creates a neutral tab before navigating it", async () => {
await winopen("https://example.com/")
expect(browser.windows.create).toHaveBeenCalledWith({ url: "about:blank" })
expect(browser.tabs.update).toHaveBeenCalledWith(42, {
loadReplace: true,
url: "https://example.com/",
})
})

View file

@ -3503,7 +3503,7 @@ export async function winopen(...args: string[]) {
return nativeopen(firefoxArgs, address)
}
createData.url = "https://fix-a-firefox-bug.invalid"
createData.url = "about:blank"
return browser.windows.create(createData).then(win => openInTab(win.tabs[0], { loadReplace: true }, address.split(" ")))
}