Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / origin-whitelisting-exact-match.html
blob4b89cee0c08094d84c00bb67e24deb13521b8145
1 <p>Tests the behavior of whitelisting origins using exact matching.</p>
3 <pre id="console"></pre>
4 <script>
5 testRunner.dumpAsText();
6 testRunner.waitUntilDone();
7 testRunner.addOriginAccessWhitelistEntry("http://127.0.0.1:8000", "http", "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, 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, 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", true],
42 ["http://loCALhost:8000/xmlhttprequest/resources/get.txt", true]
43 // FIXME: Is it possible to setup the following tests?
44 // ["http://localhost:8001/xmlhttprequest/resources/get.txt", false],
45 // ["http://foo.localhost:8000/xmlhttprequest/resources/get.txt", false],
46 // ["https://localhost:8000/xmlhttprequest/resources/get.txt", false]
49 var currentTest = 0;
51 function nextTest()
53 if (currentTest < tests.length)
54 test.apply(null, tests[currentTest++]);
55 else
56 testRunner.notifyDone();
59 nextTest();
60 </script>