fix: open an approval window while another one has focus (closes #290)
check / check (push) Failing after 2s
e2e / e2e-chrome (push) Failing after 2s
e2e / e2e-firefox (push) Failing after 2s

The background centred each approval window on the last focused window,
which could be an earlier approval window still open. Headless Chrome
reports one as 1280x720, so the position came out where the browser refused
to create the window ("Bounds must be at least 50% within visible screen
space"), and the request failed with -32603 and no window. It now centres on
the last focused browser window.

Under load a test in the Chrome suite raised its prompt while the previous
test's window was still closing, and either hit that refusal or took the
closing window for its own. The runner now closes every approval window
between tests.

Model: opus-5-5
This commit is contained in:
2026-10-05 03:37:47 +00:00
parent 90a9d5597f
commit d377b1f9fe
12 changed files with 129 additions and 24 deletions
+31 -1
View File
@@ -267,7 +267,14 @@ function loadBackground(options) {
lastError: null,
},
windows: {
getLastFocused: (cb) => cb(null),
// The last focused of `opts.windows` (listed oldest focus first)
// whose type the caller asked for, as the browser filters them.
getLastFocused: (queryOptions, cb) => {
const asked = (opts.windows || []).filter((w) =>
queryOptions.windowTypes.includes(w.type),
);
cb(asked[asked.length - 1] || null);
},
create: (options2, cb) => {
created.push(options2);
// A browser that answers with no window at all. The approval
@@ -2716,3 +2723,26 @@ describe("removing a site in Settings disconnects it", () => {
expect(await siteAccounts(bg)).toEqual({ result: [signer.address] });
});
});
// An approval window still open is often the last focused window, and headless
// Chrome reports one as 1280x720. Centred on that, the next approval window
// lands where the browser refuses to create it, and its request failed with no
// window at all (https://git.eeqj.de/sneak/AutistMask/issues/290).
describe("where an approval window opens", () => {
test("centred on the browser window, not on an approval window focused since", async () => {
const bg = loadBackground({
windows: [
{ type: "normal", left: 0, top: 0, width: 1280, height: 720 },
{ type: "popup", left: 440, top: 0, width: 1280, height: 720 },
],
});
bg.requestSign();
await settle();
// Centred on the browser window; on the approval window it would be at
// left 900, the position the browser refused.
expect(bg.created).toHaveLength(1);
expect(bg.created[0]).toMatchObject({ left: 460, top: 60 });
});
});