Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / access-control-basic-get-fail-non-simple.html
blob304601c052ad9d1e458c521caadf82d1d914234c
1 <html>
2 <body>
3 <pre id='console'></pre>
4 <script type="text/javascript">
5 function log(message)
7 document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
10 if (window.testRunner)
11 testRunner.dumpAsText();
13 (function() {
14 var xhr = new XMLHttpRequest;
16 try {
17 xhr.open("GET", "http://localhost:8000/xmlhttprequest/resources/access-control-basic-get-fail-non-simple.cgi", false);
18 } catch(e) {
19 log("FAIL: Exception thrown. Cross-domain access is not allowed in 'open'. [" + e.message + "].");
20 return;
23 // Non-whitelisted method
24 xhr.setRequestHeader("x-webkit", "foobar");
26 // This is going to fail because the cgi script is not prepared for an OPTIONS request.
27 try {
28 xhr.send();
29 } catch(e) {
30 log("PASS: Exception thrown. Cross-domain access was denied in 'send'. [" + e.message + "].");
31 return;
34 log(xhr.responseText);
35 })();
36 </script>
37 </body>
38 </html>