mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb+LibWebView+WebContent: Implement more <input type=file> behavior
We had previous implemented some plumbing for file input elements in
commit 636602a54e.
This implements the return path for chromes to inform WebContent of the
file(s) the user selected. This patch includes a dummy implementation
for headless-browser to enable testing.
This commit is contained in:
committed by
Andreas Kling
parent
435c2c24d1
commit
108521a566
Notes:
sideshowbarker
2024-07-17 04:10:16 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/108521a566 Pull-request: https://github.com/SerenityOS/serenity/pull/23346
32
Tests/LibWeb/Text/input/input-file.html
Normal file
32
Tests/LibWeb/Text/input/input-file.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<input id="input1" type="file" />
|
||||
<input id="input2" type="file" multiple />
|
||||
<script src="./include.js"></script>
|
||||
<script type="text/javascript">
|
||||
const runTest = async id => {
|
||||
let input = document.getElementById(id);
|
||||
|
||||
return new Promise(resolve => {
|
||||
input.addEventListener("input", async () => {
|
||||
println(`${id}:`);
|
||||
|
||||
for (let i = 0; i < input.files.length; ++i) {
|
||||
const file = input.files.item(i);
|
||||
const text = await file.text();
|
||||
|
||||
println(`${file.name}: ${text}`);
|
||||
}
|
||||
|
||||
resolve();
|
||||
});
|
||||
|
||||
internals.dispatchUserActivatedEvent(input, new Event("mousedown"));
|
||||
input.showPicker();
|
||||
});
|
||||
};
|
||||
|
||||
asyncTest(async done => {
|
||||
await runTest("input1");
|
||||
await runTest("input2");
|
||||
done();
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user