Skip to content

Target visible controls in background Chrome - #14

Merged
alexanderradahl merged 1 commit into
mainfrom
fix/visible-fill-target-20260827
Aug 27, 2026
Merged

Target visible controls in background Chrome#14
alexanderradahl merged 1 commit into
mainfrom
fix/visible-fill-target-20260827

Conversation

@alexanderradahl

Copy link
Copy Markdown
Owner

Problem

After the background-frame timeout fix, old Reddit still did not publish comments because chrome_fill used document.querySelector, while Reddit exposes multiple textarea[name="text"] elements including hidden reply templates. A generic selector could therefore fill and submit a hidden form while reporting success. Snapshot generation also returned non-unique attribute selectors and repeatedly queried the full DOM while constructing structural selectors, which could stall on Reddit's very large navigation DOM.

Fix

  • Resolve all selector matches and choose the first visible, enabled, fillable element.
  • Fail closed when every fillable match is hidden or disabled.
  • Pass the visible submit control into form.requestSubmit.
  • Return match count, selected index/visibility, form action/method, and submit strategy for native verification.
  • Return id/attribute selectors from snapshots only when unique.
  • Build root-anchored structural selectors without repeatedly scanning the full document.
  • Bump the unpacked extension to 0.2.9.

Regression coverage

The executable pageFill regression now proves:

  1. A suspended background requestAnimationFrame still resolves in about 250 ms.
  2. With a hidden Reddit-style textarea first and visible composer second, only the visible composer is filled and its visible submitter is passed to requestSubmit.
  3. A hidden-only match fails closed without changing its value.

Verification

  • npm run check — passed
  • node tests/chrome-fill-background.mjs — passed
  • node tests/chrome-background.mjs — passed
  • npm test — passed, including smoke, integration, adversarial, Responses, HTTP, OAuth, PTY, federation, ChatGPT conversation/runtime, browser, and installer suites

No website/provider write is performed by the source change itself.

@alexanderradahl
alexanderradahl merged commit 75742c2 into main Aug 27, 2026
2 checks passed
@alexanderradahl
alexanderradahl deleted the fix/visible-fill-target-20260827 branch August 27, 2026 21:30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 69685a9b02

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +3021 to +3023
const submitter = form
? [...form.querySelectorAll('button:not([type]),button[type="submit"],input[type="submit"]')]
.find((candidate) => isVisible(candidate) && !isDisabled(candidate))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid selecting an arbitrary submitter

When a form has multiple visible submit controls, this unconditionally chooses the first one. Passing that button to requestSubmit applies its formaction, formmethod, formnovalidate, and name/value semantics, whereas the previous no-argument call used the form itself; consequently, chrome_fill(..., submit: true) can now hit a different endpoint or bypass validation (for example, if a delete or alternate-action button appears first). Reject ambiguous submitters or select one only when its submission semantics are known to match the form.

Useful? React with 👍 / 👎.

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