chromium/third_party/blink/web_tests/fast/files/read-blob-as-array-buffer.html

<!DOCTYPE html>
<html>
<body>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script type="text/javascript">
var test = async_test("Test reading data from a blob as an ArrayBuffer");

var onloadstartSeen = false;

test.step(function() {
    var blob = new Blob(["HelloWorld"]);
    var reader = new FileReader();
    assert_equals(reader.readyState, reader.EMPTY,
                  "reader.readyState");
    reader.readAsArrayBuffer(blob);
    reader.onloadstart = test.step_func(function() {
        assert_false(onloadstartSeen, "onloadstartSeen");
        onloadstartSeen = true;

        assert_equals(reader.readyState, reader.LOADING,
                      "reader.readyState");
        assert_equals(reader.error, null, "reader.error");
        assert_equals(reader.result, null, "reader.result");
    });
    reader.onabort = test.step_func(function() {
        assert_unreached("onabort invoked on reader");
    });
    reader.onerror = test.step_func(function() {
        assert_unreached("onerror invoked on reader");
    });
    reader.onloadend = test.step_func(function() {
        assert_equals(reader.readyState, reader.DONE,
                      "reader.readyState");
        assert_equals(reader.error, null, "reader.error");
        assert_not_equals(reader.result, null, "reader.result");
        assert_equals(reader.result.byteLength, 10,
                      "reader.result.byteLength");
        test.done();
    });
});
</script>
</body>
</html>