<body>
<p>Test that we don't crash when creating a message port for an inactive document.</p>
<pre id=log></pre>
<script>
function log(message)
{
    document.getElementById("log").innerHTML += message + "<br>";
}

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

var closure;
var failed;

function test()
{
    failed = false;
    closure = window.frames[0].createClosure();
    document.getElementsByTagName("iframe")[0].onload = test2;
    window.frames[0].location = "resources/banking-site.html";
}

function test2()
{
   try {
      var channel = closure();
    } catch (ex) {
      log("FAIL: got exception while creating port from closed frame's constructor: " + ex);
      done();
      return;
    }
    log("PASS: Creating MessageChannel from closed frame does not crash");
    done();
}

function done()
{
    log("DONE");
    if (window.testRunner)
        testRunner.notifyDone();
}

</script>
<iframe src="resources/attacker-frame.html" onload="test()"></iframe>
</body>
