chromium/third_party/blink/web_tests/http/tests/xmlhttprequest/xmlhttprequest-onProgress-open-should-zero-length.html

<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.loaded >= 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.loaded;
}

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>