fix: approval windows open as wide as the page (closes #518)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run

The approval window opened 360 pixels wide while the page is 396, cutting
off the Reject button; it now opens at 396. The browser counts the
window's frame in that width, and a tall screen gives some of it to a
vertical scrollbar, so once the approval's screen is up the page widens
its own window by however far it would scroll sideways, times the zoom of
its own tab. Firefox draws some zoom steps a little larger than it
reports, so the page measures again after each widening, three times at
most. The toolbar popup's window is left alone. The Firefox suite checks
that the sign prompt fits at 170%. README's Visual Style line now gives
the page's real width.

Model: opus-5-5
This commit is contained in:
2026-10-16 02:48:04 +00:00
parent f857bb0a3f
commit 324ef3f924
8 changed files with 288 additions and 11 deletions
+35
View File
@@ -394,6 +394,26 @@ async function waitForApprovalWindow(d, timeout = 30000) {
}
}
// Firefox keeps one zoom per site, so a zoom set on the popup's tab holds for
// every page of the extension, the approval windows included.
async function setExtensionZoom(env, zoom) {
const d = env.driver;
await d.switchToWindow(env.popupWindow);
const outcome = await d.executeAsync(
`const done = arguments[arguments.length - 1];
const zoom = arguments[0];
browser.tabs
.getCurrent()
.then((tab) => browser.tabs.setZoom(tab.id, zoom))
.then(() => done({}), (e) => done({ error: String(e) }));`,
[zoom],
);
assert(
outcome && !outcome.error,
"could not set the extension's zoom: " + (outcome && outcome.error),
);
}
function startRequest(d, key, method, params) {
return d.execute(
"window.__dapp.start(arguments[0], arguments[1], arguments[2]);" +
@@ -633,6 +653,14 @@ step(
"personal_sign returns a signature that recovers to the address",
async (env) => {
const d = env.driver;
// The window is opened as wide as the page, and widened once the
// screen is up if it still scrolls sideways
// (https://git.eeqj.de/sneak/AutistMask/issues/518). This suite is
// where that is checked: the Chrome suite's approval windows open at
// 1280x720 whatever width the extension asks for. At 170%, one of
// Firefox's zoom steps, the page is drawn a little larger than the
// 1.7 Firefox reports, so a single widening leaves it a pixel short.
await setExtensionZoom(env, 1.7);
await d.switchToWindow(env.dappWindow);
await startRequest(d, "sign", "personal_sign", [SIGN_HEX, env.address]);
@@ -640,6 +668,12 @@ step(
await d.switchToWindow(popup);
await d.waitVisible("#view-approve-sign");
await d.waitFor(
"the sign prompt to fit its window without scrolling sideways",
"return document.documentElement.scrollWidth <=" +
" document.documentElement.clientWidth;",
);
const screen = await d.execute(
`return {
origin: document.getElementById("approve-sign-origin").textContent,
@@ -674,6 +708,7 @@ step(
await d.switchToWindow(env.dappWindow);
const outcome = await settleRequest(d, "sign");
await setExtensionZoom(env, 1);
assert(
outcome.settled === "resolved",
"personal_sign did not resolve: " + JSON.stringify(outcome),