1 <p>Tests the behavior of whitelisting origins and removing them later.
</p>
3 <pre id=
"console"></pre>
5 testRunner
.dumpAsText();
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);
20 log((expectSuccess
? "PASS: " : "FAIL: ") + req
.responseText
);
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" : ""));
32 testRunner
.addOriginAccessWhitelistEntry(origin
, protocol
.toLowerCase(), host
.toLowerCase(), subdomains
);
36 testRunner
.removeOriginAccessWhitelistEntry(origin
, protocol
, host
, subdomains
);
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
) });