Target visible controls in background Chrome - #14
Conversation
There was a problem hiding this comment.
💡 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".
| const submitter = form | ||
| ? [...form.querySelectorAll('button:not([type]),button[type="submit"],input[type="submit"]')] | ||
| .find((candidate) => isVisible(candidate) && !isDisabled(candidate)) |
There was a problem hiding this comment.
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 👍 / 👎.
Problem
After the background-frame timeout fix, old Reddit still did not publish comments because
chrome_filluseddocument.querySelector, while Reddit exposes multipletextarea[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
form.requestSubmit.0.2.9.Regression coverage
The executable
pageFillregression now proves:requestAnimationFramestill resolves in about 250 ms.requestSubmit.Verification
npm run check— passednode tests/chrome-fill-background.mjs— passednode tests/chrome-background.mjs— passednpm test— passed, including smoke, integration, adversarial, Responses, HTTP, OAuth, PTY, federation, ChatGPT conversation/runtime, browser, and installer suitesNo website/provider write is performed by the source change itself.