Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / access-control-basic-non-simple-deny-cached.html
blob49e917c9ada71ac827085e06f107e9cad9bd77a8
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("PUT", "http://localhost:8000/xmlhttprequest/resources/access-control-basic-non-get-allow.cgi", false);
18 } catch(e) {
19 log("FAIL: Exception thrown. PUT cross-domain access is not allowed in 'open'. [" + e.message + "].");
20 return;
23 xhr.setRequestHeader("Content-Type", "text/plain");
25 try {
26 xhr.send("PASS: PUT data received");
27 } catch(e) {
28 log("FAIL: Exception thrown. PUT cross-domain access is not allowed in 'send'. [" + e.message + "].");
29 return;
32 try {
33 xhr.open("PUT", "http://localhost:8000/xmlhttprequest/resources/access-control-basic-non-get-allow.cgi", false);
34 } catch(e) {
35 log("FAIL: Exception thrown. GET cross-domain access is not allowed in 'open'. [" + e.message + "].");
36 return;
39 xhr.setRequestHeader("Content-Type", "application/xml");
41 try {
42 xhr.send("FAIL: PUT data received");
43 log("FAIL: Exception not thrown. Cross-domain access was allowed, even though content type was not on white list.");
44 log(xhr.responseText);
45 } catch(e) {
46 log("PASS: Exception thrown. Cross-domain access is not allowed in 'send'. [" + e.message + "].");
47 return;
49 })();
50 </script>
51 </body>
52 </html>