file_upload.sub.html (819B)
1 <!doctype html> 2 <meta charset=utf8> 3 <title>File upload using testdriver</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/resources/testdriver.js"></script> 7 <script src="/resources/testdriver-vendor.js"></script> 8 <form id="form"> 9 <input id="file_input" name="file_input" type="file"> 10 </form> 11 <script> 12 promise_test(() => { 13 let form = document.getElementById("form"); 14 let input = document.getElementById("file_input"); 15 return test_driver 16 .send_keys(input, String.raw`{{fs_path(file_upload_data.txt)}}`) 17 .then(() => 18 fetch("file_upload.py", 19 {method: "POST", 20 body: new FormData(form)})) 21 .then(response => response.text()) 22 .then(data => { 23 assert_equals(data, "PASS"); 24 }); 25 }); 26 </script>