blob: 9e0aec8f78e15445f0ce0d3280bc020e197cf1ff [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.py", 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.py", true);
req.send(null);
</script>
</body>
</html>