<html>
<head>
<title>Test XMLHttpRequest frame load abort causes unexpected notification activity</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body onload="startTest()">
<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=11450">bug 11450</a>
REGRESSION: XMLHttpRequest::didFinishLoading() should immediately return if the request has already been aborted</p>
<p>If a frame has an active XMLHttpRequest that is still receiving data, and that frame is destroyed<br>
(or its load is otherwise stopped) the XMLHttpRequest gets an abort call then a didFinishedLoading call.</p>
<p>That didFinishedLoading() call should immediately exit and not update the object's state or do any 
other notifications.</p>

<script>
    var console_messages = document.createElement("ul");
    document.body.appendChild(console_messages);
    
    var framediv;
    
    function startTest()
    {
        if (window.testRunner) {
            testRunner.waitUntilDone();
            testRunner.dumpAsText();
        }
        log("Loading subframe to cancel");
        framediv = document.getElementById('framediv');
        framediv.innerHTML = '<iframe src="resources/frame-load-to-cancel.html" width=0 height=0 border=0></iframe>';
    }
    
    function subframeLoaded()
    {
        log("Body of subframe is loaded.  XMLHttpRequest should be in progress.  Nuking the iframe");
        framediv.innerHTML = 'Test complete';
        log("Iframe removed");
        if (window.testRunner)
            testRunner.notifyDone();
    }
    
    function dumpRequestStatus(req) {
       try { log ("Ready State: " + req.readyState); } catch (ex) { log("Exception getting status: " + ex.message); }
    }
    
    function log(message)
    {
        var item = document.createElement("li");
        item.appendChild(document.createTextNode(message));
        console_messages.appendChild(item);
    }
    
</script>
<div id="framediv" name="framediv" style="visibility:hidden">
iFrame will go here
</div>
</body>
</html>
