forked from web-platform-tests/wpt-actions-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement read methods on FileReaderSync
Upstreamed from servo/servo#19511 [ci skip]
- Loading branch information
Showing
1 changed file
with
43 additions
and
15 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,28 +1,56 @@ | ||
importScripts("/resources/testharness.js"); | ||
|
||
var blob, readerSync; | ||
setup(function() { | ||
readerSync = new FileReaderSync(); | ||
blob = new Blob(["test"]); | ||
var blob, empty_blob, readerSync; | ||
setup(() => { | ||
readerSync = new FileReaderSync(); | ||
blob = new Blob(["test"]); | ||
empty_blob = new Blob(); | ||
}); | ||
|
||
test(function() { | ||
assert_true(readerSync instanceof FileReaderSync); | ||
test(() => { | ||
assert_true(readerSync instanceof FileReaderSync); | ||
}, "Interface"); | ||
|
||
test(function() { | ||
var text = readerSync.readAsText(blob); | ||
assert_equals(text, "test"); | ||
test(() => { | ||
var text = readerSync.readAsText(blob); | ||
assert_equals(text, "test"); | ||
}, "readAsText"); | ||
|
||
test(function() { | ||
var data = readerSync.readAsDataURL(blob); | ||
assert_equals(data.indexOf("data:"), 0); | ||
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(function() { | ||
var data = readerSync.readAsArrayBuffer(blob); | ||
assert_true(data instanceof ArrayBuffer); | ||
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(); |