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

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

window.onload = function() {
    window.popup = window.open("resources/popup-ready-to-navigate-child.html", "target");
}

window.addEventListener("message", function(e) {
    log(e.data);

    if (e.data == "ready") {
        window.savedFunction = popup.go;
        popup.location = "http://127.0.0.1:8080/security/frameNavigation/resources/iframe-with-inner-frame-on-foreign-domain.html";
        return;
    }

    if (e.data = "iframe-with-inner-frame-on-foreign-domain-LOADED") {
        log("Attempting navigation...");
        try {
            window.savedFunction();
            if (window.testRunner)
                testRunner.notifyDone();
        } catch(e) {
            log(e);
            testRunner.notifyDone();
        }
        return;
    }

}, false);
</script>
</head>
<body>
This test passes if it doesn't alert "FAIL".
<div id="console"></div>
</body>
</html>
