submit-file.sub.html (844B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <body> 6 <iframe id=testframe name=testframe></iframe> 7 <form id=testform method=post action="//{{domains[www1]}}:{{location[port]}}/html/semantics/forms/form-submission-0/resources/file-submission.py" target=testframe enctype="multipart/form-data"> 8 <input name=testinput id=testinput type=file> 9 </form> 10 <script> 11 async_test(t => { 12 const dataTransfer = new DataTransfer(); 13 dataTransfer.items.add(new File(["foobar"], "name")); 14 assert_equals(1, dataTransfer.files.length); 15 16 testinput.files = dataTransfer.files; 17 testform.submit(); 18 19 onmessage = t.step_func(e => { 20 if (e.source !== testframe) return; 21 assert_equals(e.data, "foobar"); 22 t.done(); 23 }); 24 }, 'Posting a File'); 25 </script>