11cb0ef41Sopenharmony_ci<!doctype html>
21cb0ef41Sopenharmony_ci<html>
31cb0ef41Sopenharmony_ci  <head>
41cb0ef41Sopenharmony_ci      <title>FileReader States</title>
51cb0ef41Sopenharmony_ci      <link rel=help href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-filereader">
61cb0ef41Sopenharmony_ci      <link rel=author title="Lenient" href="mailto:lenient315@gmail.com">
71cb0ef41Sopenharmony_ci      <script src="/resources/testharness.js"></script>
81cb0ef41Sopenharmony_ci      <script src="/resources/testharnessreport.js"></script>
91cb0ef41Sopenharmony_ci  </head>
101cb0ef41Sopenharmony_ci  <body>
111cb0ef41Sopenharmony_ci    <div id="log"></div>
121cb0ef41Sopenharmony_ci    <script>
131cb0ef41Sopenharmony_ci        test(function() {
141cb0ef41Sopenharmony_ci             assert_true("FileReader" in window, "window should have a FileReader property.");
151cb0ef41Sopenharmony_ci        }, "FileReader interface object");
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci        test(function(){
181cb0ef41Sopenharmony_ci            var fileReader = new FileReader();
191cb0ef41Sopenharmony_ci            assert_true(fileReader instanceof FileReader);
201cb0ef41Sopenharmony_ci        }, "no-argument FileReader constructor");
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci        var t_abort = async_test("FileReader States -- abort");
231cb0ef41Sopenharmony_ci        t_abort.step(function(){
241cb0ef41Sopenharmony_ci            var fileReader = new FileReader();
251cb0ef41Sopenharmony_ci            assert_equals(fileReader.readyState, 0);
261cb0ef41Sopenharmony_ci            assert_equals(fileReader.readyState, FileReader.EMPTY);
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci            var blob = new Blob();
291cb0ef41Sopenharmony_ci            fileReader.readAsArrayBuffer(blob);
301cb0ef41Sopenharmony_ci            assert_equals(fileReader.readyState, 1);
311cb0ef41Sopenharmony_ci            assert_equals(fileReader.readyState, FileReader.LOADING);
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci            fileReader.onabort = this.step_func(function(e) {
341cb0ef41Sopenharmony_ci                assert_equals(fileReader.readyState, 2);
351cb0ef41Sopenharmony_ci                assert_equals(fileReader.readyState, FileReader.DONE);
361cb0ef41Sopenharmony_ci                t_abort.done();
371cb0ef41Sopenharmony_ci            });
381cb0ef41Sopenharmony_ci            fileReader.abort();
391cb0ef41Sopenharmony_ci            fileReader.onabort = this.unreached_func("abort event should fire sync")
401cb0ef41Sopenharmony_ci        });
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ci        var t_event = async_test("FileReader States -- events");
431cb0ef41Sopenharmony_ci        t_event.step(function(){
441cb0ef41Sopenharmony_ci            var fileReader = new FileReader();
451cb0ef41Sopenharmony_ci
461cb0ef41Sopenharmony_ci            var blob = new Blob();
471cb0ef41Sopenharmony_ci            fileReader.readAsArrayBuffer(blob);
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ci            fileReader.onloadstart = this.step_func(function(e) {
501cb0ef41Sopenharmony_ci                assert_equals(fileReader.readyState, 1);
511cb0ef41Sopenharmony_ci                assert_equals(fileReader.readyState, FileReader.LOADING);
521cb0ef41Sopenharmony_ci            });
531cb0ef41Sopenharmony_ci
541cb0ef41Sopenharmony_ci            fileReader.onprogress = this.step_func(function(e) {
551cb0ef41Sopenharmony_ci                assert_equals(fileReader.readyState, 1);
561cb0ef41Sopenharmony_ci                assert_equals(fileReader.readyState, FileReader.LOADING);
571cb0ef41Sopenharmony_ci            });
581cb0ef41Sopenharmony_ci
591cb0ef41Sopenharmony_ci            fileReader.onloadend = this.step_func(function(e) {
601cb0ef41Sopenharmony_ci                assert_equals(fileReader.readyState, 2);
611cb0ef41Sopenharmony_ci                assert_equals(fileReader.readyState, FileReader.DONE);
621cb0ef41Sopenharmony_ci                t_event.done();
631cb0ef41Sopenharmony_ci            });
641cb0ef41Sopenharmony_ci        });
651cb0ef41Sopenharmony_ci    </script>
661cb0ef41Sopenharmony_ci  </body>
671cb0ef41Sopenharmony_ci</html>
68