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

Side by Side Diff: LayoutTests/fast/files/blob-slice-test.html

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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script>
5 <script src="resources/blob-slice-common.js"></script>
4 <script> 6 <script>
5 var blob; 7 description("Test Blob.slice().");
6 var testIndex = 0; 8
7 var sliceParams = [ 9 var sliceTestCases = [
8 [2, 3], 10 [2, 3, "2"],
9 [2, 12], 11 [2, 12, "23456789"],
10 [2, 2], 12 [2, 2, ""],
11 [2, 1], 13 [2, 1, ""],
12 [2, -12], 14 [2, -12, ""],
13 [2, 2147483647], 15 [2, 2147483647, "23456789"],
14 [2, -2147483648], 16 [2, -2147483648, ""],
15 [2, 9223372036854775000], 17 [2, 9223372036854775000, "23456789"],
16 [2, -9223372036854775000], 18 [2, -9223372036854775000, ""],
17 [-2, -1], 19 [-2, -1, "8"],
18 [-2, -2], 20 [-2, -2, ""],
19 [-2, -3], 21 [-2, -3, ""],
20 [-2, -12], 22 [-2, -12, ""],
21 [-2, 2147483647], 23 [-2, 2147483647, "89"],
22 [-2, -2147483648], 24 [-2, -2147483648, ""],
23 [-2, 9223372036854775000], 25 [-2, 9223372036854775000, "89"],
24 [-2, -9223372036854775000], 26 [-2, -9223372036854775000, ""],
25 [0], 27 [0, null, "0123456789"],
26 [2], 28 [2, null, "23456789"],
27 [-2], 29 [-2, null, "89"],
28 [12], 30 [12, null, ""],
29 [-12], 31 [-12, null, "0123456789"],
30 [2147483647], 32 [2147483647, null, ""],
31 [-2147483648], 33 [-2147483648, null, "0123456789"],
32 [9223372036854775000], 34 [9223372036854775000, null, ""],
33 [-9223372036854775000], 35 [-9223372036854775000, null, "0123456789"],
34 [], 36 [null, null, "0123456789"],
35 ]; 37 ];
36 38
37 function log(message)
38 {
39 document.getElementById('console').appendChild(document.createTextNode(messa ge + "\n"));
40 }
41
42 function testSlicing(start, end)
43 {
44 var subBlob;
45 var reader = new FileReader();
46 var message = "Slicing ";
47 if (start == undefined && end == undefined) {
48 message += "without parameters";
49 subBlob = blob.slice();
50 } else if (end == undefined) {
51 message += "from " + start;
52 subBlob = blob.slice(start);
53 } else {
54 message += "from " + start + " to " + end;
55 subBlob = blob.slice(start, end);
56 }
57 message += ": ";
58 reader.onload = function(event) {
59 log(message + event.target.result);
60 runNextTest();
61 };
62 reader.onerror = function(event) {
63 log(message + "error " + event.target.error.code);
64 runNextTest();
65 };
66 reader.readAsText(subBlob);
67 }
68
69 function runNextTest()
70 {
71 if (testIndex >= sliceParams.length) {
72 if (window.testRunner)
73 testRunner.notifyDone();
74 return;
75 }
76
77 var start = sliceParams[testIndex][0];
78 var end = sliceParams[testIndex][1];
79 testIndex++;
80 testSlicing(start, end);
81 }
82
83 function runTests() 39 function runTests()
84 { 40 {
85 blob = new Blob(["0123456789"]); 41 blob = new Blob(["0123456789"]);
42 file = new File(["0123456789"], "slice-test.txt");
86 43
87 runNextTest(); 44 runNextTest();
88 } 45 }
89 46
90 if (window.testRunner) { 47 window.jsTestIsAsync = true;
91 testRunner.dumpAsText();
92 testRunner.waitUntilDone();
93 }
94 </script> 48 </script>
95 </head> 49 </head>
96 <body onload="runTests()"> 50 <body onload="runTests()">
97 <pre id='console'></pre> 51 <pre id='console'></pre>
98 </body> 52 </body>
99 </html> 53 </html>
OLDNEW
« no previous file with comments | « LayoutTests/fast/files/blob-parts-slice-test-expected.txt ('k') | LayoutTests/fast/files/blob-slice-test-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698