test_notreadableerrors-manual.html (1326B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>FileReader NotReadableError Test</title> 4 <link rel="author" title="Intel" href="http://www.intel.com"> 5 <link rel="help" href="https://w3c.github.io/FileAPI/#dfn-error-codes"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <form name="upload"> 9 <input type="file" id="fileChooser"><br><input type="button" id="start" value="start"> 10 </form> 11 12 <div> 13 <p>Test steps:</p> 14 <ol> 15 <li>Download the <a href="support/file_test1.txt">file</a>.</li> 16 <li>Select the file in the file inputbox.</li> 17 <li>Delete the file's readable permission.</li> 18 <li>Click the 'start' button.</li> 19 </ol> 20 </div> 21 22 <script> 23 24 const fileChooser = document.querySelector('#fileChooser'); 25 26 setup({explicit_done: true}); 27 setup({explicit_timeout: true}); 28 29 on_event(document.querySelector('#start'), 'click', () => { 30 async_test(t => { 31 const reader = new FileReader(); 32 reader.readAsArrayBuffer(fileChooser.files[0]); 33 reader.onloadend = t.step_func_done(event => { 34 assert_equals(event.target.readyState, FileReader.DONE); 35 assert_equals(reader.error.name, "NotReadableError"); 36 }); 37 }, 'FileReader.error should be NotReadableError if the file is unreadable'); 38 done(); 39 }); 40 41 </script>