Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / files / read-blob-as-array-buffer.html
blob0738fdfefa634e1301ea617397a944a460798bfe
1 <!DOCTYPE html>
2 <html>
3 <body>
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,
15 "reader.readyState");
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,
22 "reader.readyState");
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");
28 });
29 reader.onabort = test.step_func(function() {
30 assert_unreached("onabort invoked on reader");
31 });
32 reader.onerror = test.step_func(function() {
33 assert_unreached("onerror invoked on reader");
34 });
35 reader.onloadend = test.step_func(function() {
36 assert_equals(reader.readyState, reader.DONE,
37 "reader.readyState");
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");
42 test.done();
43 });
44 });
45 </script>
46 </body>
47 </html>