4 <script src=
"../../resources/testharness.js"></script>
5 <script src=
"../../resources/testharnessreport.js"></script>
6 <script type=
"text/javascript">
7 var test
= async_test("Test reading data from a blob as an ArrayBuffer");
9 var onloadstartSeen
= false;
11 test
.step(function() {
12 var blob
= new Blob(["HelloWorld"]);
13 var reader
= new FileReader();
14 assert_equals(reader
.readyState
, reader
.EMPTY
,
16 reader
.readAsArrayBuffer(blob
);
17 reader
.onloadstart
= test
.step_func(function() {
18 assert_false(onloadstartSeen
, "onloadstartSeen");
19 onloadstartSeen
= true;
21 assert_equals(reader
.readyState
, reader
.LOADING
,
23 assert_equals(reader
.error
, null, "reader.error");
24 assert_not_equals(reader
.result
, null, "reader.result");
25 assert_true(reader
.result
.byteLength
>= 0 &&
26 reader
.result
.byteLength
<= 10,
27 "reader.result.byteLength between 0 and 10 inclusive");
29 reader
.onabort
= test
.step_func(function() {
30 assert_unreached("onabort invoked on reader");
32 reader
.onerror
= test
.step_func(function() {
33 assert_unreached("onerror invoked on reader");
35 reader
.onloadend
= test
.step_func(function() {
36 assert_equals(reader
.readyState
, reader
.DONE
,
38 assert_equals(reader
.error
, null, "reader.error");
39 assert_not_equals(reader
.result
, null, "reader.result");
40 assert_equals(reader
.result
.byteLength
, 10,
41 "reader.result.byteLength");