Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / xmlhttprequest-test-send-flag.html
blobc66a6102c2cfe3030704513b6d9a709eb45ec8e5
1 <html>
2 <head></head>
3 <body>
5 <p> Test bug 16989 : Add send() flag checks in XmlHttpRequest </p>
6 <p> You should see PASS two times </p>
8 <div id="ans"></div>
10 <script type="text/javascript">
11 function log(message) {
12 document.getElementById("ans").appendChild(document.createTextNode(message));
13 document.getElementById("ans").appendChild(document.createElement("br"));
16 if (window.testRunner)
17 testRunner.dumpAsText();
19 var xhr;
21 if (window.XMLHttpRequest) {
22 xhr = new XMLHttpRequest();
23 } else {
24 try {
25 xhr = new ActiveXObject("Msxml2.XMLHTTP");
26 } catch (ex) {
27 xhr = new ActiveXObject("Microsoft.XMLHTTP");
31 // First test : test open method send() flag check
32 xhr.open("GET", "resources/endlessxml.php", true);
33 xhr.send(null);
34 try {
35 if (xhr.readyState == 1)
36 xhr.send(null);
37 log("FAILED");
38 } catch (e) {
39 // Call abort to prevent triggering some readystate events
40 xhr.abort();
41 log("PASS");
44 // Second test : test setResponseHeader method send() flag check
45 xhr.open("GET", "resources/endlessxml.php", true);
46 xhr.setRequestHeader("Test1", "Test1");
47 xhr.send(null);
48 try {
49 // makes sure readyState is opened (bug in Opera)
50 if (xhr.readyState == 1)
51 xhr.setRequestHeader("Test", "Test");
52 log("FAILED");
53 } catch (e) {
54 // Call abort to prevent triggering some readystate events
55 xhr.abort();
56 log("PASS");
59 if (window.testRunner)
60 testRunner.notifyDone();
62 </script>
63 </body>
64 </html>