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

    addEventListener("message", function() {
        // Call injected function.
        try {
            attack();
        } catch (e) {
            // V8 throws a TypeError: Cannot set property 'fail' of undefined.
        }

        // Post message to victim to check if it was accessed.
        document.getElementById('theFrame').contentWindow.postMessage("test", "*");
    }, false);
</script>
<body>
    <p>Test cross-origin direct document access.</p>
    <iframe id="theFrame" name="theFrame" src="resources/cross-frame-iframe-for-document-direct-test.html"></iframe>
</body>
</html>
