blob: a4e26074022c210f8fd80a44bfcb011567a3f770 [file] [log] [blame]
<html>
<body>
<p>Test for <a href="rdar://problem/5766352">rdar://problem/5766352</a>:
REGRESSION: XMLHttpRequest.abort() resets response status.
<div id="log"></div>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var req = null;
function log(message)
{
document.getElementById("log").innerHTML += message + "<br>";
}
function logStatusAndState(comment)
{
var status;
var statusText;
var readyState;
try
{
status = req.status;
} catch (ex)
{
status = "[exception]";
}
try
{
statusText = req.statusText;
} catch (ex)
{
statusText = "[exception]";
}
try
{
readyState = req.readyState;
} catch (ex)
{
readyState = "[exception]";
}
log((comment ? comment + ". ": "") + "Response status: " + status + "; statusText: '" + statusText + "'; readyState: " + readyState);
}
function callBackFunction()
{
logStatusAndState("Onreadystatechange");
if (req.readyState == 4)
{
log("Aborting the request...");
req.abort();
logStatusAndState("After aborting the request");
log("Reopening the request to check that the status is reset...");
req.onreadystatechange = callBackFunction;
req.open("GET", "foobar", true);
req.onreadystatechange = null;
req.abort();
log("Done.");
if (window.testRunner)
testRunner.notifyDone();
}
}
req = new XMLHttpRequest();
logStatusAndState("A newly created request");
req.onreadystatechange = callBackFunction;
log("Opening...");
req.open("GET","status-after-abort.html",true);
logStatusAndState("Opened request");
req.send(null);
logStatusAndState("Sent request");
</script>
</body>
</html>