Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / origin-whitelisting-https.html
blob7fce1f77e4ba95b8f4ba7efb8d0608fd58aa0d17
1 <p>Tests that origin whitelisting for https does not match http URLs.</p>
3 <pre id="console"></pre>
4 <script>
5 testRunner.dumpAsText();
6 testRunner.waitUntilDone();
7 testRunner.addOriginAccessWhitelistEntry("http://127.0.0.1:8000", "https", "localhost", false);
9 function log(message)
11 document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
14 function test(url, expectSuccess)
16 log("Testing: " + url + " (sync)");
17 var req = new XMLHttpRequest();
18 req.open("GET", url + "?sync", false);
19 try {
20 req.send(null);
21 log((expectSuccess ? "PASS: " : "FAIL: ") + req.responseText);
22 } catch (e) {
23 log((expectSuccess ? "FAIL: " : "PASS: ") + e);
26 log("Testing: " + url + " (async)");
27 req = new XMLHttpRequest();
28 req.open("GET", url + "?async", true);
29 req.onload = function() {
30 log((expectSuccess ? "PASS: " : "FAIL: ") + req.responseText);
31 nextTest();
33 req.onerror = function() {
34 log((expectSuccess ? "FAIL: " : "PASS: ") + req.status);
35 nextTest();
37 req.send(null);
40 var tests = [
41 ["http://localhost:8000/xmlhttprequest/resources/get.txt", false]
42 // FIXME: Is it possible to setup the following tests?
43 // ["https://localhost:8000/xmlhttprequest/resources/get.txt", true]
46 var currentTest = 0;
48 function nextTest()
50 if (currentTest < tests.length)
51 test.apply(null, tests[currentTest++]);
52 else
53 testRunner.notifyDone();
56 nextTest();
57 </script>