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(blob); |
18 | 18 |
19 }, 'check BlobEvent creation and content management'); | 19 }, 'check BlobEvent creation and content management'); |
20 | 20 |
| 21 test(function() { |
| 22 assert_throws(null, |
| 23 function() { var blobEvent = new BlobEvent('BlobEvent'); }); |
| 24 }, 'check BlobEvent needs two constructor parameters, type and BlobEventInit'); |
| 25 |
| 26 test(function() { |
| 27 assert_throws(null, |
| 28 function() { |
| 29 var blobEvent = new BlobEvent('BlobEvent', {data : "blergh"}); |
| 30 }); |
| 31 }, 'check BlobEvent needs the second constructor parameter to be a BlobEventInit
'); |
| 32 |
21 </script> | 33 </script> |
OLD | NEW |