Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test cases for FileReader States. #287

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions FileAPI/fileReader.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!doctype html>
<html>
<head>
<title>FileReader States</title>
<link rel=help href="http://www.w3.org/TR/FileAPI/#dfn-filereader">
<link rel=author title="Lenient" href="mailto:lenient315@gmail.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<script>
test(function() {
assert_true("FileReader" in window, "window should have a FileReader property.");
}, "FileReader interface object");

test(function(){
var fileReader = new FileReader();
assert_true(fileReader instanceof FileReader);
}, "no-argument FileReader constructor");

var t_abort = async_test("FileReader States -- abort");
t_abort.step(function(){
var fileReader = new FileReader();
assert_equals(fileReader.readyState, 0);
assert_equals(fileReader.readyState, FileReader.EMPTY);

var blob = new Blob();
fileReader.readAsArrayBuffer(blob);
assert_equals(fileReader.readyState, 1);
assert_equals(fileReader.readyState, FileReader.LOADING);

fileReader.abort();
fileReader.onabort = this.step_func(function(e) {
assert_equals(fileReader.readyState, 2);
assert_equals(fileReader.readyState, FileReader.DONE);
t_abort.done();
});
});

var t_event = async_test("FileReader States -- events");
t_event.step(function(){
var fileReader = new FileReader();

var blob = new Blob();
fileReader.readAsArrayBuffer(blob);

fileReader.onloadstart = this.step_func(function(e) {
assert_equals(fileReader.readyState, 1);
assert_equals(fileReader.readyState, FileReader.LOADING);
});

fileReader.onprogress = this.step_func(function(e) {
assert_equals(fileReader.readyState, 2);
assert_equals(fileReader.readyState, FileReader.DONE);
});

fileReader.onloadend = this.step_func(function(e) {
assert_equals(fileReader.readyState, 2);
assert_equals(fileReader.readyState, FileReader.DONE);
t_event.done();
});
});
</script>
</body>
</html>