| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="resources/blob-slice-common.js"></script> |
| 4 <script> | 5 <script> |
| 5 var blob; | |
| 6 var testIndex = 0; | |
| 7 var sliceParams = [ | 6 var sliceParams = [ |
| 8 [2, 3], | 7 [2, 3], |
| 9 [2, 12], | 8 [2, 12], |
| 10 [2, 2], | 9 [2, 2], |
| 11 [2, 1], | 10 [2, 1], |
| 12 [2, -12], | 11 [2, -12], |
| 13 [2, 2147483647], | 12 [2, 2147483647], |
| 14 [2, -2147483648], | 13 [2, -2147483648], |
| 15 [2, 9223372036854775000], | 14 [2, 9223372036854775000], |
| 16 [2, -9223372036854775000], | 15 [2, -9223372036854775000], |
| (...skipping 10 matching lines...) Expand all Loading... |
| 27 [-2], | 26 [-2], |
| 28 [12], | 27 [12], |
| 29 [-12], | 28 [-12], |
| 30 [2147483647], | 29 [2147483647], |
| 31 [-2147483648], | 30 [-2147483648], |
| 32 [9223372036854775000], | 31 [9223372036854775000], |
| 33 [-9223372036854775000], | 32 [-9223372036854775000], |
| 34 [], | 33 [], |
| 35 ]; | 34 ]; |
| 36 | 35 |
| 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() | 36 function runTests() |
| 84 { | 37 { |
| 85 blob = new Blob(["0123456789"]); | 38 blob = new Blob(["0123456789"]); |
| 39 file = new File(["0123456789"], "slice-test.txt"); |
| 86 | 40 |
| 87 runNextTest(); | 41 runNextTest(); |
| 88 } | 42 } |
| 89 | 43 |
| 90 if (window.testRunner) { | 44 if (window.testRunner) { |
| 91 testRunner.dumpAsText(); | 45 testRunner.dumpAsText(); |
| 92 testRunner.waitUntilDone(); | 46 testRunner.waitUntilDone(); |
| 93 } | 47 } |
| 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> |
| OLD | NEW |