2 "testReadingNonExistentFileBlob",
3 "testReadingNonExistentFileBlob2",
4 "testReadingEmptyFileBlob",
5 "testReadingEmptyTextBlob",
6 "testReadingEmptyFileAndTextBlob",
7 "testReadingSingleFileBlob",
8 "testReadingSingleTextBlob",
9 "testReadingSingleTextBlobAsDataURL",
10 "testReadingSingleTextBlobAsDataURL2",
11 "testReadingSingleArrayBufferBlob",
12 "testReadingSlicedFileBlob",
13 "testReadingSlicedTextBlob",
14 "testReadingSlicedArrayBufferBlob",
15 "testReadingMultipleFileBlob",
16 "testReadingMultipleTextBlob",
17 "testReadingMultipleArrayBufferBlob",
18 "testReadingHybridBlob",
19 "testReadingSlicedHybridBlob",
20 "testReadingTripleSlicedHybridBlob",
24 function runNextTest(testFiles
)
26 if (testIndex
< testCases
.length
) {
28 self
[testCases
[testIndex
- 1]](testFiles
);
34 function testReadingNonExistentFileBlob(testFiles
)
36 log("Test reading a blob containing non-existent file");
37 var blob
= buildBlob([testFiles
['non-existent']]);
38 readBlobAsBinaryString(testFiles
, blob
);
41 function testReadingNonExistentFileBlob2(testFiles
)
43 log("Test reading a blob containing existent and non-existent file");
44 var blob
= buildBlob([testFiles
['file1'], testFiles
['non-existent'], testFiles
['empty-file']]);
45 readBlobAsBinaryString(testFiles
, blob
);
48 function testReadingEmptyFileBlob(testFiles
)
50 log("Test reading a blob containing empty file");
51 var blob
= buildBlob([testFiles
['empty-file']]);
52 readBlobAsBinaryString(testFiles
, blob
);
55 function testReadingEmptyTextBlob(testFiles
)
57 log("Test reading a blob containing empty text");
58 var blob
= buildBlob(['']);
59 readBlobAsBinaryString(testFiles
, blob
);
62 function testReadingEmptyFileAndTextBlob(testFiles
)
64 log("Test reading a blob containing empty files and empty texts");
65 var blob
= buildBlob(['', testFiles
['empty-file'], '', testFiles
['empty-file']]);
66 readBlobAsBinaryString(testFiles
, blob
);
69 function testReadingSingleFileBlob(testFiles
)
71 log("Test reading a blob containing single file");
72 var blob
= buildBlob([testFiles
['file1']]);
73 readBlobAsBinaryString(testFiles
, blob
);
76 function testReadingSingleTextBlob(testFiles
)
78 log("Test reading a blob containing single text");
79 var blob
= buildBlob(['First']);
80 readBlobAsBinaryString(testFiles
, blob
);
83 function testReadingSingleTextBlobAsDataURL(testFiles
)
85 log("Test reading a blob containing single text as data URL");
86 var blob
= buildBlob(['First']);
87 readBlobAsDataURL(testFiles
, blob
);
90 function testReadingSingleTextBlobAsDataURL2(testFiles
)
92 log("Test reading a blob containing single text as data URL (optional content type provided)");
93 var blob
= buildBlob(['First'], 'type/foo');
94 readBlobAsDataURL(testFiles
, blob
);
97 function testReadingSingleArrayBufferBlob(testFiles
)
99 log("Test reading a blob containing single ArrayBuffer");
100 var array
= new Uint8Array([0, 1, 2, 128, 129, 130, 253, 254, 255]);
101 var blob
= buildBlob([array
]);
102 readBlobAsBinaryString(testFiles
, blob
);
105 function testReadingSlicedFileBlob(testFiles
)
107 log("Test reading a blob containing sliced file");
108 var blob
= buildBlob([testFiles
['file2'].slice(1, 6)]);
109 readBlobAsBinaryString(testFiles
, blob
);
112 function testReadingSlicedTextBlob(testFiles
)
114 log("Test reading a blob containing sliced text");
115 var blob
= buildBlob(['First'])
116 blob
= blob
.slice(1, 11);
117 readBlobAsBinaryString(testFiles
, blob
);
120 function testReadingSlicedArrayBufferBlob(testFiles
)
122 log("Test reading a blob containing sliced ArrayBuffer");
123 var array
= new Uint8Array([0, 1, 2, 128, 129, 130, 253, 254, 255]);
124 var blob
= buildBlob([array
])
125 blob
= blob
.slice(1, 11);
126 readBlobAsBinaryString(testFiles
, blob
);
129 function testReadingMultipleFileBlob(testFiles
)
131 log("Test reading a blob containing multiple files");
132 var blob
= buildBlob([testFiles
['file1'], testFiles
['file2'], testFiles
['file3']]);
133 readBlobAsBinaryString(testFiles
, blob
);
136 function testReadingMultipleTextBlob(testFiles
)
138 log("Test reading a blob containing multiple texts");
139 var blob
= buildBlob(['First', 'Second', 'Third']);
140 readBlobAsBinaryString(testFiles
, blob
);
143 function testReadingMultipleArrayBufferBlob(testFiles
)
145 log("Test reading a blob containing multiple ArrayBuffer");
146 var array1
= new Uint8Array([0, 1, 2]);
147 var array2
= new Uint8Array([128, 129, 130]);
148 var array3
= new Uint8Array([253, 254, 255]);
149 var blob
= buildBlob([array1
, array2
, array3
]);
150 readBlobAsBinaryString(testFiles
, blob
);
153 function testReadingHybridBlob(testFiles
)
155 log("Test reading a hybrid blob");
156 var array
= new Uint8Array([48, 49, 50]);
157 var blob
= buildBlob(['First', testFiles
['file1'], 'Second', testFiles
['file2'], testFiles
['file3'], 'Third', array
]);
158 readBlobAsBinaryString(testFiles
, blob
);
161 function testReadingSlicedHybridBlob(testFiles
)
163 log("Test reading a sliced hybrid blob");
164 var array
= new Uint8Array([48, 49, 50]);
165 var blob
= buildBlob(['First', testFiles
['file1'], 'Second', testFiles
['file2'], testFiles
['file3'], 'Third', array
]);
166 var blob
= blob
.slice(7, 19);
167 readBlobAsBinaryString(testFiles
, blob
);
170 function testReadingTripleSlicedHybridBlob(testFiles
)
172 log("Test reading a triple-sliced hybrid blob");
173 var array
= new Uint8Array([48, 49, 50]);
174 var items
= ['First', testFiles
['file1'].slice(1, 11), testFiles
['empty-file'], 'Second', testFiles
['file2'], testFiles
['file3'], 'Third', array
];
175 var blob
= buildBlob(items
);
176 var blob
= blob
.slice(7, 19);
177 var blob2
= buildBlob(items
.concat(['Foo', blob
, 'Bar']));
178 var blob2
= blob2
.slice(12, 42);
179 readBlobAsBinaryString(testFiles
, blob2
);