diff options
| author | Tianren Dong <tianrendong.dtr@gmail.com> | 2026-05-13 02:35:01 -0400 |
|---|---|---|
| committer | Tianren Dong <tianrendong.dtr@gmail.com> | 2026-05-13 02:35:01 -0400 |
| commit | 26ab0d36e45b1b65f667d4743eb30e83389ff57f (patch) | |
| tree | 678f92867c16671caa116b4e1762a672703f9863 /test-suite/challenges/29-shadow-dom-controls.html | |
| parent | b319c82a75e9a6488a6454790d1436f74a655e7c (diff) | |
pi-chrome 0.14.2: recover from foreign-extension input overlays
When a different Chrome extension (password manager, autofill popup,
etc.) anchors an overlay to the focused input, Chrome's CDP refuses
our Input.dispatchMouseEvent with 'Cannot access a chrome-extension://
URL of different extension'. The CDP target list shows the foreign
chrome-extension:// URL as type:'other' attached to the same tab.
New behaviour in cdp() wrapper:
1. On that specific error for any Input.* call, snapshot CDP targets
to identify the offending extension id and log it (foreign-ext-
detected event added to ring buffer).
2. Send Esc via Input.dispatchKeyEvent (key dispatch routes by focus,
not coordinates, so it bypasses the overlay) to dismiss the popup.
3. Retry the original Input.* call once.
4. If retry still fails, throw a clear error naming the foreign
extension id and listing three concrete workarounds: disable that
extension on the page, use Tab-to-focus instead of clicking, or
run /chrome quiet off.
Diffstat (limited to 'test-suite/challenges/29-shadow-dom-controls.html')
| -rw-r--r-- | test-suite/challenges/29-shadow-dom-controls.html | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test-suite/challenges/29-shadow-dom-controls.html b/test-suite/challenges/29-shadow-dom-controls.html new file mode 100644 index 0000000..bb2355c --- /dev/null +++ b/test-suite/challenges/29-shadow-dom-controls.html @@ -0,0 +1,44 @@ +<!doctype html> +<meta charset="utf-8"> +<title>29 shadow DOM controls</title> +<link rel="stylesheet" href="../_style.css"> +<script src="../_lib.js"></script> +<body> +<main> + <p>Goal: discover controls inside an <code>open</code> Shadow DOM, click the button, then type <code>shadow-ok</code> into the shadow input.</p> + <div id="host"></div> +</main> +<script> +Challenge.init({ id: "shadow-dom-controls", instructions: "click shadow button, type 'shadow-ok' in shadow input" }); +const host = document.getElementById("host"); +const root = host.attachShadow({ mode: "open" }); +root.innerHTML = ` + <style> + .card { border:1px solid #555; border-radius:8px; padding:16px; background:#222; display:inline-block; } + button,input { font:16px system-ui; padding:8px 10px; margin:6px; } + </style> + <div class="card" role="group" aria-label="Shadow test controls"> + <button id="shadowBtn">Arm shadow form</button> + <input id="shadowInput" aria-label="Shadow value" placeholder="shadow-ok" disabled> + <span id="status">waiting</span> + </div> +`; +const btn = root.getElementById("shadowBtn"); +const input = root.getElementById("shadowInput"); +const status = root.getElementById("status"); +let armed = false; +btn.addEventListener("click", (e) => { + armed = true; + input.disabled = false; + input.focus(); + status.textContent = `armed; click trusted=${e.isTrusted}`; + Challenge.log("shadow-click", { isTrusted: e.isTrusted }); +}); +input.addEventListener("input", (e) => { + Challenge.log("shadow-input", { value: input.value, isTrusted: e.isTrusted }); + if (input.value !== "shadow-ok") return; + if (!armed) return Challenge.fail("input reached target value before shadow button click armed the form"); + Challenge.pass("shadow button clicked and shadow input filled"); +}); +</script> +</body> |
