ladybird/Tests/LibWeb/Text/input/input-file.html
Timothy Flynn f55471333b LibWeb: Set the MIME type when creating an <input> element's File list
We were passing the MIME type to the underlying Blob, but the factory
for creating a File only checks an explicit options structure.
2024-03-14 10:10:33 +01:00

38 lines
1.1 KiB
HTML

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