StructuredClone-serializable-FileList.html 829 B

1234567891011121314151617181920212223242526272829303132
  1. <input id="input1" type="file" multiple />
  2. <script src="../include.js"></script>
  3. <script>
  4. const runTest = async id => {
  5. let input = document.getElementById(id);
  6. return new Promise(resolve => {
  7. input.addEventListener("input", async () => {
  8. println(`${id}:`);
  9. let files = structuredClone(input.files);
  10. for (let file of input.files) {
  11. const text = await file.text();
  12. println(`${file.name}: ${file.type}: ${text}`);
  13. }
  14. resolve();
  15. });
  16. internals.dispatchUserActivatedEvent(input, new Event("mousedown"));
  17. input.showPicker();
  18. });
  19. }
  20. asyncTest(async done => {
  21. await runTest("input1");
  22. done();
  23. });
  24. </script>