blob: ea0b3775310795e102f233032e6a5c2f895ba50e [file] [log] [blame]
<!DOCTYPE html>
<script src=../../resources/testharness.js></script>
<script src=../../resources/testharnessreport.js></script>
<script>
test(function() {
var array = new Uint8Array([0x70, 0x71, 0x72, 0x73]);
var blob = new Blob([array]);
var blobEvent = new BlobEvent('BlobEvent', {data : blob});
var reader = new FileReader();
reader.addEventListener("loadend", function() {
// |reader.result| contains the contents of blob as an ArrayBuffer.
var outputArray = new Uint8Array(reader.result);
assert_array_equals(array, outputArray)
});
reader.readAsArrayBuffer(blob);
}, 'check BlobEvent creation and content management');
test(function() {
assert_throws(null,
function() { var blobEvent = new BlobEvent('BlobEvent'); });
}, 'check BlobEvent needs two constructor parameters, type and BlobEventInit');
test(function() {
assert_throws(null,
function() {
var blobEvent = new BlobEvent('BlobEvent', {data : "blergh"});
});
}, 'check BlobEvent needs the second constructor parameter to be a BlobEventInit');
</script>