<html>
<head>
    <script src="/js-test-resources/js-test-pre.js"></script>
    <script src="resources/cross-frame-access.js"></script>
    <script>
        jsTestIsAsync = true;

        window.onload = function()
        {
            if (window.testRunner) {
                setTimeout(pollForTest, 1);
            } else {
                log("To run the test, click the button below when the opened window finishes loading.");
                var button = document.createElement("button");
                button.appendChild(document.createTextNode("Run Test"));
                button.onclick = runTest;
                document.body.appendChild(button);
            }
        }

        pollForTest = function()
        {
            if (!testRunner.globalFlag) {
                setTimeout(pollForTest, 1);
                return;
            }
            runTest();
            finishJSTest();
        }

        function getCustomProperty(o)
        {
            return o.customProperty;
        }

        runTest = function()
        {
            window.targetWindow = frames[0];

            shouldThrowErrorName("getCustomProperty(targetWindow)", "SecurityError");
            shouldThrowErrorName("getCustomProperty(targetWindow)", "SecurityError");
            shouldThrowErrorName("getCustomProperty(targetWindow)", "SecurityError");
        }
    </script>
</head>
<body>
<p>This test checks that caching of property accesses doesn't allow for illegal cross-frame access of a custom property. It also checks for an assertion failure that once occurred in this situation.</p>
<iframe src="http://localhost:8000/security/resources/cross-frame-access-get-custom-property-cached-iframe.html" style=""></iframe>
<pre id="console"></pre>
<script src="/js-test-resources/js-test-post.js"></script>
</body>
</html>
