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
+22 -1
View File
@@ -242,6 +242,13 @@ async function settle() {
* "?approval=" and an id for the popup opened as an approval window.
* @param {object} [options.runtime] members of chrome.runtime that replace the
* stub's own, for a test that has to answer the background's messages.
* @param {object} [options.windows] chrome.windows, for a test of the approval
* window resizing itself.
* @param {object} [options.tabs] chrome.tabs, for the same test: the page's
* tab and its zoom.
* @param {object} [options.documentElement] members of document.documentElement
* that replace the stub's own: scrollWidth and clientWidth, which are equal
* unless a test says otherwise, so the page does not scroll sideways.
* @returns {Promise<object>} handles onto the booted page.
*/
async function bootPopup(stored, options) {
@@ -277,7 +284,13 @@ async function bootPopup(stored, options) {
(options && options.storage) ||
makeStorageStub(stored === undefined ? {} : { autistmask: stored });
const document = makeDocument(POPUP_HTML);
Object.assign(
document.documentElement,
{ scrollWidth: 396, clientWidth: 396 },
options && options.documentElement,
);
const reloads = [];
const windowListeners = {};
globalThis.chrome = {
storage: { local: storage.local },
@@ -287,6 +300,8 @@ async function bootPopup(stored, options) {
onMessage: { addListener: () => {} },
...(options && options.runtime),
},
windows: options && options.windows,
tabs: options && options.tabs,
};
globalThis.document = document;
globalThis.window = {
@@ -300,7 +315,13 @@ async function bootPopup(stored, options) {
addEventListener: () => {},
removeEventListener: () => {},
}),
addEventListener: () => {},
// Recorded, as the document's are, so a test that widens the approval
// window can call the page's resize listeners.
listeners: windowListeners,
addEventListener: (name, fn) => {
windowListeners[name] = windowListeners[name] || [];
windowListeners[name].push(fn);
},
};
// The ten-second refresh init() starts, and a transaction wait's timers,
// would outlive the test. So every interval is recorded rather than