Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(550)

Side by Side Diff: LayoutTests/fast/files/resources/blob-slice-common.js

Issue 57483002: Implement File constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed most feedback. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 var blob, file; // Populated by runTests() in individual tests.
2 var sliceParams = []; // Populated by individual tests.
3 var testIndex = 0;
4
5 function testSlicing(start, end, expectedResult, blob, doneCallback)
6 {
7 var blobClass = blob.constructor.name;
8 var sliced;
9 var reader = new FileReader();
10 var message = ".slice";
11 if (start === null && end === null) {
12 message += "()";
13 sliced = blob.slice();
14 } else if (end == undefined) {
15 message += "(" + start + ")";
16 sliced = blob.slice(start);
17 } else {
18 message += "(" + start + ", " + end + ")";
19 sliced = blob.slice(start, end);
20 }
21 reader.onloadend = function(event) {
22 var error = event.target.error;
23 if (error) {
24 testFailed("File read error " + message + error);
25 doneCallback();
26 return;
27 }
28 var blobContentsVar = blobClass.toLowerCase() + "Contents";
29 window[blobContentsVar] = event.target.result;
30 shouldBeEqualToString(blobContentsVar, expectedResult);
31 doneCallback();
32 };
33 debug(blobClass + " " + message);
34 reader.readAsText(sliced);
35 }
36
37 function runNextTest()
38 {
39 if (testIndex >= sliceTestCases.length) {
40 finishJSTest();
41 return;
42 }
43
44 var testCase = sliceTestCases[testIndex];
45 testIndex++;
46 testSlicing(testCase[0], testCase[1], testCase[2], blob, function() {
47 testSlicing(testCase[0], testCase[1], testCase[2], file, runNextTest);
48 });
49 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/files/file-constructor-expected.txt ('k') | LayoutTests/fast/files/script-tests/blob-constructor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698