blob: 1518ef435357447bd8a7aa94893b5469a2aab84d [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script>
function log(message)
{
var console = document.getElementById('console');
console.appendChild(document.createTextNode(message));
console.appendChild(document.createElement('br'));
}
function errorHandler()
{
log("Error handler: readyState = " + xhr.readyState);
var results = window.top.document.getElementById('results');
results.innerHTML = document.body.innerHTML;
}
function readyStateHandlerDirectory()
{
log("ReadyState handler: readyState = " + xhr.readyState);
if (xhr.readyState == 4 && window.testRunner) {
var results = window.top.document.getElementById('results');
results.innerHTML = document.body.innerHTML;
setTimeout("testRunner.notifyDone()", 0);
}
}
function testXHRDirectory()
{
log("");
log("Doing an XHR to a directory.");
xhr = new XMLHttpRequest();
xhr.onerror = errorHandler;
xhr.onreadystatechange = readyStateHandlerDirectory;
try {
xhr.open("GET", "../resources/", false);
xhr.send("");
} catch(e) {
log("Exception: " + e.message);
}
}
function readyStateHandlerNonExistent()
{
log("ReadyState handler: readyState = " + xhr.readyState);
if (xhr.readyState == 4)
setTimeout("testXHRDirectory()", 0);
}
function testXHRNonExistentFile()
{
log("Doing an XHR to a nonexistent file.");
xhr = new XMLHttpRequest();
xhr.onerror = errorHandler;
xhr.onreadystatechange = readyStateHandlerNonExistent;
try {
xhr.open("GET", "nonexistent.html", true);
xhr.send("");
} catch(e) {
log("Exception: " + e.message);
testXHRDirectory();
}
}
</script>
</head>
<body onload="testXHRNonExistentFile()">
<p> Bug <a href="https://bugs.webkit.org/show_bug.cgi?id=22475">22475</a>: REGRESSION: Async XMLHttpRequest never finishes on nonexistent files anymore </p>
<p> In both cases, readyState 4 should be reached. Because one of the requests is synchronous and for a file: URL, only a single error handler should be invoked. </p>
<div id="console"/>
</body>
</html>