1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 02:14:58 +00:00
serenity/Tests/LibWeb/Text/input/input-file-accept.html
Timothy Flynn 6760d236e4 Ladybird+LibWeb+WebContent: Parse the <input type=file> accept attribute
This parses the accept attribute value for file input types and passes
it along to the browser chromes.
2024-03-16 08:42:33 +01:00

34 lines
1 KiB
HTML

<input id="input1" type="file" accept="text/plain" />
<input id="input2" type="file" accept="text/plain" multiple />
<input id="input3" type="file" accept=".cpp" />
<input id="input4" type="file" accept=".cpp" 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 file of input.files) {
const text = await file.text();
println(`${file.name}: ${file.type}: ${text}`);
}
resolve();
});
internals.dispatchUserActivatedEvent(input, new Event("mousedown"));
input.showPicker();
});
};
asyncTest(async done => {
await runTest("input1");
await runTest("input2");
await runTest("input3");
await runTest("input4");
done();
});
</script>