2025-03-18 19:28:35 +01:00
|
|
|
<!DOCTYPE html>
|
2024-02-25 13:02:47 -05:00
|
|
|
<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();
|
|
|
|
|
|
2024-03-13 16:05:32 -04:00
|
|
|
println(`${file.name} (index iteration): ${file.type}: ${text}`);
|
2024-03-13 15:29:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (let file of input.files) {
|
|
|
|
|
const text = await file.text();
|
|
|
|
|
|
2024-03-13 16:05:32 -04:00
|
|
|
println(`${file.name} (for..of iteration): ${file.type}: ${text}`);
|
2024-02-25 13:02:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resolve();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
internals.dispatchUserActivatedEvent(input, new Event("mousedown"));
|
|
|
|
|
input.showPicker();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
asyncTest(async done => {
|
|
|
|
|
await runTest("input1");
|
|
|
|
|
await runTest("input2");
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
</script>
|