Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / interactive-state.html
blob1e8f4512bd68126ad84dc1620a2eef0782a58ba8
1 <html>
2 <head>
3 <title>Test XmlHttpRequest onreadystatechange being called for each chunk of data</title>
4 <body>
5 <p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=7392">bug 7392</a>:
6 GMAIL: XMLHttpRequest does not correctly report "Interactive" state on receipt of load data.</p>
7 <script>
9 if (window.testRunner) {
10 testRunner.dumpAsText();
11 testRunner.waitUntilDone();
14 var console_messages = document.createElement("ol");
15 document.body.appendChild(console_messages);
17 var count = 0;
19 function log(message)
21 var item = document.createElement("li");
22 item.appendChild(document.createTextNode(message));
23 console_messages.appendChild(item);
26 function get(url, async)
28 if (window.XMLHttpRequest) {
29 req = new XMLHttpRequest();
30 } else {
31 try {
32 req = new ActiveXObject("Msxml2.XMLHTTP");
33 } catch (ex) {
34 req = new ActiveXObject("Microsoft.XMLHTTP");
38 req.onreadystatechange = processStateChange;
40 req.open('GET', url, async);
41 req.send(null);
43 if (!async && req.status != 200)
44 throw ("HTTP request failed, status: " + req.status);
46 return req;
49 function processStateChange(){
50 if (req.readyState == 3)
51 ++count;
52 else if (req.readyState == 4) {
53 log((count > 1) ? "SUCCESS" : "FAILURE (count = " + count + ")");
54 if (window.testRunner)
55 testRunner.notifyDone();
59 // start async steps
60 get('interactive-state.cgi', true);
62 </script>
63 </body>
64 </html>