aboutsummaryrefslogtreecommitdiff
path: root/test-suite/unit
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-11-08 15:32:11 +0000
committerIgor Soarez <igor@soarez.org>2026-11-08 15:32:11 +0000
commit56356bd3400c104eb0b7af1322ff515c155ef7a4 (patch)
tree193aa48263fb7a90bb1e229be5a1ab4288f71deb /test-suite/unit
parent0edeb17be41b4f57e40b16b9c86bf5ce85add971 (diff)
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.
Diffstat (limited to 'test-suite/unit')
-rw-r--r--test-suite/unit/overlay.test.mjs7
1 files changed, 6 insertions, 1 deletions
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", () => {