| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>FileReader readyState</title> |
| <link rel="help" href="http://www.w3.org/TR/FileAPI/#events"> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| </head> |
| <body> |
| <script> |
| |
| var reader = new FileReader(); |
| |
| setup({explicit_done: true}); |
| |
| test(function() { |
| assert_equals(reader.readyState, reader.EMPTY, "The readyState"); |
| }, "Check if the readyState is EMPTY initially"); |
| |
| on_event(reader, "loadstart", function() { |
| test(function() { |
| assert_equals(reader.readyState, reader.LOADING, "The readyState"); |
| }, "Check if the readyState is LOADING in loadstart"); |
| }); |
| |
| on_event(reader, "progress", function() { |
| test(function() { |
| assert_equals(reader.readyState, reader.LOADING, "The readyState"); |
| }, "Check if the readyState is LOADING in progress"); |
| }); |
| |
| on_event(reader, "load", function() { |
| test(function() { |
| assert_equals(reader.readyState, reader.DONE, "The readyState"); |
| }, "Check if the readyState is DONE in load"); |
| }); |
| |
| on_event(reader, "loadend", function() { |
| test(function() { |
| assert_equals(reader.readyState, reader.DONE, "The readyState"); |
| }, "Check if the readyState is DONE in loadend"); |
| |
| done(); |
| }); |
| |
| reader.readAsText(new Blob(["foo"])); |
| |
| </script> |
| </body> |
| </html> |