https://github.com/web-platform-tests/wpt
Raw File
Tip revision: b0a5adb79b683700fb1a3e59dd2632387c506701 authored by Luke Bjerring on 29 March 2018, 17:14:00 UTC
Remove redundant Array.from
Tip revision: b0a5adb
test_securityerrors-manual.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>FileReader SecurityError Test</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://w3c.github.io/FileAPI/#dfn-error-codes">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<form name="upload">
  <input type="file" id="fileChooser"><br><input type="button" id="start" value="start">
</form>

<div>
  <p>Test steps:</p>
  <ol>
    <li>Select a system sensitive file (e.g. files in /usr/bin, password files,
        and other native operating system executables) in the file inputbox.</li>
    <li>Click the 'start' button.</li>
    </ol>
</div>

<script>

  const fileChooser = document.querySelector('#fileChooser');

  setup({explicit_done: true});
  setup({explicit_timeout: true});

  on_event(document.querySelector('#start'), 'click', () => {
    async_test(t => {
      const reader = new FileReader();
      reader.readAsArrayBuffer(fileChooser.files[0]);
      reader.onloadend = t.step_func_done(event => {
        assert_equals(event.target.readyState, FileReader.DONE);
        assert_equals(reader.error.name, "SecurityError");
      });
    }, 'FileReader.error should be SECURITY_ERROR if the file is a system sensitive file');
    done();
  });

</script>
back to top