| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src=../../resources/testharness.js></script> | 2 <script src=../../resources/testharness.js></script> |
| 3 <script src=../../resources/testharnessreport.js></script> | 3 <script src=../../resources/testharnessreport.js></script> |
| 4 <script> | 4 <script> |
| 5 | 5 |
| 6 test(function() { | 6 test(function() { |
| 7 var array = new Uint8Array([0x70, 0x71, 0x72, 0x73]); | 7 var array = new Uint8Array([0x70, 0x71, 0x72, 0x73]); |
| 8 var blob = new Blob([array]); | 8 var blob = new Blob([array]); |
| 9 var blobEvent = new BlobEvent('BlobEvent', {data : blob}); | 9 var blobEvent = new BlobEvent('BlobEvent', {data : blob}); |
| 10 | 10 |
| 11 var reader = new FileReader(); | 11 var reader = new FileReader(); |
| 12 reader.addEventListener("loadend", function() { | 12 reader.addEventListener("loadend", function() { |
| 13 // |reader.result| contains the contents of blob as an ArrayBuffer. | 13 // |reader.result| contains the contents of blob as an ArrayBuffer. |
| 14 var outputArray = new Uint8Array(reader.result); | 14 var outputArray = new Uint8Array(reader.result); |
| 15 assert_array_equals(array, outputArray) | 15 assert_array_equals(array, outputArray) |
| 16 }); | 16 }); |
| 17 reader.readAsArrayBuffer(blob); | 17 reader.readAsArrayBuffer(blobEvent.data); |
| 18 assert_equals(blobEvent.timecode, NaN, 'timecode'); |
| 18 | 19 |
| 19 }, 'check BlobEvent creation and content management'); | 20 }, 'BlobEvent creation and content management'); |
| 21 |
| 22 test(function() { |
| 23 var array = new Uint8Array([0x70, 0x71, 0x72, 0x73]); |
| 24 var blob = new Blob([array]); |
| 25 var now = Date.now(); |
| 26 var blobEvent = new BlobEvent('BlobEvent', {data : blob, timecode : now}); |
| 27 |
| 28 assert_equals(blobEvent.timecode, now, 'timecode'); |
| 29 |
| 30 }, 'BlobEvent creation with timecode'); |
| 20 | 31 |
| 21 test(function() { | 32 test(function() { |
| 22 assert_throws(null, | 33 assert_throws(null, |
| 23 function() { var blobEvent = new BlobEvent('BlobEvent'); }); | 34 function() { var blobEvent = new BlobEvent('BlobEvent'); }); |
| 24 }, 'check BlobEvent needs two constructor parameters, type and BlobEventInit'); | 35 }, 'BlobEvent needs two constructor parameters, type and BlobEventInit'); |
| 25 | 36 |
| 26 test(function() { | 37 test(function() { |
| 38 var array = new Uint8Array([0x70, 0x71, 0x72, 0x73]); |
| 39 var blob = new Blob([array]); |
| 27 assert_throws(null, | 40 assert_throws(null, |
| 28 function() { | 41 function() { |
| 29 var blobEvent = new BlobEvent('BlobEvent', {data : "blergh"}); | 42 var blobEvent = new BlobEvent(blob, {data : "blergh"}); |
| 30 }); | 43 }); |
| 31 }, 'check BlobEvent needs the second constructor parameter to be a BlobEventInit
'); | 44 }, 'BlobEvent needs the second constructor parameter to be a BlobEventInit'); |
| 45 |
| 46 test(function() { |
| 47 var array = new Uint8Array([0x70, 0x71, 0x72, 0x73]); |
| 48 var blob = new Blob([array]); |
| 49 assert_throws(null, |
| 50 function() { |
| 51 var blobEvent = new BlobEvent(blob, {timecode : 0.0}); |
| 52 }); |
| 53 }, 'BlobEventInit needs a data parameter'); |
| 32 | 54 |
| 33 </script> | 55 </script> |
| OLD | NEW |