aboutsummaryrefslogtreecommitdiff
path: root/test-suite
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-11-08 16:31:10 +0000
committerIgor Soarez <igor@soarez.org>2026-11-08 16:31:10 +0000
commit9d4e47337b9c857b70ea9caf116adb935e18e31c (patch)
tree7ad91a9ae5fdcea5f8cfa128e879a16a2ca6f02f /test-suite
parent516d6f05e7f67a1ef48f1ffc28d27e136e87cd1a (diff)
overlay.clear: read closed shadow roots and remove the host element
Diagnostics on 1Password's inline prompt: the page holds a <com-1password-uso> element and no iframe in its own DOM; the frame is inside a closed shadow root. Run in the isolated world, where chrome.dom.openOrClosedShadowRoot can read it, and remove the element that hosts a foreign extension frame. Drop the body-click events: they were never shown to help.
Diffstat (limited to 'test-suite')
-rw-r--r--test-suite/unit/overlay.test.mjs33
1 files changed, 15 insertions, 18 deletions
diff --git a/test-suite/unit/overlay.test.mjs b/test-suite/unit/overlay.test.mjs
index 87c8fb9..b533ff8 100644
--- a/test-suite/unit/overlay.test.mjs
+++ b/test-suite/unit/overlay.test.mjs
@@ -52,7 +52,7 @@ test("overlay.clear removes the frame and reports the tab usable", async () => {
assert.deepEqual(result.removedFrames, ["chrome-extension://aeblf/inline/universal-sign-on/x.html"]);
assert.equal(result.debuggerAttachable, true);
assert.equal(calls[0].options.args[0], "ours");
- assert.equal(calls[0].options.world, "MAIN");
+ assert.equal(calls[0].options.world, undefined);
});
test("overlay.clear says so when the tab is still blocked (toolbar popup, desktop app)", async () => {
@@ -63,30 +63,27 @@ test("overlay.clear says so when the tab is still blocked (toolbar popup, deskto
assert.deepEqual(result.remainingForeignTargets, ["chrome-extension://aeblf/inline/universal-sign-on/x.html"]);
});
-test("the injected clean-up removes foreign extension iframes, not ours, and blurs the field", () => {
+test("the injected clean-up removes a host whose closed shadow root holds a foreign frame, and loose foreign frames, but not ours or the page's", () => {
const { w } = worker();
- const mk = (src) => ({ tagName: "IFRAME", src, removed: false, remove() { this.removed = true; } });
- const foreign = mk("chrome-extension://aeblf/inline/a.html?x=1");
- const ours = mk("chrome-extension://ours/panel.html");
- const page = mk("https://example.com/embed");
- const shadowFrame = mk("chrome-extension://aeblf/inline/b.html");
- const host = { tagName: "DIV", shadowRoot: { querySelectorAll: () => [shadowFrame] } };
+ const frame = (src) => ({ tagName: "IFRAME", src, isConnected: true, removed: false, remove() { this.removed = true; } });
+ const foreign = frame("chrome-extension://aeblf/inline/a.html?x=1");
+ const ours = frame("chrome-extension://ours/panel.html");
+ const page = frame("https://example.com/embed");
+ const inClosedRoot = frame("chrome-extension://aeblf/inline/universal-sign-on.html?tabId=2");
+ const host = { tagName: "COM-1PASSWORD-USO", isConnected: true, removed: false, remove() { this.removed = true; }, shadowRoot: null, closedRoot: { querySelectorAll: () => [inClosedRoot] } };
+ const plain = { tagName: "DIV", isConnected: true, shadowRoot: null };
let blurred = false, escaped = false;
- const bodyEvents = [];
const sandbox = {
- document: { querySelectorAll: () => [foreign, ours, page, host], activeElement: { blur: () => { blurred = true; } }, body: {}, documentElement: { dispatchEvent: (e) => { bodyEvents.push(e.type); }, click: () => { bodyEvents.push("click"); } }, dispatchEvent: (e) => { escaped = e.key === "Escape"; } },
+ document: { querySelectorAll: (sel) => (sel === "iframe" ? [foreign, ours, page] : [foreign, ours, page, host, plain]), activeElement: { blur: () => { blurred = true; } }, body: {}, dispatchEvent: (e) => { escaped = e.key === "Escape"; } },
+ chrome: { dom: { openOrClosedShadowRoot: (el) => el.closedRoot ?? null } },
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,
+ Array, Set,
};
const result = vm.runInNewContext(`(${w.clearForeignOverlays.toString()})("ours")`, sandbox);
- assert.deepEqual([...result.removed], ["chrome-extension://aeblf/inline/a.html", "chrome-extension://aeblf/inline/b.html"]);
- assert.equal(foreign.removed && shadowFrame.removed, true);
- assert.equal(ours.removed || page.removed, false);
+ assert.deepEqual([...result.removed], ["chrome-extension://aeblf/inline/a.html", "<com-1password-uso> holding chrome-extension://aeblf/inline/universal-sign-on.html"]);
+ assert.ok(foreign.removed && host.removed);
+ assert.equal(ours.removed || page.removed || inClosedRoot.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", () => {