blob: 806a34ee0a811b3e7c1cce14b474e063f61a982e [file] [log] [blame]
<html>
<body>
<p> Verify that XMLHttpRequest.open resets received size.</p>
<p> You should see PASSED once. </p>
<script type="text/javascript">
var resourceSize = 1461754;
var lastPosition = 0;
function log (msg)
{
document.body.appendChild(document.createTextNode(msg));
document.body.appendChild(document.createElement("br"));
}
function onProgress(e) {
if (e.position >= resourceSize / 4) {
// We want to restart the XMLHttpRequest to see if the count is updated
var xhr = e.target;
xhr.onprogress = onProgressTest;
xhr.onreadystatechange = onReadyStateChange;
xhr.open("GET", "resources/big-response.php", true);
xhr.send(null);
}
}
function onProgressTest(e) {
lastPosition = e.position;
}
function onReadyStateChange() {
if (req.readyState == 4) {
// Compare last position with the known resource size.
log((lastPosition == resourceSize) ? "PASSED" : ("FAILED: expected " + resourceSize + ", actual " + lastPosition));
if (window.testRunner)
testRunner.notifyDone();
}
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var req = new XMLHttpRequest();
req.onprogress = onProgress;
req.open("GET", "resources/big-response.php", true);
req.send(null);
</script>
</body>
</html>