<html>
<body>
<p>XmlHttpRequest abort exception shouldn't assert.</p>
<p>On success, you should see a single PASS below.</p>
<script src="../../workers/resources/worker-util.js"></script>
<script>
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }

    var console_messages = document.createElement("ol");
    document.body.appendChild(console_messages);

    function log(message)
    {
        var item = document.createElement("li");
        item.appendChild(document.createTextNode(message));
        console_messages.appendChild(item);
    }

    var worker = new Worker('resources/endless-sync-xhr.js');
    worker.onmessage = function(evt)
    {
        setTimeout("terminateWorkerAndFinish();", 100);
    }

    function terminateWorkerAndFinish()
    {
        // This is an (unlikley) race condition here in that the worker may not have started
        // the sync xhr call at this point, but it has been greatly lessened by the 100ms delay.
        worker.terminate();
        waitUntilWorkerThreadsExit(doneWithTest);
    }

    function doneWithTest()
    {
        log("PASS");
        if (window.testRunner)
            testRunner.notifyDone();
    }
</script>
</body>
</html>
