diff options
Diffstat (limited to 'testing/web-platform/tests/FileAPI/FileReader')
6 files changed, 214 insertions, 0 deletions
diff --git a/testing/web-platform/tests/FileAPI/FileReader/progress_event_bubbles_cancelable.html b/testing/web-platform/tests/FileAPI/FileReader/progress_event_bubbles_cancelable.html new file mode 100644 index 0000000000..6a03243f93 --- /dev/null +++ b/testing/web-platform/tests/FileAPI/FileReader/progress_event_bubbles_cancelable.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>File API Test: Progress Event - bubbles, cancelable</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="http://www.w3.org/TR/FileAPI/#events"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + async_test(function(){ + var blob = new Blob(["TEST"]); + var reader = new FileReader(); + + reader.onloadstart = this.step_func(function(evt) { + assert_false(evt.bubbles, "The bubbles must be false when the event is dispatched"); + assert_false(evt.cancelable, "The cancelable must be false when the event is dispatched"); + }); + + reader.onload = this.step_func(function(evt) { + assert_false(evt.bubbles, "The bubbles must be false when the event is dispatched"); + assert_false(evt.cancelable, "The cancelable must be false when the event is dispatched"); + }); + + reader.onloadend = this.step_func(function(evt) { + assert_false(evt.bubbles, "The bubbles must be false when the event is dispatched"); + assert_false(evt.cancelable, "The cancelable must be false when the event is dispatched"); + this.done(); + }); + + reader.readAsText(blob); + }, "Check the values of bubbles and cancelable are false when the progress event is dispatched"); +</script> + diff --git a/testing/web-platform/tests/FileAPI/FileReader/support/file_test1.txt b/testing/web-platform/tests/FileAPI/FileReader/support/file_test1.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testing/web-platform/tests/FileAPI/FileReader/support/file_test1.txt diff --git a/testing/web-platform/tests/FileAPI/FileReader/test_errors-manual.html b/testing/web-platform/tests/FileAPI/FileReader/test_errors-manual.html new file mode 100644 index 0000000000..b8c3f84d2b --- /dev/null +++ b/testing/web-platform/tests/FileAPI/FileReader/test_errors-manual.html @@ -0,0 +1,72 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8"> + <title>FileReader Errors Test</title> + <link rel=help href="http://dev.w3.org/2006/webapi/FileAPI/#convenienceAPI"> + <link rel=author title="Breezewish" href="mailto:me@breeswish.org"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> +</head> +<body> + <form name="upload"> + <input type="file" id="fileChooser"><br><input type="button" id="start" value="start"> + </form> + + <div> + <p>Test steps:</p> + <ol> + <li>Download the <a href="support/file_test1.txt">file</a>.</li> + <li>Select the file in the file inputbox.</li> + <li>Delete the file.</li> + <li>Click the 'start' button.</li> + </ol> + </div> + + <div id="log"></div> + + <script> + + var fileChooser = document.querySelector('#fileChooser'); + + setup({explicit_done: true}); + setup({explicit_timeout: true}); + + on_event(fileChooser, 'change', function() { + + async_test(function(t) { + + var reader = new FileReader(); + reader.readAsArrayBuffer(fileChooser.files[0]); + + reader.onloadend = t.step_func_done(function(event) { + assert_equals(event.target.readyState, FileReader.DONE); + assert_equals(reader.error, null); + }); + + }, 'FileReader.error should be null if there are no errors when reading'); + + }); + + on_event(document.querySelector('#start'), 'click', function() { + + async_test(function(t) { + + var reader = new FileReader(); + reader.readAsArrayBuffer(fileChooser.files[0]); + + reader.onloadend = t.step_func_done(function(event) { + assert_equals(event.target.readyState, FileReader.DONE); + assert_equals(reader.error.code, 8); + assert_true(reader.error instanceof DOMException); + }); + + }, 'FileReader.error should be NOT_FOUND_ERR if the file is not found when reading'); + + done(); + + }); + + </script> +</body> +</html> diff --git a/testing/web-platform/tests/FileAPI/FileReader/test_notreadableerrors-manual.html b/testing/web-platform/tests/FileAPI/FileReader/test_notreadableerrors-manual.html new file mode 100644 index 0000000000..46d73598a0 --- /dev/null +++ b/testing/web-platform/tests/FileAPI/FileReader/test_notreadableerrors-manual.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>FileReader NotReadableError 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>Download the <a href="support/file_test1.txt">file</a>.</li> + <li>Select the file in the file inputbox.</li> + <li>Delete the file's readable permission.</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, "NotReadableError"); + }); + }, 'FileReader.error should be NotReadableError if the file is unreadable'); + done(); + }); + +</script> + diff --git a/testing/web-platform/tests/FileAPI/FileReader/test_securityerrors-manual.html b/testing/web-platform/tests/FileAPI/FileReader/test_securityerrors-manual.html new file mode 100644 index 0000000000..add93ed69d --- /dev/null +++ b/testing/web-platform/tests/FileAPI/FileReader/test_securityerrors-manual.html @@ -0,0 +1,40 @@ +<!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> diff --git a/testing/web-platform/tests/FileAPI/FileReader/workers.html b/testing/web-platform/tests/FileAPI/FileReader/workers.html new file mode 100644 index 0000000000..8e114eeaf8 --- /dev/null +++ b/testing/web-platform/tests/FileAPI/FileReader/workers.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + +async_test(t => { + function workerCode() { + close(); + var blob = new Blob([123]); + var fr = new FileReader(); + fr.readAsText(blob); + fr.abort() + fr.readAsArrayBuffer(blob); + postMessage(true); + } + + var workerBlob = new Blob([workerCode.toString() + ";workerCode();"], {type:"application/javascript"}); + + var w = new Worker(URL.createObjectURL(workerBlob)); + w.onmessage = function(e) { + assert_true(e.data, "FileReader created during worker shutdown."); + t.done(); + } +}, 'FileReader created after a worker self.close()'); + +</script> |