Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / xmlhttprequest-multiple-open.html
blob4f74a7286a340856c9c3a4d364533f9169073160
1 <html><head></head><body>
3 <p>Test bug 17481: Several consecutive calls to XMLHttpRequest::open should dispatch only one readyState event</p>
4 <p>You should see "PASS" once:</p>
5 <div id="ans"></div>
7 <script type="text/javascript">
8 function log(message)
10 document.getElementById("ans").appendChild(document.createTextNode(message));
11 document.getElementById("ans").appendChild(document.createElement("br"));
14 Array.prototype.isEqual = function(expected)
16 if (this.length != expected.length)
17 return false;
18 for (i = 0; i < this.length; i++)
19 if (this[i] != expected[i])
20 return false;
21 return true;
24 if (window.testRunner) {
25 testRunner.dumpAsText();
26 testRunner.waitUntilDone();
29 var xhr;
31 if (window.XMLHttpRequest) {
32 xhr = new XMLHttpRequest();
33 } else {
34 try {
35 xhr = new ActiveXObject("Msxml2.XMLHTTP");
36 } catch (ex) {
37 xhr = new ActiveXObject("Microsoft.XMLHTTP");
41 var results = [],
42 expected = ['before first open', 1, 'before second open', 'before third open'];
44 xhr.onreadystatechange = function () {
45 results.push(this.readyState);
48 results.push('before first open');
49 xhr.open("GET", "resources/1251.html", true);
50 results.push('before second open');
51 xhr.open("GET", "resources/1251.html", true);
52 results.push('before third open');
53 xhr.open("GET", "resources/print-headers.cgi", true);
55 log(results.isEqual(expected) ? "PASS" : "FAILED results : " + results + " expected : " + expected);
57 if (window.testRunner)
58 testRunner.notifyDone();
60 </script>
61 </body></html>