Implement input type=file support (FileList, input.files/value, DOM.setFileInputFiles)#2635
Merged
Merged
Conversation
…tFiles
Populate FileList with real File objects and expose them on
HTMLInputElement:
- input.files returns a live, identity-stable FileList for type=file
(null for other input types)
- input.value returns the spec "C:\fakepath\<name>" string
- required file inputs report value-missing only when empty
Implement CDP DOM.setFileInputFiles: load files from disk into a file
input (MIME sniffed by extension) and fire input + change events.
File backing arenas are reference counted via their Blob proto, so the
owning Frame now acquires/releases them and frees any still held at
teardown, preventing an ArenaPool leak for CDP-set files never read
from JS. A scoped errdefer frees partially-created files when one path
in a multi-file set fails to load.
Ar-maan05
force-pushed
the
feat-implement-file-api
branch
from
June 4, 2026 10:32
6932a13 to
7524a75
Compare
Contributor
Author
|
Friendly ping! Resolved all merge conflicts. Let me know if any changes are needed. |
Small formatting tweaks
Collaborator
|
Thank you. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What
Implements
<input type=file>support, building on the W3CBlob/FileAPI in the first commit.FileListnow backs a real[]*File(was a zero-size stub):lengthanditem(i)work.input.filesreturns a live, identity-stableFileListfortype=file, andnullfor every other input type (per the IDL).input.valuereturns the specC:\fakepath\<name>string for file inputs; setting it to anything but""throws.valueMissingonly when empty (was a hardcoded always-emptyTODO).DOM.setFileInputFilesloads files from disk into a file input, sniffs MIME by extension, and firesinput+change: the upload entry point for WebDriver/automation.Memory ownership
File/Blobown a reference-counted pooled arena, normally released when V8 finalizes the JS wrapper. Files set via CDP may never be read from JS, so the owningFramenow tracks each input'sFileList,acquireRefs the files it holds, and releases them at teardown, mirroring howURL.createObjectURLblobs are managed. Without this they leak an arena (caught by the test runner's leak detector). A scopederrdeferalso frees partially-created files if one path in a multi-file set fails to load.Not in scope
DataTransferTests
element/html/input_file.html:filesidentity/length/item,nullfor non-file inputs,valuegetter/setter.cdp.dom: setFileInputFiles: happy path, non-input node, missing node id, and partial-failure (no-leak) path.make testgreen;zig fmt --checkclean.Closes #2175