Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / origin-whitelisting-removal.html
blob36540a1cf19dadec0b1701a71e10234224989203
1 <p>Tests the behavior of whitelisting origins and removing them later.</p>
3 <pre id="console"></pre>
4 <script>
5 testRunner.dumpAsText();
7 function log(message)
9 document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
12 function loadURL(url, expectSuccess)
14 log("Loading: " + url + " " + (expectSuccess ? "(expecting PASS)" : "(expecting NETWORK_ERR)"));
16 var req = new XMLHttpRequest();
17 req.open("GET", url, false);
18 try {
19 req.send(null);
20 log((expectSuccess ? "PASS: " : "FAIL: ") + req.responseText);
21 } catch (e) {
22 log((expectSuccess ? "FAIL: " : "PASS: ") + e);
26 function test(origin, protocol, host, subdomains, url)
28 log("Testing: source origin: " + origin + " destination origin: " + protocol + ":" + host + " " + (subdomains ? "allowing subdomains" : ""));
30 loadURL(url, false);
32 testRunner.addOriginAccessWhitelistEntry(origin, protocol.toLowerCase(), host.toLowerCase(), subdomains);
34 loadURL(url, true);
36 testRunner.removeOriginAccessWhitelistEntry(origin, protocol, host, subdomains);
38 loadURL(url, false);
40 log("\n");
43 var tests = [
44 ["http://127.0.0.1:8000", "http", "localhost", false, "http://localhost:8000/xmlhttprequest/resources/get.txt"],
45 ["http://127.0.0.1:8000", "http", "localhost", true, "http://localhost:8000/xmlhttprequest/resources/get.txt"],
46 ["http://127.0.0.1:8000", "hTtP", "LoCaLhOsT", true, "http://localhost:8000/xmlhttprequest/resources/get.txt"],
47 ["http://127.0.0.1:8000", "http", "", true, "http://localhost:8000/xmlhttprequest/resources/get.txt"]
50 tests.forEach(function(testEntry) { test.apply(null, testEntry) });
51 </script>