Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / xmlhttprequest-onProgress-open-should-zero-length.html
blob806a34ee0a811b3e7c1cce14b474e063f61a982e
1 <html>
2 <body>
3 <p> Verify that XMLHttpRequest.open resets received size.</p>
4 <p> You should see PASSED once. </p>
6 <script type="text/javascript">
7 var resourceSize = 1461754;
8 var lastPosition = 0;
10 function log (msg)
12 document.body.appendChild(document.createTextNode(msg));
13 document.body.appendChild(document.createElement("br"));
16 function onProgress(e) {
17 if (e.position >= resourceSize / 4) {
18 // We want to restart the XMLHttpRequest to see if the count is updated
19 var xhr = e.target;
20 xhr.onprogress = onProgressTest;
21 xhr.onreadystatechange = onReadyStateChange;
22 xhr.open("GET", "resources/big-response.php", true);
23 xhr.send(null);
27 function onProgressTest(e) {
28 lastPosition = e.position;
31 function onReadyStateChange() {
32 if (req.readyState == 4) {
33 // Compare last position with the known resource size.
34 log((lastPosition == resourceSize) ? "PASSED" : ("FAILED: expected " + resourceSize + ", actual " + lastPosition));
35 if (window.testRunner)
36 testRunner.notifyDone();
40 if (window.testRunner) {
41 testRunner.dumpAsText();
42 testRunner.waitUntilDone();
45 var req = new XMLHttpRequest();
46 req.onprogress = onProgress;
47 req.open("GET", "resources/big-response.php", true);
48 req.send(null);
49 </script>
50 </body>
51 </html>