<html>
<body>
<p>Test that exceptions in iframe are not reported to the main frame window.onerror handler.
window.onerror should print exactly one line.</p>
<div id="result"></div>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function log(msg) {
    document.getElementById("result").innerHTML += msg + "<br>";
}

window.onerror = function(msg, url, line, column, error)
{
    url = url ? url.match( /[^\/]+\/?$/ )[0] : url;
    log("Main frame window.onerror: " + msg + " at " + url + ":" + line + ":" + column + " " + error);
    return true;
}

function receiveMessage(event) {
    if (event.data === "IFrameLoaded") {
        log("DONE");
        if (window.testRunner)
            testRunner.notifyDone();
    } else
        log("FAIL " + event.data);
}

window.addEventListener("message", receiveMessage, false);

throw "MainFrameException";

</script>
<iframe src="http://localhost:8000/security/resources/onerror-iframe.html"/>
</body>
</html>
