diff options
| author | Tianren Dong <tianrendong.dtr@gmail.com> | 2026-05-13 01:05:46 -0400 |
|---|---|---|
| committer | Tianren Dong <tianrendong.dtr@gmail.com> | 2026-05-13 01:05:46 -0400 |
| commit | 33110e803fcacc31dc2859dbc0d470b008556798 (patch) | |
| tree | bb30dad365139c558f9d9651cb8bca375320cb8e /test-suite/challenges/18-native-select.html | |
| parent | d78081aa58ecaa1c72e847c2d095b5f07c391506 (diff) | |
pi-chrome: humanize synthetic input + anti-automation test suite
Bump 0.8.0 → 0.9.1.
Companion extension (service_worker.js):
- humanise pointer paths: easing Bezier-ish interpolation w/ wobble, 12–42
steps, 4–18 ms gaps; pointer position persisted across calls
- click point picked inside element rect, not dead center
- pointer events fill movementX/Y, screenX/Y, pressure (0.5 on down),
pointerId, width/height, tilt, composed
- click sequence: humanMoveTo → pointerdown → focus → 45–140 ms hold →
pointerup → mouseup → click
- per-character typing: keydown → keypress → beforeinput → value mutate
(or execCommand for contenteditable) → input → keyup, with 25–95 ms
hold + 35–140 ms inter-key; auto Shift chord for uppercase/symbols
- pressKeyInPage emits same cadence + handles printable insert / Backspace
- hoverPage: humanised path + 80–220 ms dwell
- dragPage: full HTML5 sequence (dragstart/drag/dragenter/dragover/
dragleave/drop/dragend) with shared DataTransfer + pointer continuity
- new scrollPage: wheel events with front-loaded momentum-shaped deltas
- self-reload on version drift: SW reads x-pi-chrome-version header,
reloads when older than pi-chrome
Pi side (index.ts):
- new chrome_scroll tool
- PI_CHROME_VERSION read from package.json (and re-read on every /next
so future bumps take effect without pi restart)
- /chrome-doctor escalates version mismatch to top-line ✗ error and
skips downstream capability probes when stale
- /next response carries x-pi-chrome-version header for SW self-heal
Test suite (test-suite/):
- 28 challenge pages each catching a different synthetic-event tell:
isTrusted, webdriver/fingerprint, mouse entropy/timing/coords,
pointer pressure/continuity, per-char cadence + framework invariants,
user activation, honeypots, focus order, wheel scroll, drag+
DataTransfer, contenteditable+Selection, paste/clipboard, native
select, hover dwell, React valueTracker, keyboard modifiers, touch
events, stack-trace fingerprint, viewport-edge clicks, mousemove
rate, scroll momentum, IntersectionObserver visibility
- shared _lib.js exposes window.__verdict + writes localStorage so
index.html dashboard aggregates results
- notes/bypass-ideas.md documents fixes still needed per challenge
Diffstat (limited to 'test-suite/challenges/18-native-select.html')
| -rw-r--r-- | test-suite/challenges/18-native-select.html | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test-suite/challenges/18-native-select.html b/test-suite/challenges/18-native-select.html new file mode 100644 index 0000000..7ca7002 --- /dev/null +++ b/test-suite/challenges/18-native-select.html @@ -0,0 +1,56 @@ +<!doctype html> +<meta charset="utf-8"> +<title>18 native select option</title> +<link rel="stylesheet" href="../_style.css"> +<script src="../_lib.js"></script> +<body> +<main> + <p>Goal: select the option <code>banana</code> from the native <code><select></code>. + Page asserts a real picker interaction: <code>mousedown</code>/<code>pointerdown</code> + on the <select> (opening the OS picker), then a <code>change</code> event with + <code>isTrusted=true</code>. Programmatically setting <code>.value</code> or clicking the + option element directly fails (clicking <option> does not change selection in + real browsers).</p> + <select id="s" style="font-size:18px;padding:6px 10px"> + <option value="">— pick a fruit —</option> + <option value="apple">apple</option> + <option value="banana">banana</option> + <option value="cherry">cherry</option> + </select> +</main> +<script> +Challenge.init({ id: "native-select", instructions: "pick 'banana' from native select" }); +const s = document.getElementById("s"); + +let sawPointerDownOnSelect = false, pointerDownTrusted = false; +s.addEventListener("pointerdown", (e) => { sawPointerDownOnSelect = true; pointerDownTrusted = e.isTrusted; }); +s.addEventListener("mousedown", (e) => { sawPointerDownOnSelect = true; pointerDownTrusted ||= e.isTrusted; }); + +// Trap: if a click bubbles up from an <option>, that's bot-like (real OS pickers don't dispatch this). +s.addEventListener("click", (e) => { + if (e.target && e.target.tagName === "OPTION") { + Challenge.fail("click event with target=<option> bubbled to <select> (synthetic option click)"); + } +}); + +let changeTrusted = false; +s.addEventListener("change", (e) => { + changeTrusted = e.isTrusted; + Challenge.log("change", { v: s.value, isTrusted: e.isTrusted }); + if (s.value !== "banana") return Challenge.fail(`selected="${s.value}" (need 'banana')`); + const bad = []; + if (!changeTrusted) bad.push("change event isTrusted=false"); + if (!sawPointerDownOnSelect) bad.push("no pointerdown/mousedown on <select> before change"); + if (!pointerDownTrusted) bad.push("pointerdown on select isTrusted=false"); + if (bad.length) Challenge.fail(...bad); + else Challenge.pass("native picker opened and trusted change fired"); +}); + +// Also trip if value mutates without change firing. +let changed = false; +s.addEventListener("change", () => { changed = true; }); +setInterval(() => { + if (s.value === "banana" && !changed) Challenge.fail("value='banana' without any change event"); +}, 200); +</script> +</body> |
