Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / cross-site-denied-response.html
blob8af93c35c74e87bf9f94dd55043fc6ca5d94f594
1 <body>
2 <pre id=preOnerror>FAIL: onerror was not called.</pre>
3 <pre id=console></pre>
4 <script>
5 if (window.testRunner) {
6 testRunner.dumpAsText();
7 testRunner.waitUntilDone();
10 function log(message)
12 document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
15 var hadError = false;
16 function error(message)
18 hadError = true;
19 log("FAIL: " + message);
22 function checkResponse()
24 try {
25 document.body.removeChild(document.getElementById('preOnerror'));
27 if (req.responseText.length)
28 error("responseText is not empty");
29 if (req.responseXML)
30 error("responseXML is not null");
31 try {
32 if (req.status)
33 error("status is not zero: " + req.status);
34 } catch (ex) {
36 try {
37 if (req.statusText)
38 error("statusText is not empty: " + req.statusText);
39 } catch (ex) {
41 try {
42 if (req.getAllResponseHeaders().length)
43 error("getAllResponseHeaders() result is not empty: " + req.getAllResponseHeaders());
44 } catch (ex) {
47 if (!hadError)
48 log("PASS");
49 } catch (ex) {
50 log(ex);
52 if (window.testRunner)
53 testRunner.notifyDone();
56 var req = new XMLHttpRequest;
57 req.open("GET", "http://localhost:8000/xmlhttprequest/resources/reply.xml")
58 req.onerror = function() { setTimeout(checkResponse, 100); } // Giving the time for load to continue.
59 req.send(null);
60 </script>
61 </body>