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/27-scroll-momentum.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/27-scroll-momentum.html')
| -rw-r--r-- | test-suite/challenges/27-scroll-momentum.html | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test-suite/challenges/27-scroll-momentum.html b/test-suite/challenges/27-scroll-momentum.html new file mode 100644 index 0000000..981ec7b --- /dev/null +++ b/test-suite/challenges/27-scroll-momentum.html @@ -0,0 +1,66 @@ +<!doctype html> +<meta charset="utf-8"> +<title>27 scroll momentum tail</title> +<link rel="stylesheet" href="../_style.css"> +<script src="../_lib.js"></script> +<body> +<main> + <p>Goal: scroll the box to its bottom using a real wheel/trackpad gesture. + Page records the <code>deltaY</code> sequence and requires a momentum-like tail: + a peak <code>|deltaY|</code>, then a decreasing decay over several events + (≥4 wheel events whose <code>|deltaY|</code> is strictly less than the previous + by >5%). Constant or single-shot wheel events (one big delta then nothing) + fail.</p> + <div id="box" style="height:200px;overflow:auto;border:1px solid #555;background:#fff;color:#111;padding:8px"> + <div style="height:2400px">scroll me ⬇ … continues …</div> + </div> +</main> +<script> +Challenge.init({ id: "scroll-momentum", instructions: "scroll the box to its bottom with a real gesture" }); + +const box = document.getElementById("box"); +const deltas = []; // signed +const tsLog = []; + +box.addEventListener("wheel", (e) => { + deltas.push(e.deltaY); + tsLog.push(e.timeStamp); + if (deltas.length > 200) { deltas.shift(); tsLog.shift(); } + Challenge.log("wheel", { dy: e.deltaY, isTrusted: e.isTrusted }); + if (!e.isTrusted) Challenge.fail("wheel event isTrusted=false"); +}, { passive: true }); + +box.addEventListener("scroll", () => { + if (box.scrollTop + box.clientHeight < box.scrollHeight - 2) return; + // We hit bottom. Analyze the deltaY trace. + if (deltas.length === 0) return Challenge.fail("reached bottom with zero wheel events"); + if (deltas.length < 6) return Challenge.fail(`only ${deltas.length} wheel events (need ≥6 for momentum)`); + + const abs = deltas.map(Math.abs); + // All same sign? Trackpad inertia keeps signs consistent. + const allSameSign = deltas.every(d => Math.sign(d) === Math.sign(deltas[0])); + if (!allSameSign) return Challenge.fail("wheel deltaY signs flip — not a continuous scroll gesture"); + + // All identical magnitudes? Robotic. + const allEqual = abs.every(a => Math.abs(a - abs[0]) < 0.01); + if (allEqual) return Challenge.fail(`all |deltaY|=${abs[0]} — no momentum`); + + // Find peak and require decay tail after it. + const peakIdx = abs.indexOf(Math.max(...abs)); + const tail = abs.slice(peakIdx); + let decays = 0; + for (let i = 1; i < tail.length; i++) { + if (tail[i] < tail[i-1] * 0.95) decays++; + } + Challenge.log("trace", { abs, peakIdx, decays }); + if (decays < 3) return Challenge.fail(`only ${decays} decay steps after peak — no momentum tail`); + + // Timestamps within the tail should span ≥150ms (real inertia lasts hundreds of ms). + const tailTs = tsLog.slice(peakIdx); + const span = tailTs[tailTs.length-1] - tailTs[0]; + if (span < 100) return Challenge.fail(`momentum tail only spans ${span.toFixed(0)}ms`); + + Challenge.pass(`${deltas.length} wheels, peak |dY|=${abs[peakIdx].toFixed(1)}, ${decays} decay steps over ${span.toFixed(0)}ms`); +}); +</script> +</body> |
