GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: add wpt tests for Blob · nodejs/node@d73d58d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test
    • fixtures/wpt
      • FileAPI
        • BlobURL
          • support
            • file_test2.txt
          • test2-manual.html
        • FileReaderSync.worker.js
        • FileReader
          • progress_event_bubbles_cancelable.html
          • support
            • file_test1.txt
          • test_errors-manual.html
          • test_notreadableerrors-manual.html
          • test_securityerrors-manual.html
          • workers.html
        • META.yml
        • blob
          • Blob-array-buffer.any.js
          • Blob-constructor-endings.html
          • Blob-constructor.html
          • Blob-in-worker.worker.js
          • Blob-slice-overflow.html
          • Blob-slice.html
          • Blob-stream.any.js
          • Blob-text.any.js
        • fileReader.html
        • filelist-section
          • filelist.html
          • filelist_multiple_selected_files-manual.html
          • filelist_selected_file-manual.html
          • support
            • upload.txt
            • upload.zip
        • file
          • File-constructor-endings.html
          • File-constructor.html
          • Worker-read-file-constructor.worker.js
          • send-file-form-controls.tentative.html
          • send-file-form-iso-2022-jp.tentative.html
          • send-file-form-punctuation.tentative.html
          • send-file-form-utf-8.html
          • send-file-form-windows-1252.tentative.html
          • send-file-form-x-user-defined.tentative.html
          • send-file-form.html
          • send-file-formdata-controls.tentative.html
          • send-file-formdata-punctuation.tentative.html
          • send-file-formdata-utf-8.html
          • send-file-formdata.html
        • historical.https.html
        • idlharness-manual.html
        • idlharness.html
        • idlharness.worker.js
        • progress-manual.html
        • reading-data-section
          • Determining-Encoding.html
          • FileReader-event-handler-attributes.html
          • FileReader-multiple-reads.html
          • filereader_abort.html
          • filereader_error.html
          • filereader_events.any.js
          • filereader_file-manual.html
          • filereader_file_img-manual.html
          • filereader_readAsArrayBuffer.html
          • filereader_readAsBinaryString.html
          • filereader_readAsDataURL.html
          • filereader_readAsText.html
          • filereader_readystate.html
          • filereader_result.html
          • support
            • blue-100x100.png
        • support
          • Blob.js
          • document-domain-setter.sub.html
          • historical-serviceworker.js
          • incumbent.sub.html
          • send-file-form-helper.js
          • send-file-formdata-helper.js
          • upload.txt
          • url-origin.html
        • unicode.html
        • url
          • cross-global-revoke.sub.html
          • multi-global-origin-serialization.sub.html
          • resources
            • create-helper.html
            • create-helper.js
            • fetch-tests.js
            • revoke-helper.html
            • revoke-helper.js
          • sandboxed-iframe.html
          • unicode-origin.sub.html
          • url-charset.window.js
          • url-format.any.js
          • url-in-tags-revoke.window.js
          • url-in-tags.window.js
          • url-lifetime.html
          • url-reload.window.js
          • url-with-fetch.any.js
          • url-with-xhr.any.js
          • url_createobjecturl_file-manual.html
          • url_createobjecturl_file_img-manual.html
          • url_xmlhttprequest_img-ref.html
          • url_xmlhttprequest_img.html
      • README.md
      • versions.json
    • wpt
      • status/FileAPI
        • blob.json
      • test-blob.js

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/fixtures/wpt/FileAPI/BlobURL/support/file_test2.txt‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/FileAPI/BlobURL/support/file_test2.txt
Whitespace-only changes.
Collapse file

‎test/fixtures/wpt/FileAPI/BlobURL/test2-manual.html‎

Copy file name to clipboard
+62Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Blob and File reference URL Test(2)</title>
6+
<link rel=help href="http://dev.w3.org/2006/webapi/FileAPI/#convenienceAPI">
7+
<link rel=author title="Breezewish" href="mailto:[email protected]">
8+
<script src="/resources/testharness.js"></script>
9+
<script src="/resources/testharnessreport.js"></script>
10+
</head>
11+
<body>
12+
<form name="upload">
13+
<input type="file" id="fileChooser"><br><input type="button" id="start" value="start">
14+
</form>
15+
16+
<div>
17+
<p>Test steps:</p>
18+
<ol>
19+
<li>Download the <a href="support/file_test2.txt">file</a>.</li>
20+
<li>Select the file in the file inputbox.</li>
21+
<li>Delete the file.</li>
22+
<li>Click the 'start' button.</li>
23+
</ol>
24+
</div>
25+
26+
<div id="log"></div>
27+
28+
<script>
29+
30+
var fileChooser = document.querySelector('#fileChooser');
31+
32+
setup({explicit_done: true});
33+
setup({explicit_timeout: true});
34+
35+
on_event(document.querySelector('#start'), 'click', function() {
36+
37+
async_test(function(t) {
38+
39+
var url = URL.createObjectURL(fileChooser.files[0]);
40+
41+
var xhr = new XMLHttpRequest();
42+
xhr.open('GET', url, true);
43+
xhr.onreadystatechange = t.step_func(function() {
44+
switch (xhr.readyState) {
45+
case xhr.DONE:
46+
assert_equals(xhr.status, 500, 'status code should be 500.');
47+
t.done();
48+
return;
49+
}
50+
});
51+
52+
xhr.send();
53+
54+
}, 'Check whether the browser response 500 in XHR if the selected file which File/Blob URL refered is not found');
55+
56+
done();
57+
58+
});
59+
60+
</script>
61+
</body>
62+
</html>
Collapse file

‎test/fixtures/wpt/FileAPI/FileReader/progress_event_bubbles_cancelable.html‎

Copy file name to clipboard
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>File API Test: Progress Event - bubbles, cancelable</title>
4+
<link rel="author" title="Intel" href="http://www.intel.com">
5+
<link rel="help" href="http://www.w3.org/TR/FileAPI/#events">
6+
<script src="/resources/testharness.js"></script>
7+
<script src="/resources/testharnessreport.js"></script>
8+
<div id="log"></div>
9+
<script>
10+
async_test(function(){
11+
var blob = new Blob(["TEST"]);
12+
var reader = new FileReader();
13+
14+
reader.onloadstart = this.step_func(function(evt) {
15+
assert_false(evt.bubbles, "The bubbles must be false when the event is dispatched");
16+
assert_false(evt.cancelable, "The cancelable must be false when the event is dispatched");
17+
});
18+
19+
reader.onload = this.step_func(function(evt) {
20+
assert_false(evt.bubbles, "The bubbles must be false when the event is dispatched");
21+
assert_false(evt.cancelable, "The cancelable must be false when the event is dispatched");
22+
});
23+
24+
reader.onloadend = this.step_func(function(evt) {
25+
assert_false(evt.bubbles, "The bubbles must be false when the event is dispatched");
26+
assert_false(evt.cancelable, "The cancelable must be false when the event is dispatched");
27+
this.done();
28+
});
29+
30+
reader.readAsText(blob);
31+
}, "Check the values of bubbles and cancelable are false when the progress event is dispatched");
32+
</script>
33+
Collapse file

‎test/fixtures/wpt/FileAPI/FileReader/support/file_test1.txt‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/FileAPI/FileReader/support/file_test1.txt
Whitespace-only changes.
Collapse file

‎test/fixtures/wpt/FileAPI/FileReader/test_errors-manual.html‎

Copy file name to clipboard
+72Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>FileReader Errors Test</title>
6+
<link rel=help href="http://dev.w3.org/2006/webapi/FileAPI/#convenienceAPI">
7+
<link rel=author title="Breezewish" href="mailto:[email protected]">
8+
<script src="/resources/testharness.js"></script>
9+
<script src="/resources/testharnessreport.js"></script>
10+
</head>
11+
<body>
12+
<form name="upload">
13+
<input type="file" id="fileChooser"><br><input type="button" id="start" value="start">
14+
</form>
15+
16+
<div>
17+
<p>Test steps:</p>
18+
<ol>
19+
<li>Download the <a href="support/file_test1.txt">file</a>.</li>
20+
<li>Select the file in the file inputbox.</li>
21+
<li>Delete the file.</li>
22+
<li>Click the 'start' button.</li>
23+
</ol>
24+
</div>
25+
26+
<div id="log"></div>
27+
28+
<script>
29+
30+
var fileChooser = document.querySelector('#fileChooser');
31+
32+
setup({explicit_done: true});
33+
setup({explicit_timeout: true});
34+
35+
on_event(fileChooser, 'change', function() {
36+
37+
async_test(function(t) {
38+
39+
var reader = new FileReader();
40+
reader.readAsArrayBuffer(fileChooser.files[0]);
41+
42+
reader.onloadend = t.step_func_done(function(event) {
43+
assert_equals(event.target.readyState, FileReader.DONE);
44+
assert_equals(reader.error, null);
45+
});
46+
47+
}, 'FileReader.error should be null if there are no errors when reading');
48+
49+
});
50+
51+
on_event(document.querySelector('#start'), 'click', function() {
52+
53+
async_test(function(t) {
54+
55+
var reader = new FileReader();
56+
reader.readAsArrayBuffer(fileChooser.files[0]);
57+
58+
reader.onloadend = t.step_func_done(function(event) {
59+
assert_equals(event.target.readyState, FileReader.DONE);
60+
assert_equals(reader.error.code, 8);
61+
assert_true(reader.error instanceof DOMException);
62+
});
63+
64+
}, 'FileReader.error should be NOT_FOUND_ERR if the file is not found when reading');
65+
66+
done();
67+
68+
});
69+
70+
</script>
71+
</body>
72+
</html>
Collapse file

‎test/fixtures/wpt/FileAPI/FileReader/test_notreadableerrors-manual.html‎

Copy file name to clipboard
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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>
42+
Collapse file

‎test/fixtures/wpt/FileAPI/FileReader/test_securityerrors-manual.html‎

Copy file name to clipboard
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>FileReader SecurityError 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>Select a system sensitive file (e.g. files in /usr/bin, password files,
16+
and other native operating system executables) in the file inputbox.</li>
17+
<li>Click the 'start' button.</li>
18+
</ol>
19+
</div>
20+
21+
<script>
22+
23+
const fileChooser = document.querySelector('#fileChooser');
24+
25+
setup({explicit_done: true});
26+
setup({explicit_timeout: true});
27+
28+
on_event(document.querySelector('#start'), 'click', () => {
29+
async_test(t => {
30+
const reader = new FileReader();
31+
reader.readAsArrayBuffer(fileChooser.files[0]);
32+
reader.onloadend = t.step_func_done(event => {
33+
assert_equals(event.target.readyState, FileReader.DONE);
34+
assert_equals(reader.error.name, "SecurityError");
35+
});
36+
}, 'FileReader.error should be SECURITY_ERROR if the file is a system sensitive file');
37+
done();
38+
});
39+
40+
</script>
Collapse file

‎test/fixtures/wpt/FileAPI/FileReader/workers.html‎

Copy file name to clipboard
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<meta charset=utf-8>
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<script>
6+
7+
async_test(t => {
8+
function workerCode() {
9+
close();
10+
var blob = new Blob([123]);
11+
var fr = new FileReader();
12+
fr.readAsText(blob);
13+
fr.abort()
14+
fr.readAsArrayBuffer(blob);
15+
postMessage(true);
16+
}
17+
18+
var workerBlob = new Blob([workerCode.toString() + ";workerCode();"], {type:"application/javascript"});
19+
20+
var w = new Worker(URL.createObjectURL(workerBlob));
21+
w.onmessage = function(e) {
22+
assert_true(e.data, "FileReader created during worker shutdown.");
23+
t.done();
24+
}
25+
}, 'FileReader created after a worker self.close()');
26+
27+
</script>
Collapse file

‎test/fixtures/wpt/FileAPI/FileReaderSync.worker.js‎

Copy file name to clipboard
+56Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
importScripts("/resources/testharness.js");
2+
3+
var blob, empty_blob, readerSync;
4+
setup(() => {
5+
readerSync = new FileReaderSync();
6+
blob = new Blob(["test"]);
7+
empty_blob = new Blob();
8+
});
9+
10+
test(() => {
11+
assert_true(readerSync instanceof FileReaderSync);
12+
}, "Interface");
13+
14+
test(() => {
15+
var text = readerSync.readAsText(blob);
16+
assert_equals(text, "test");
17+
}, "readAsText");
18+
19+
test(() => {
20+
var text = readerSync.readAsText(empty_blob);
21+
assert_equals(text, "");
22+
}, "readAsText with empty blob");
23+
24+
test(() => {
25+
var data = readerSync.readAsDataURL(blob);
26+
assert_equals(data.indexOf("data:"), 0);
27+
}, "readAsDataURL");
28+
29+
test(() => {
30+
var data = readerSync.readAsDataURL(empty_blob);
31+
assert_equals(data.indexOf("data:"), 0);
32+
}, "readAsDataURL with empty blob");
33+
34+
test(() => {
35+
var data = readerSync.readAsBinaryString(blob);
36+
assert_equals(data, "test");
37+
}, "readAsBinaryString");
38+
39+
test(() => {
40+
var data = readerSync.readAsBinaryString(empty_blob);
41+
assert_equals(data, "");
42+
}, "readAsBinaryString with empty blob");
43+
44+
test(() => {
45+
var data = readerSync.readAsArrayBuffer(blob);
46+
assert_true(data instanceof ArrayBuffer);
47+
assert_equals(data.byteLength, "test".length);
48+
}, "readAsArrayBuffer");
49+
50+
test(() => {
51+
var data = readerSync.readAsArrayBuffer(empty_blob);
52+
assert_true(data instanceof ArrayBuffer);
53+
assert_equals(data.byteLength, 0);
54+
}, "readAsArrayBuffer with empty blob");
55+
56+
done();
Collapse file

‎test/fixtures/wpt/FileAPI/META.yml‎

Copy file name to clipboard
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
spec: https://w3c.github.io/FileAPI/
2+
suggested_reviewers:
3+
- inexorabletash
4+
- zqzhang
5+
- jdm
6+
- mkruisselbrink

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.