<!DOCTYPE html>
<html>
<body>
<pre id='console'></pre>
<script src="../../resources/gc.js"></script>
<script>
function log(message)
{
    document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
}

function test1()
{
    log("Test that FileReader.abort on newly created FileReader doesn't crash.");
    new FileReader().abort();
}

function test2()
{
    log("Test that FileReader.abort on newly created FileReader doesn't fire events.");

    var reader = new FileReader();
    reader.onload = function() {
        log("Received load event");
    };
    reader.onloadend = function() {
        log("Received loadend event");
    };
    reader.onabort = function() {
        log("Received abort event");
    };
    reader.onerror = function(event) {
        log("Received error event: " + event.target.error.code);
    };

    reader.abort();
}

function runTests()
{
    test1();
    gc();
    log("PASSED");

    test2();
    gc();
    log("PASSED");

    log("DONE");
    if (testRunner.notifyDone)
        testRunner.notifyDone();
}

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

window.onload = runTests;
</script>
</body>
</html>
