Options to keep upload_file and fill_form from clicking or pressing keys beyond their target

Open
#3,180 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
tooling

Research direction

The upload fallback is in build/src/tools/input.js: when handle.uploadFile() throws, it calls waitForFileChooser() and then handle.asLocator().click(). The fill_form path goes through Locator.fill, which uses ElementHandle.type for values under typingThreshold. Done means an opt-in way to disable the click fallback so upload_file only targets <input type=file>, with the maintainers agreeing on the option shape first. Check the tool's tests before changing behavior.

Written by the indexing model from the issue text.

Description

collecting-feedback feature

We run chrome-devtools-mcp (1.10.1) behind a policy layer for an agent that fills job-application forms and must never submit them. Two behaviors make that hard to guarantee at the tool level:

1. upload_file clicks its target when a direct upload fails. In build/src/tools/input.js, if handle.uploadFile() throws, the tool falls back to waitForFileChooser() plus handle.asLocator().click(). If an agent passes the uid of a non-file element by mistake, for example a Submit button, the fallback clicks it. We currently ship a patch that removes the fallback. Would you accept an option to turn it off, for example a server flag (--no-upload-chooser-fallback) or a tool parameter, so that upload_file only ever targets an actual <input type=file>?

2. fill_form types short values as real keystrokes. For text inputs, Locator.fill types values shorter than Puppeteer's typingThreshold (100) with ElementHandle.type, and Keyboard.type maps \n/\r to Enter and \t to Tab. A value like "5\n" therefore presses Enter, and in a single-line field that submits the form (implicit submission); a Tab moves focus elsewhere first. We now reject control characters in short values before forwarding, but a built-in option would help every caller: either set values directly without key events, or refuse control characters in typed values. Toggles are clicked by design, which is fine; we'd just like key events not to depend on value length.

Happy to send a PR for either if you agree on the shape.

Dominant language
TypeScript
Stars
59.8k
Forks
4.8k
Avg merge
2d 10h
Merged PRs (30d)
162

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ChromeDevTools/chrome-devtools-mcp

All issues in ChromeDevTools/chrome-devtools-mcp

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.