blob: 1e8f4512bd68126ad84dc1620a2eef0782a58ba8 [file] [log] [blame]
<html>
<head>
<title>Test XmlHttpRequest onreadystatechange being called for each chunk of data</title>
<body>
<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=7392">bug 7392</a>:
GMAIL: XMLHttpRequest does not correctly report "Interactive" state on receipt of load data.</p>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var console_messages = document.createElement("ol");
document.body.appendChild(console_messages);
var count = 0;
function log(message)
{
var item = document.createElement("li");
item.appendChild(document.createTextNode(message));
console_messages.appendChild(item);
}
function get(url, async)
{
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (ex) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
}
req.onreadystatechange = processStateChange;
req.open('GET', url, async);
req.send(null);
if (!async && req.status != 200)
throw ("HTTP request failed, status: " + req.status);
return req;
}
function processStateChange(){
if (req.readyState == 3)
++count;
else if (req.readyState == 4) {
log((count > 1) ? "SUCCESS" : "FAILURE (count = " + count + ")");
if (window.testRunner)
testRunner.notifyDone();
}
}
// start async steps
get('interactive-state.cgi', true);
</script>
</body>
</html>