<html>
<head>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function log(msg) {
    var div = document.createElement("div");
    div.innerText = msg;
    document.getElementById("console").appendChild(div);
}

function fail() {
    log("FAIL: The origin of the document was mutated.");
    if (window.testRunner)
        testRunner.notifyDone();
}

function pass() {
    log("PASS");
}

window.addEventListener("message", function (evt) {
    var fr = document.getElementById("theFrame");
    if (evt.data == "step1-ready") {
        fr.sandbox = "allow-scripts";
        fr.contentWindow.postMessage("go", "*");
    } else if (evt.data == "step1-done")
        fr.src = "resources/sandboxed-iframe-origin-remove-step2.html";
    else if (evt.data == "step2-done") {
        if (window.testRunner)
            testRunner.notifyDone();
    }
}, false);

</script>
</head>

<body>
<p>Test that removing allow-origin after creating an iframe doesn't modify
the origin of an existing document, but it doesn modify the origin of the
next document.</p>

<div id="console"></div>
 
<iframe id="theFrame" sandbox="allow-scripts allow-same-origin"
        src="resources/sandboxed-iframe-origin-remove-step1.html">
</iframe>
</body>
</html>
