Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / cross-site-denied-response-sync-2.html
blobd25741a188c3b0bd49ddce9253c5ed96662fc3a3
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 if (req.responseText.length) {
25 error("responseText is not empty");
26 if (window.testRunner)
27 testRunner.notifyDone()
31 function stealResponse()
33 document.body.removeChild(document.getElementById('preOnerror'));
35 req.open("GET", "http://127.0.0.1:8000/xmlhttprequest/resources/zero-length.xml");
36 req.send();
37 req.onreadystatechange = checkResponse;
38 setTimeout(function() {
39 checkResponse();
40 if (!hadError)
41 log("PASS");
42 if (window.testRunner)
43 testRunner.notifyDone()
44 }, 100);
47 var req = new XMLHttpRequest;
48 req.open("GET", "http://localhost:8000/xmlhttprequest/resources/reply.xml", false);
49 try {
50 req.send(null);
51 error("send did not raise an exception");
52 } catch (ex) {
53 stealResponse();
55 </script>
56 </body>