blob: 8e3d91d377f9e79c9facc1c9d1c3d26249209c27 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test for setting document.location.host to accepted values</title>
</head>
<body>
<pre id="pre"></pre>
<script>
// This function will be redefined as the test cases get executed
var testCaseOnload = function() {
runOneTestThatShouldBeAccepted(0);
};
var iframeDocument;
function iframeOnload() {
iframeDocument = document.getElementById("targetFrame").contentDocument;
testCaseOnload();
}
function log(s) {
document.getElementById("pre").appendChild(document.createTextNode(s));
}
function runOneTestThatShouldBeAccepted(testIndex) {
var testCasesThatShouldBeAccepted = [
{ hostString : 'localhost:8000', description : false }
,{ hostString : '127.0.0.1:8000', description : false }
];
if (testIndex >= testCasesThatShouldBeAccepted.length) {
if (window.testRunner)
testRunner.notifyDone();
} else {
// Prepare for next test case by setting testCaseOnload to load the test case
// and then load the simple HTML file that says "Before"
testCaseOnload = function () {
// Prepare test case execution by first setting testCaseOnload to check
// the test outcome and then load set the iframe's document.location.host
testCaseOnload = function(currentTestIndex) {
return function () {
var currentCase = testCasesThatShouldBeAccepted[currentTestIndex],
description = (currentCase.description ? currentCase.description : currentCase.hostString);
if (iframeDocument === null || iframeDocument.location.host == currentCase.hostString) {
log("PASS: " + description + " was accepted" + (iframeDocument === null ? " (at least the iframe contentDocument was null so it had changed origin)" : "") + ".\n");
} else {
log("FAIL: " + description + " was not accepted. The iframe contentDocument was not null and its location.host was not " + currentCase.hostString + ".\n");
}
runOneTestThatShouldBeAccepted(currentTestIndex + 1);
};
}(testIndex);
iframeDocument.location.host = testCasesThatShouldBeAccepted[testIndex].hostString;
};
document.getElementById("targetFrame").setAttribute("src", "http://127.0.0.1:8000/dom/resources/set-document-location-iframe.html");
}
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
</script>
<iframe id="targetFrame" src="resources/set-document-location-iframe.html" onload="iframeOnload()"></iframe>
</body>
</html>