diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-21 20:56:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-21 20:56:19 +0000 |
commit | 0b6210cd37b68b94252cb798598b12974a20e1c1 (patch) | |
tree | e371686554a877842d95aa94f100bee552ff2a8e /test/wpt/tests/FileAPI/FileReader | |
parent | Initial commit. (diff) | |
download | node-undici-0b6210cd37b68b94252cb798598b12974a20e1c1.tar.xz node-undici-0b6210cd37b68b94252cb798598b12974a20e1c1.zip |
Adding upstream version 5.28.2+dfsg1+~cs23.11.12.3.upstream/5.28.2+dfsg1+_cs23.11.12.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/wpt/tests/FileAPI/FileReader')
6 files changed, 214 insertions, 0 deletions
diff --git a/test/wpt/tests/FileAPI/FileReader/progress_event_bubbles_cancelable.html b/test/wpt/tests/FileAPI/FileReader/progress_event_bubbles_cancelable.html new file mode 100644 index 0000000..6a03243 --- /dev/null +++ b/test/wpt/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/test/wpt/tests/FileAPI/FileReader/support/file_test1.txt b/test/wpt/tests/FileAPI/FileReader/support/file_test1.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/wpt/tests/FileAPI/FileReader/support/file_test1.txt diff --git a/test/wpt/tests/FileAPI/FileReader/test_errors-manual.html b/test/wpt/tests/FileAPI/FileReader/test_errors-manual.html new file mode 100644 index 0000000..b8c3f84 --- /dev/null +++ b/test/wpt/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/test/wpt/tests/FileAPI/FileReader/test_notreadableerrors-manual.html b/test/wpt/tests/FileAPI/FileReader/test_notreadableerrors-manual.html new file mode 100644 index 0000000..46d7359 --- /dev/null +++ b/test/wpt/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/test/wpt/tests/FileAPI/FileReader/test_securityerrors-manual.html b/test/wpt/tests/FileAPI/FileReader/test_securityerrors-manual.html new file mode 100644 index 0000000..add93ed --- /dev/null +++ b/test/wpt/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/test/wpt/tests/FileAPI/FileReader/workers.html b/test/wpt/tests/FileAPI/FileReader/workers.html new file mode 100644 index 0000000..8e114ee --- /dev/null +++ b/test/wpt/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> |