Skip to content

Add the form filler - #31

Merged
firegiant9000 merged 52 commits into
mainfrom
feat/form-filler
Nov 20, 2026
Merged

firegiant9000 merged 52 commits into
mainfrom
feat/form-filler

Conversation

@firegiant9000

Copy link
Copy Markdown
Owner

Adds the form filler. You click Fill in the popup, check what will be filled, and confirm. Nothing reads or touches the page until you click, and nothing is ever submitted.

This brings the work merged in #27, #28 and #29 into main, plus the fixes from the whole-branch review.

What is in it

  • core/src/fill/: label matching, control fit and the fill plan. No DOM.
  • shell/fill/page/: the page script. It scans the form, skips hidden fields, writes values, rechecks each field before writing and undoes a write that did not take.
  • shell/fill/inject.ts: injects the page script into the top frame only, on click.
  • shell/fill/controller.ts: holds the fill state for the popup.
  • shell/ui/FillSection.tsx: the review in the popup. "Will fill" now starts open.
  • Lint rules and guard tests that keep filling click-only and submit-free. docs/ARCHITECTURE.md explains them.

Gate

Baseline (320b251) Now (e8f4cd3)
Unit tests 828 1857
Build tests 16 18
ESLint warnings 0 0
web-ext lint 0 errors, 2 warnings 0 errors, 2 warnings

The warning count did not change. No allowlist entries were added.

Hand checks (Task 26)

  • 1. To do
  • 2. To do
  • 3. To do
  • A right-to-left page (suggested)

Screenshots

Day and night popup shots to follow, because "Will fill" now starts open.

Open risks (design section 11)

The hidden-field check is best-effort. The review list is the guard: every field that will be filled is shown before you click Fill.

  • A field covered by another element (overlays, z-index) is not seen as hidden.
  • A clipping parent 2px or more wide does not hide the field.
  • A fixed field below the bottom of the window is not seen as hidden.
  • clip: rect(0 0 0 0) without commas is not tested, because happy-dom does not compute it.
  • An inline or display: contents ancestor with a transform or contain is treated as a containing block. A visible fixed or absolute field inside it can be skipped. It is then left unfilled.
  • contain: paint on html or body is ignored. will-change: translate, rotate, scale or contain, and container-type: size or inline-size, are not treated as containing blocks. In both cases the field is still shown.
  • The lint rules catch ordinary code. They do not stop code written to get around them, such as a path like ..//inject or a name built from pieces. Code review is the backstop.
  • The name-based ban on page changes may flag non-DOM remove, before or after calls in the page script.

Form filler 2: page script, injector and controller
Form filler 3: review in the popup and reworded claims
A throwing popup subscriber no longer leaves busy set, and a throwing now() or relCanonical() after the apply no longer loses the counts or the fill result.
After a failed or unconfirmed apply the page may have renumbered its fields, so the controller drops the plan's writes and the old scan. The Will fill list now starts open, so every value is shown before the click.
Text-like fields (not radio, checkbox or file) are now treated as hidden when opacity is 0 on the field or an ancestor, when clip or clip-path collapses them, when the computed width or height is 1px or less, or when a laid-out box is 1px or smaller or entirely above or left of the page. Box checks only apply when the rect is not all zero, so happy-dom (no layout) is unaffected.

A radio group with a checked member that is not a candidate (disabled, readonly, hidden) is left out of the scan entirely. checked indexes into options, and options only hold candidates, so the checked member cannot be represented without exposing a non-fillable element as a write target; omitting the group guarantees nothing is written and checking another radio can never clear it. Peers are matched by name within the same form owner, or among form-less radios. Checkbox groups are built the same way but checking one box does not clear others, so they are unchanged.
Before any write, apply.ts now re-runs the scan's own isCandidate and controlOf (exported from scan.ts, no copy) and, for radio groups, hasCheckedPeer live. A field hidden, switched to password, given a cc-* or similar autocomplete, or changed to another control kind after the scan is not written.

Outcome on a failed recheck is 'gone': the scanned fillable field no longer exists as such. It is already a not-written outcome in WriteOutcome, so no new union member. The existing disabled/readonly checks still run first and keep reporting 'failed'.

A read-back mismatch now sets text, date and textarea fields back to empty through the prototype setter, and restores the previous selectedIndex or unchecks the member, before returning 'failed'. No events fire on these paths.
Ancestors that are transparent, clipped, or collapsed to 1px or less while clipping overflow now hide a text field. Where checkVisibility exists, a text field it rejects, or one with no client rects, is hidden; radios and checkboxes use it without the opacity property so opacity:0 custom controls stay fillable. inset() clip-path is parsed in its 1 to 4 value form, the left-of-page check is skipped on right-to-left pages, and radio groups and peers are keyed by form owner (form attribute first, then nearest form) and name.
1. The ancestor walk skips documentElement, body and inline/contents boxes, and uses a rect intersection (at most 1px) when both boxes have layout.
2. Drop contentVisibilityAuto from checkVisibility; content-visibility:hidden is always honoured and closed details has no client rects.
3. RTL horizontal off-page check is box.left + scrollX >= clientWidth.
4. Share groupKey between countSlots and scanForm.
Drops the intersection test: a laid-out field in a 0x0 wrapper at the page origin read as no layout and was filled, and fields scrolled out of view in a scrolling box, or positioned outside their wrapper, were skipped. A parent now hides a field only when it clips overflow and is 1px or less across that axis, measured from its box when the field has layout.
The injector test may not import ../controller, a template key such as ctrl[`fill`] counts as reading fill(), and guard/scan.ts may not name the fill script. ARCHITECTURE now says the rules catch ordinary code, not code written to evade them.
Brings back the box test for overflow hidden and clip only, so a field moved outside a normal-sized wrapper is not filled, while fields in a scrolling box stay fillable. Both parent tests now apply only to parents that contain the field: an absolute field escapes up to its nearest positioned ancestor and a fixed one escapes all. ARCHITECTURE no longer calls the built-output scan a backstop for lint evasion.
A transform, filter, perspective, will-change or contain on an ancestor makes it the containing block for absolute and fixed fields, so its overflow clip now counts. contain:paint clips like overflow:clip. Document the visibility check as best-effort, with the review list as the guard.
@firegiant9000
firegiant9000 merged commit dd4c852 into main Nov 20, 2026
1 check passed
@firegiant9000
firegiant9000 deleted the feat/form-filler branch November 20, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant