blob: 7da6a7c2b910b56165a3215b939f2928d1f0a176 [file] [log] [blame]
<p>Tests the behavior of allowlisting origins using exact matching.</p>
<pre id="console"></pre>
<script>
testRunner.dumpAsText();
testRunner.waitUntilDone();
testRunner.addOriginAccessAllowListEntry("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>