1 var blob
, file
; // Populated by runTests() in individual tests.
2 var sliceParams
= []; // Populated by individual tests.
5 function testSlicing(start
, end
, expectedResult
, blob
, doneCallback
)
7 var blobClass
= blob
.constructor.name
;
9 var reader
= new FileReader();
10 var message
= ".slice";
11 if (start
=== null && end
=== null) {
13 sliced
= blob
.slice();
14 } else if (end
== undefined) {
15 message
+= "(" + start
+ ")";
16 sliced
= blob
.slice(start
);
18 message
+= "(" + start
+ ", " + end
+ ")";
19 sliced
= blob
.slice(start
, end
);
21 reader
.onloadend = function(event
) {
22 var error
= event
.target
.error
;
24 testFailed("File read error " + message
+ error
);
28 var blobContentsVar
= blobClass
.toLowerCase() + "Contents";
29 window
[blobContentsVar
] = event
.target
.result
;
30 shouldBeEqualToString(blobContentsVar
, expectedResult
);
33 debug(blobClass
+ " " + message
);
34 reader
.readAsText(sliced
);
37 function runNextTest()
39 if (testIndex
>= sliceTestCases
.length
) {
44 var testCase
= sliceTestCases
[testIndex
];
46 testSlicing(testCase
[0], testCase
[1], testCase
[2], blob
, function() {
47 testSlicing(testCase
[0], testCase
[1], testCase
[2], file
, runNextTest
);