Conversation
DOM.setFileInputFiles is rejected under chrome.debugger (crbug 928255), so the extension opens the file chooser via interception and uses the backendNodeId from Page.fileChooserOpened. That only works when the input is rendered and the click is treated as a user gesture. Many sites hide a 0x0 <input type=file> behind a styled button and open it programmatically (e.g. Xiaohongshu's creator center, which triggers set-file-input on publish). Clicking such an input never opens a chooser, so set-file-input always failed with: Page.fileChooserOpened not received within 5s Temporarily make hidden inputs renderable and dispatch the click with Runtime.evaluate userGesture:true, then restore the original inline style. Add a cdp unit test covering the reveal/restore flow.
The setFileInputFiles cleanup calls chrome.debugger.onEvent.removeListener; the mock only provided addListener, so the test threw.
Contributor
Author
|
Pushed a fix for the failing extension test: the mock needed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
set-file-inputfails whenever the target file input is hidden, e.g. on the Xiaohongshu creator center:This breaks
opencli xiaohongshu publishandopencli browser <session> uploadfor those sites.Repro:
Root cause
DOM.setFileInputFilesis rejected underchrome.debugger(crbug 928255), so the extension opens the chooser viaPage.setInterceptFileChooserDialog+Runtime.evaluate.click()and uses thebackendNodeIdfromPage.fileChooserOpened. The chooser only opens for a rendered input and when the click carries a user gesture. A 0x0 hidden input (hidden<input type=file>behind a styled button - a very common pattern) never opens a chooser, so the event never fires and the call times out.Fix
Before clicking, if the input is not rendered (
display:none/visibility:hidden/opacity:0/ zero rect), temporarily reveal it (fixed 1x1 box) and click withRuntime.evaluate userGesture: true; restore the original inline style infinally.Tests
Added a
cdp setFileInputFilesunit test covering the reveal -> click(userGesture) -> restore flow and theDOM.setFileInputFilesbackendNodeIdhand-off. I could not run vitest locally in this environment (no node_modules, slow network); please rely on CI.