Repository navigation
feat(thumbjar): record each input event's target ranges, selection and whether its default was prevented - #3669
Conversation
…d whether its default was prevented
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Bundle Stats✅ No significant changes. All scenario measurements (34)🗺️
Significant means at least 1.0 KB and 1% gzip, or at least 5 ms and 10% import time. |
recordInputnow records what each input event carries, not just its type and data. Every recorded event gets the field's text and selection at the moment it fires.beforeinputandinputalso getisComposing,cancelable, the target ranges the browser reported (read during dispatch, as offsets in the field's text) and whether the default ended up prevented once the page's own handlers had run.This makes a device run answer two questions it could not before: whether the browser's event alone says which text changed, and whether calling
preventDefault()on it actually held on Android. Existing keys and their values are unchanged, so current tests read the same events as before.defaultPreventedis written by a zero-delay timer after the dispatch, because a trusted event runs microtasks between listeners and the page's handlers, React's included, run after the recorder's document capture listener. Any read that throws is recorded asnullso the recorder never breaks the page.Note
Low Risk
Changes are confined to test instrumentation (
recordInput) and driver reads, with broad unit test coverage and no production auth or data-path impact.Overview
recordInputnow captures richer per-event state for Android keyboard tests: every recorded event includesselection(direction-aware UTF-16{anchor, focus}) and fieldtextat dispatch time.beforeinput/inputalso recordisComposing,cancelable,targetRanges(field-relative UTF-16 ranges, withnullfor out-of-field), anddefaultPrevented(filled after dispatch viasetTimeout(0)so page handlers can run first).The page exposes
window.__selection()so the Gboard driver no longer inlines selection logic in CDP; boundary reads use that API and step/event fixtures in tests were updated to expect the new fields.Extensive jsdom unit tests and README documentation cover backward selection, contenteditable offsets, throwing getters, and deferred
defaultPreventedlogging.Reviewed by Cursor Bugbot for commit d9d268c. Bugbot is set up for automated code reviews on this repo. Configure here.