Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / chunked-progress-event-expectedLength.html
bloba8cb532a7dfeeeec2b7fa8ab9f6e004addda2314
1 <html>
2 <head>
3 <title>Test case for bug 36156</title>
4 </head>
5 <body>
6 <p> Test case for <a href="https://bugs.webkit.org/show_bug.cgi?id=36156"> bug 36156</a>: XHR 'progress' event code assumes wrongly that expectedLength >= 0</p>
7 <p> Verify that the progress event total property is 0 when the expected overall length can't be computed.<p>
8 <p>PASS should appear below:</p>
9 <p id=console></p>
10 <script type="text/javascript">
11 if (window.testRunner) {
12 testRunner.dumpAsText();
13 testRunner.waitUntilDone();
16 function log(message)
18 document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
21 function test()
23 var xhr = new XMLHttpRequest();
24 xhr.open("GET", "resources/chunked-transfer.php", true);
26 xhr.onprogress = function(e) {
27 if (xhr.readyState != xhr.LOADING) {
28 // As this test ends when a readystatechange event arrives with
29 // readyState == DONE, a "progress" event cannot arrive when
30 // readyState == DONE.
31 log("FAIL: xhr.readyState must be LOADING when a progress event arrives, but is " + xhr.readyState);
33 if (e.loaded == 4 && e.total == 0 && !e.lengthComputable)
34 log("PASS");
35 else if (e.total != 0 && !e.lengthComputable)
36 log("FAIL: XMLHttpRequestProgressEvent lengthComputable=false but total is non-zero: " + e.total);
39 xhr.onreadystatechange = function(e) {
40 if (xhr.readyState == xhr.DONE)
42 if (window.testRunner)
43 testRunner.notifyDone();
47 xhr.send();
50 test();
51 </script>
52 </body>