<html>
<head>
<script>

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

var testStatus       = "FAIL: not completed";
var windowsOpened    = 0;
var mainWindowLoaded = false;
var testCompleted    = false;

function updateStatus(loaded, done)
{
    mainWindowLoaded |= loaded;
    testCompleted |= done;

    if (mainWindowLoaded && testCompleted) {
        document.getElementById("testStatus").innerHTML = testStatus;
        if (testCompleted && window.testRunner)
            testRunner.notifyDone();
    }
}

function windowOpened(windowOpener)
{
    if (windowOpener == self.sandboxed) {
        testStatus = "FAIL: sandboxed frame opened window";
        updateStatus(false, true);
    } else {
        ++windowsOpened;
        if (windowsOpened == 10 && !testCompleted) {
            testStatus = "PASS";
            updateStatus(false, true);
        }
    }
}

</script>
</head>

<body onload="updateStatus(true, false);">

    <p>Verifies that a sandboxed IFrame cannot open new windows
    using <code>window.open()</code>. Expect ten windows to be opened,
    but the sandboxed IFrame not to be the opener of any of them.</p>
    
    <p>This test will print &quot;PASS&quot; on success.</p>

    <iframe src="resources/sandboxed-iframe-navigation-windowopen.html"></iframe>
    <iframe src="resources/sandboxed-iframe-navigation-windowopen.html"></iframe>
    <iframe src="resources/sandboxed-iframe-navigation-windowopen.html"></iframe>
    <iframe src="resources/sandboxed-iframe-navigation-windowopen.html"></iframe>
    <iframe src="resources/sandboxed-iframe-navigation-windowopen.html"></iframe>

    <iframe src="resources/sandboxed-iframe-navigation-windowopen.html"
            sandbox="allow-scripts"
            name="sandboxed">
    </iframe>

    <iframe src="resources/sandboxed-iframe-navigation-windowopen.html"></iframe>
    <iframe src="resources/sandboxed-iframe-navigation-windowopen.html"></iframe>
    <iframe src="resources/sandboxed-iframe-navigation-windowopen.html"></iframe>
    <iframe src="resources/sandboxed-iframe-navigation-windowopen.html"></iframe>
    <iframe src="resources/sandboxed-iframe-navigation-windowopen.html"></iframe>

    <p id='testStatus'>FAIL: Script didn't run</p>
</body>
</html>
