Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / open-async-overload.html
blob2463869fe39b0f411851ac66718a62f1a1fbf1a7
1 <html>
2 <body>
3 <p>XMLHttpRequest.open() should be correctly overloaded</p>
4 <script>
6 var console_messages = document.createElement("ol");
7 document.body.appendChild(console_messages);
9 function log(message)
11 var item = document.createElement("li");
12 item.appendChild(document.createTextNode(message));
13 console_messages.appendChild(item);
16 function shouldSendBehaveAs(req, async, description)
18 var expectedState = async ? 1 : 4;
20 req.send();
22 if (req.readyState == expectedState)
23 log("PASS: " + description);
24 else
25 log("FAIL: " + description + " (expected:" + expectedState + ", actual:" + req.readyState +")");
28 if (window.testRunner)
29 testRunner.dumpAsText();
31 req = new XMLHttpRequest();
32 req.open("GET", "methods.cgi?1", true);
33 shouldSendBehaveAs(req, true, "if async argument is true, send() should behave asynchronously");
35 req = new XMLHttpRequest();
36 req.open("GET", "methods.cgi?2", false);
37 shouldSendBehaveAs(req, false, "if async argument is false, send() should behave synchronously");
39 req = new XMLHttpRequest();
40 req.open("GET", "methods.cgi?3");
41 shouldSendBehaveAs(req, true, "if async argument is not given, send() should behave like as async=true");
43 req = new XMLHttpRequest();
44 req.open("GET", "methods.cgi?4", undefined);
45 shouldSendBehaveAs(req, false, "if async argument is undefined, send() should behave like as async=false");
47 req = new XMLHttpRequest();
48 req.open("GET", "methods.cgi?5", "OK");
49 shouldSendBehaveAs(req, true, "if async argument is a non-empty string, send() should behave like as async=true");
51 </script>
52 </body>
53 </html>