blob: 62efc9ed7ceb84ca28d8762d1eded7b2822f5daa [file] [log] [blame]
<p>Tests the special case of allowlisting all origins.</p>
<pre id="console"></pre>
<script>
testRunner.dumpAsText();
testRunner.waitUntilDone();
testRunner.addOriginAccessAllowListEntry("http://127.0.0.1:8000", "http", "", true);
testRunner.addOriginAccessAllowListEntry("http://localhost:8000", "http", "", true);
function log(message)
{
document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
}
function testDomain()
{
var url = "http://localhost:8000/xmlhttprequest/resources/get.txt";
log("Testing: " + url + " (sync)");
var req = new XMLHttpRequest();
req.open("GET", url, false);
try {
req.send(null);
log("PASS: " + req.responseText);
} catch (e) {
log("FAIL: " + e);
}
log("Testing: " + url + " (async)");
req = new XMLHttpRequest();
req.open("GET", url, true);
req.onload = function() {
log("PASS: " + req.responseText);
testIPAddress();
};
req.onerror = function() {
log("FAIL: " + req.status);
testIPAddress();
};
req.send(null);
}
function testIPAddress()
{
var iframe = document.createElement("iframe");
document.body.appendChild(iframe);
iframe.src = "http://localhost:8000/xmlhttprequest/resources/origin-allowlisting-ip-address-test.html";
window.addEventListener("message", function(e) {
if (e.data == "DONE")
testRunner.notifyDone();
else
log(e.data);
}, false);
}
testDomain();
</script>