fix(input): prevent upload_file crash on chooser-opening elements#2354
Open
ashutoshsinghpr7 wants to merge 3 commits into
Open
fix(input): prevent upload_file crash on chooser-opening elements#2354ashutoshsinghpr7 wants to merge 3 commits into
ashutoshsinghpr7 wants to merge 3 commits into
Conversation
Closes ChromeDevTools#2310 Previously upload_file called handle.uploadFile() on every element, including chooser-opening proxy elements (e.g. a button that triggers input.click()). Calling uploadFile() on a non-file-input element causes Chrome to kill the renderer with RESULT_CODE_KILLED_BAD_MESSAGE. The tool description documents this use case as supported: 'The uid of the file input element or an element that will open file chooser on the page' Fix: check the element type before choosing the upload path: - <input type=file> → use uploadFile() directly (fast, safe) - Everything else → use waitForFileChooser() + click (safe proxy path)
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Summary
Fixes #2310 —
upload_filecrashes the Chrome tab withRESULT_CODE_KILLED_BAD_MESSAGEwhen used on a chooser-opening proxy element (e.g. a button that callsinput.click()).Root Cause
upload_filecalledhandle.uploadFile()on every element. This method is only valid for<input type="file">elements. Calling it on a button or other element sends an invalid IPC message to the renderer, causing Chrome to kill the tab.The crash happened before reaching the existing error-handling catch block, so the fallback
waitForFileChooser()path was never reached.Fix
Check the element type before choosing the upload path:
<input type="file">→ useuploadFile()directly (fast, safe, unchanged behavior)waitForFileChooser()+click()(handles proxy elements correctly)This matches the documented behavior:
Testing
Self-contained repro from the issue:
new_pagewith a page containing a hidden<input type="file">+ button that triggersinput.click()take_snapshot→ get button uidupload_filewith button uid → no longer crashes tab, file upload succeeds via chooserExisting file input direct-upload path is unchanged and continues to work.