1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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();
|