Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / access-control-basic-whitelist-response-headers.html
bloba6d758ced6a8b54123345bbe3e751e77020a2cad
1 <html>
2 <body>
3 <pre id='console'></pre>
4 <script type="text/javascript">
5 if (window.testRunner)
6 testRunner.dumpAsText();
8 function log(message)
10 document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
13 var xhr;
15 function testAllowed(name)
17 if (xhr.getResponseHeader(name))
18 log("PASS: Response header " + name + " allowed.");
19 else
20 log("FAIL: Response header " + name + " not allowed.");
23 function testDenied(name)
25 if (!xhr.getResponseHeader(name))
26 log("PASS: Response header " + name + " denied.");
27 else
28 log("FAIL: Response header " + name + " not denied.");
32 xhr = new XMLHttpRequest;
33 xhr.open("GET", "http://localhost:8000/xmlhttprequest/resources/access-control-basic-whitelist-response-headers.cgi", false);
34 xhr.send();
36 // Test getResponseHeader()
37 testAllowed("cache-control");
38 testAllowed("content-language");
39 testAllowed("content-type");
40 testAllowed("expires");
41 testAllowed("last-modified");
42 testAllowed("pragma");
43 testDenied("x-webkit");
45 // Test getAllResponseHeaders()
46 if (!xhr.getAllResponseHeaders().match("foobar"))
47 log("PASS: Non-whitelisted headers not passed to getAllResponseHeaders().");
48 else
49 log("FAIL: Non-whitelisted headers passed to getAllResponseHeaders().");
50 </script>
51 </body>
52 </html>