blob: 4b89cee0c08094d84c00bb67e24deb13521b8145 [file] [log] [blame]
<p>Tests the behavior of whitelisting origins using exact matching.</p>
<pre id="console"></pre>
<script>
testRunner.dumpAsText();
testRunner.waitUntilDone();
testRunner.addOriginAccessWhitelistEntry("http://127.0.0.1:8000", "http", "localhost", false);
function log(message)
{
document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
}
function test(url, expectSuccess)
{
log("Testing: " + url + " (sync)");
var req = new XMLHttpRequest();
req.open("GET", url, false);
try {
req.send(null);
log((expectSuccess ? "PASS: " : "FAIL: ") + req.responseText);
} catch (e) {
log((expectSuccess ? "FAIL: " : "PASS: ") + e);
}
log("Testing: " + url + " (async)");
req = new XMLHttpRequest();
req.open("GET", url, true);
req.onload = function() {
log((expectSuccess ? "PASS: " : "FAIL: ") + req.responseText);
nextTest();
};
req.onerror = function() {
log((expectSuccess ? "FAIL: " : "PASS: ") + req.status);
nextTest();
};
req.send(null);
}
var tests = [
["http://localhost:8000/xmlhttprequest/resources/get.txt", true],
["http://loCALhost:8000/xmlhttprequest/resources/get.txt", true]
// FIXME: Is it possible to setup the following tests?
// ["http://localhost:8001/xmlhttprequest/resources/get.txt", false],
// ["http://foo.localhost:8000/xmlhttprequest/resources/get.txt", false],
// ["https://localhost:8000/xmlhttprequest/resources/get.txt", false]
];
var currentTest = 0;
function nextTest()
{
if (currentTest < tests.length)
test.apply(null, tests[currentTest++]);
else
testRunner.notifyDone();
}
nextTest();
</script>