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/30-iframe-targeting.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/30-iframe-targeting.html')
| -rw-r--r-- | test-suite/challenges/30-iframe-targeting.html | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test-suite/challenges/30-iframe-targeting.html b/test-suite/challenges/30-iframe-targeting.html new file mode 100644 index 0000000..b77eac2 --- /dev/null +++ b/test-suite/challenges/30-iframe-targeting.html @@ -0,0 +1,44 @@ +<!doctype html> +<meta charset="utf-8"> +<title>30 iframe targeting</title> +<link rel="stylesheet" href="../_style.css"> +<script src="../_lib.js"></script> +<body> +<main> + <p>Goal: interact with controls inside a same-origin iframe. Type <code>frame-ok</code> then click Submit inside the frame.</p> + <iframe id="ifr" title="same-origin challenge frame" style="width:520px;height:220px;border:1px solid #555;border-radius:8px;background:#fff"></iframe> +</main> +<script> +Challenge.init({ id: "iframe-targeting", instructions: "type 'frame-ok' and click Submit inside iframe" }); +const frame = document.getElementById("ifr"); +frame.srcdoc = `<!doctype html><meta charset="utf-8"> +<style>body{font:16px system-ui;margin:24px;background:#202020;color:#eee}input,button{font:16px system-ui;padding:8px 10px;margin:6px}</style> +<p>Inside frame: fill and submit.</p> +<input id="insideText" aria-label="Frame value" placeholder="frame-ok"> +<button id="insideButton">Submit frame</button> +<pre id="log"></pre> +<script> + const input = document.getElementById('insideText'); + const btn = document.getElementById('insideButton'); + const log = document.getElementById('log'); + let focused = false; + input.addEventListener('focus', () => { focused = true; parent.postMessage({ type:'frame-focus' }, '*'); }); + input.addEventListener('input', e => parent.postMessage({ type:'frame-input', value: input.value, trusted: e.isTrusted }, '*')); + btn.addEventListener('click', e => { + const payload = { type:'frame-submit', value: input.value, focused, trusted: e.isTrusted }; + log.textContent = JSON.stringify(payload, null, 2); + parent.postMessage(payload, '*'); + }); +<\/script>`; +window.addEventListener("message", (e) => { + if (!e.data || typeof e.data !== "object") return; + Challenge.log("frame-message", e.data); + if (e.data.type !== "frame-submit") return; + const bad = []; + if (e.data.value !== "frame-ok") bad.push(`iframe input value="${e.data.value}" (need frame-ok)`); + if (!e.data.focused) bad.push("iframe input was not focused before submit"); + if (bad.length) Challenge.fail(...bad); + else Challenge.pass(`iframe controls reached; submit trusted=${e.data.trusted}`); +}); +</script> +</body> |
