mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 15:27:34 +00: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:
parent
435c2c24d1
commit
108521a566
23 changed files with 307 additions and 5 deletions
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>
|
Loading…
Add table
Add a link
Reference in a new issue