3 <p>Test that a simple cross-origin request to a server that responds (but does not permit cross-origin requests) is indistinguishable from one that does not exist. Should say PASS:
</p>
4 <pre id='console'
></pre>
5 <script type=
"text/javascript">
7 testRunner
.dumpAsText();
11 document
.getElementById('console').appendChild(document
.createTextNode(message
+ "\n"));
18 xhr
= new XMLHttpRequest
;
19 xhr
.onreadystatechange = function() { log("onreadystatechange " + xhr
.readyState
) }
20 xhr
.onload = function() { log("onload") }
21 xhr
.onloadstart = function() { log("onloadstart") }
22 xhr
.onprogress = function() { log("onprogress") }
23 xhr
.onerror = function() { log("onerror") }
25 xhr
.open("GET", "http://localhost:8000/xmlhttprequest/resources/reply.xml", false);
28 log("Exception thrown: " + ex
.name
);
31 if (xhr
.responseText
.length
)
32 alert("FAIL: Response is not empty, " + xhr
.responseText
);
34 logExisting
= document
.getElementById('console').innerHTML
;
35 document
.getElementById('console').innerHTML
= "";
37 xhr
= new XMLHttpRequest
;
38 xhr
.onreadystatechange = function() { log("onreadystatechange " + xhr
.readyState
) }
39 xhr
.onload = function() { log("onload") }
40 xhr
.onloadstart = function() { log("onloadstart") }
41 xhr
.onprogress = function() { log("onprogress") }
42 xhr
.onerror = function() { log("onerror") }
44 xhr
.open("GET", "http://localhost:7/", false); // A port that will likely refuse the connection.
47 log("Exception thrown: " + ex
.name
);
50 if (xhr
.responseText
.length
)
51 alert("FAIL: Response is not empty, " + xhr
.responseText
);
53 logMissing
= document
.getElementById('console').innerHTML
;
54 document
.getElementById('console').innerHTML
= "";
56 if (logMissing
== logExisting
)
59 log("FAIL. Responding server:");
60 document
.getElementById('console').innerHTML
+= logExisting
;
61 log("Non-existent server:");
62 document
.getElementById('console').innerHTML
+= logMissing
;