| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <body> | 2 <body> |
| 3 <p> Verify that XMLHttpRequest.open resets received size.</p> | 3 <p> Verify that XMLHttpRequest.open resets received size.</p> |
| 4 <p> You should see PASSED once. </p> | 4 <p> You should see PASSED once. </p> |
| 5 | 5 |
| 6 <script type="text/javascript"> | 6 <script type="text/javascript"> |
| 7 var resourceSize = 1461754; | 7 var resourceSize = 1461754; |
| 8 var lastPosition = 0; | 8 var lastPosition = 0; |
| 9 | 9 |
| 10 function log (msg) | 10 function log (msg) |
| 11 { | 11 { |
| 12 document.body.appendChild(document.createTextNode(msg)); | 12 document.body.appendChild(document.createTextNode(msg)); |
| 13 document.body.appendChild(document.createElement("br")); | 13 document.body.appendChild(document.createElement("br")); |
| 14 } | 14 } |
| 15 | 15 |
| 16 function onProgress(e) { | 16 function onProgress(e) { |
| 17 if (e.position >= resourceSize / 4) { | 17 if (e.loaded >= resourceSize / 4) { |
| 18 // We want to restart the XMLHttpRequest to see if the count is updated | 18 // We want to restart the XMLHttpRequest to see if the count is updated |
| 19 var xhr = e.target; | 19 var xhr = e.target; |
| 20 xhr.onprogress = onProgressTest; | 20 xhr.onprogress = onProgressTest; |
| 21 xhr.onreadystatechange = onReadyStateChange; | 21 xhr.onreadystatechange = onReadyStateChange; |
| 22 xhr.open("GET", "resources/big-response.php", true); | 22 xhr.open("GET", "resources/big-response.php", true); |
| 23 xhr.send(null); | 23 xhr.send(null); |
| 24 } | 24 } |
| 25 } | 25 } |
| 26 | 26 |
| 27 function onProgressTest(e) { | 27 function onProgressTest(e) { |
| 28 lastPosition = e.position; | 28 lastPosition = e.loaded; |
| 29 } | 29 } |
| 30 | 30 |
| 31 function onReadyStateChange() { | 31 function onReadyStateChange() { |
| 32 if (req.readyState == 4) { | 32 if (req.readyState == 4) { |
| 33 // Compare last position with the known resource size. | 33 // Compare last position with the known resource size. |
| 34 log((lastPosition == resourceSize) ? "PASSED" : ("FAILED: expected " + r
esourceSize + ", actual " + lastPosition)); | 34 log((lastPosition == resourceSize) ? "PASSED" : ("FAILED: expected " + r
esourceSize + ", actual " + lastPosition)); |
| 35 if (window.testRunner) | 35 if (window.testRunner) |
| 36 testRunner.notifyDone(); | 36 testRunner.notifyDone(); |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 if (window.testRunner) { | 40 if (window.testRunner) { |
| 41 testRunner.dumpAsText(); | 41 testRunner.dumpAsText(); |
| 42 testRunner.waitUntilDone(); | 42 testRunner.waitUntilDone(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 var req = new XMLHttpRequest(); | 45 var req = new XMLHttpRequest(); |
| 46 req.onprogress = onProgress; | 46 req.onprogress = onProgress; |
| 47 req.open("GET", "resources/big-response.php", true); | 47 req.open("GET", "resources/big-response.php", true); |
| 48 req.send(null); | 48 req.send(null); |
| 49 </script> | 49 </script> |
| 50 </body> | 50 </body> |
| 51 </html> | 51 </html> |
| OLD | NEW |