-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #36811 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
- Loading branch information
Showing
92 changed files
with
5,272 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Blob and File reference URL Test(2)</title> | ||
<link rel=help href="http://dev.w3.org/2006/webapi/FileAPI/#convenienceAPI"> | ||
<link rel=author title="Breezewish" href="mailto:[email protected]"> | ||
<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_test2.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(document.querySelector('#start'), 'click', function() { | ||
|
||
async_test(function(t) { | ||
|
||
var url = URL.createObjectURL(fileChooser.files[0]); | ||
|
||
var xhr = new XMLHttpRequest(); | ||
xhr.open('GET', url, true); | ||
xhr.onreadystatechange = t.step_func(function() { | ||
switch (xhr.readyState) { | ||
case xhr.DONE: | ||
assert_equals(xhr.status, 500, 'status code should be 500.'); | ||
t.done(); | ||
return; | ||
} | ||
}); | ||
|
||
xhr.send(); | ||
|
||
}, 'Check whether the browser response 500 in XHR if the selected file which File/Blob URL refered is not found'); | ||
|
||
done(); | ||
|
||
}); | ||
|
||
</script> | ||
</body> | ||
</html> |
33 changes: 33 additions & 0 deletions
33
test/fixtures/wpt/FileAPI/FileReader/progress_event_bubbles_cancelable.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
|
Empty file.
72 changes: 72 additions & 0 deletions
72
test/fixtures/wpt/FileAPI/FileReader/test_errors-manual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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:[email protected]"> | ||
<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> |
42 changes: 42 additions & 0 deletions
42
test/fixtures/wpt/FileAPI/FileReader/test_notreadableerrors-manual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
|
40 changes: 40 additions & 0 deletions
40
test/fixtures/wpt/FileAPI/FileReader/test_securityerrors-manual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
importScripts("/resources/testharness.js"); | ||
|
||
var blob, empty_blob, readerSync; | ||
setup(() => { | ||
readerSync = new FileReaderSync(); | ||
blob = new Blob(["test"]); | ||
empty_blob = new Blob(); | ||
}); | ||
|
||
test(() => { | ||
assert_true(readerSync instanceof FileReaderSync); | ||
}, "Interface"); | ||
|
||
test(() => { | ||
var text = readerSync.readAsText(blob); | ||
assert_equals(text, "test"); | ||
}, "readAsText"); | ||
|
||
test(() => { | ||
var text = readerSync.readAsText(empty_blob); | ||
assert_equals(text, ""); | ||
}, "readAsText with empty blob"); | ||
|
||
test(() => { | ||
var data = readerSync.readAsDataURL(blob); | ||
assert_equals(data.indexOf("data:"), 0); | ||
}, "readAsDataURL"); | ||
|
||
test(() => { | ||
var data = readerSync.readAsDataURL(empty_blob); | ||
assert_equals(data.indexOf("data:"), 0); | ||
}, "readAsDataURL with empty blob"); | ||
|
||
test(() => { | ||
var data = readerSync.readAsBinaryString(blob); | ||
assert_equals(data, "test"); | ||
}, "readAsBinaryString"); | ||
|
||
test(() => { | ||
var data = readerSync.readAsBinaryString(empty_blob); | ||
assert_equals(data, ""); | ||
}, "readAsBinaryString with empty blob"); | ||
|
||
test(() => { | ||
var data = readerSync.readAsArrayBuffer(blob); | ||
assert_true(data instanceof ArrayBuffer); | ||
assert_equals(data.byteLength, "test".length); | ||
}, "readAsArrayBuffer"); | ||
|
||
test(() => { | ||
var data = readerSync.readAsArrayBuffer(empty_blob); | ||
assert_true(data instanceof ArrayBuffer); | ||
assert_equals(data.byteLength, 0); | ||
}, "readAsArrayBuffer with empty blob"); | ||
|
||
done(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
spec: https://w3c.github.io/FileAPI/ | ||
suggested_reviewers: | ||
- inexorabletash | ||
- zqzhang | ||
- jdm | ||
- mkruisselbrink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// META: title=Blob Array Buffer | ||
// META: script=../support/Blob.js | ||
'use strict'; | ||
|
||
promise_test(async () => { | ||
const input_arr = new TextEncoder().encode("PASS"); | ||
const blob = new Blob([input_arr]); | ||
const array_buffer = await blob.arrayBuffer(); | ||
assert_true(array_buffer instanceof ArrayBuffer); | ||
assert_equals_typed_array(new Uint8Array(array_buffer), input_arr); | ||
}, "Blob.arrayBuffer()") | ||
|
||
promise_test(async () => { | ||
const input_arr = new TextEncoder().encode(""); | ||
const blob = new Blob([input_arr]); | ||
const array_buffer = await blob.arrayBuffer(); | ||
assert_true(array_buffer instanceof ArrayBuffer); | ||
assert_equals_typed_array(new Uint8Array(array_buffer), input_arr); | ||
}, "Blob.arrayBuffer() empty Blob data") | ||
|
||
promise_test(async () => { | ||
const input_arr = new TextEncoder().encode("\u08B8\u000a"); | ||
const blob = new Blob([input_arr]); | ||
const array_buffer = await blob.arrayBuffer(); | ||
assert_equals_typed_array(new Uint8Array(array_buffer), input_arr); | ||
}, "Blob.arrayBuffer() non-ascii input") | ||
|
||
promise_test(async () => { | ||
const input_arr = [8, 241, 48, 123, 151]; | ||
const typed_arr = new Uint8Array(input_arr); | ||
const blob = new Blob([typed_arr]); | ||
const array_buffer = await blob.arrayBuffer(); | ||
assert_equals_typed_array(new Uint8Array(array_buffer), typed_arr); | ||
}, "Blob.arrayBuffer() non-unicode input") | ||
|
||
promise_test(async () => { | ||
const input_arr = new TextEncoder().encode("PASS"); | ||
const blob = new Blob([input_arr]); | ||
const array_buffer_results = await Promise.all([blob.arrayBuffer(), | ||
blob.arrayBuffer(), blob.arrayBuffer()]); | ||
for (let array_buffer of array_buffer_results) { | ||
assert_true(array_buffer instanceof ArrayBuffer); | ||
assert_equals_typed_array(new Uint8Array(array_buffer), input_arr); | ||
} | ||
}, "Blob.arrayBuffer() concurrent reads") |
Oops, something went wrong.