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

        function onloadForButtonChild() { 
            var targetChild = document.getElementById('targetChild');
            targetChild.src = "resources/targetChild-JSTargetNode-onclick-addEventListener.html";
            targetChild.onload = start;
        }

        function start() {
            var buttonChild = window.frames[1];
            buttonChild.document.getElementById('button').click();

            if (window.testRunner)
                testRunner.notifyDone();
        }
    </script>
</head>
<body>
    <p>This tests that frame used when setting eventListeners on an EventTarget using addEventListener is
       the target nodes frame. (rdar://problem/5426142).  This test passes if you don't see an alert dialog with
       the domain of "localhost" in it and no warnings are logged to the console.</p>
    <iframe id="targetChild" src=""></iframe>
    <iframe src="resources/childWithButton.html" onload="onloadForButtonChild();"></iframe>
</body>
</html>
