From 56356bd3400c104eb0b7af1322ff515c155ef7a4 Mon Sep 17 00:00:00 2001 From: Igor Soarez Date: Sun, 8 Nov 2026 15:32:11 +0000 Subject: overlay.clear: click the page body outside the prompt, and wait for it to go Measured on 1Password's inline menu: blur and Escape did not free the tab, a click outside did. overlay.clear now also sends pointer/mouse events to the body and polls the debugger for about a second instead of checking once. --- test-suite/unit/overlay.test.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'test-suite/unit') diff --git a/test-suite/unit/overlay.test.mjs b/test-suite/unit/overlay.test.mjs index cd60522..a4247b3 100644 --- a/test-suite/unit/overlay.test.mjs +++ b/test-suite/unit/overlay.test.mjs @@ -71,9 +71,13 @@ test("the injected clean-up removes foreign extension iframes, not ours, and blu const shadowFrame = mk("chrome-extension://aeblf/inline/b.html"); const host = { tagName: "DIV", shadowRoot: { querySelectorAll: () => [shadowFrame] } }; let blurred = false, escaped = false; + const bodyEvents = []; const sandbox = { - document: { querySelectorAll: () => [foreign, ours, page, host], activeElement: { blur: () => { blurred = true; } }, body: {}, dispatchEvent: (e) => { escaped = e.key === "Escape"; } }, + document: { querySelectorAll: () => [foreign, ours, page, host], activeElement: { blur: () => { blurred = true; } }, body: { dispatchEvent: (e) => { bodyEvents.push(e.type); } }, dispatchEvent: (e) => { escaped = e.key === "Escape"; } }, KeyboardEvent: class { constructor(type, init) { this.type = type; Object.assign(this, init); } }, + MouseEvent: class { constructor(type) { this.type = type; } }, + PointerEvent: class { constructor(type) { this.type = type; } }, + window: {}, Array, }; const result = vm.runInNewContext(`(${w.clearForeignOverlays.toString()})("ours")`, sandbox); @@ -81,6 +85,7 @@ test("the injected clean-up removes foreign extension iframes, not ours, and blu assert.equal(foreign.removed && shadowFrame.removed, true); assert.equal(ours.removed || page.removed, false); assert.ok(blurred && escaped); + assert.deepEqual([...bodyEvents], ["pointerdown", "mousedown", "pointerup", "mouseup", "click"]); }); test("the tool and the primer let the agent decide: clear it when in the way, leave it when waiting for the user", () => { -- cgit v1.2.3