<html>
<head>
    <script src="cross-frame-access.js"></script>
    <script>
        receiver = function(e)
        {
            if (e.data == "settingValuesComplete")
                setTest();
        }
        addEventListener('message', receiver, false);

        window.onload = function()
        {
            // Add manuel run buttons if the browser does not support window.postMessage
            if (!window.postMessage) {
                var button = document.createElement("button");
                button.appendChild(document.createTextNode("Step 2 - Set Test"));
                button.onclick = setTest;
                document.body.appendChild(button);
            }

            window.__defineGetter__("myGetter", function() { return "myGetter";});
            window.__defineSetter__("myGetter", function(x) { return "mySetter";});
            window.myProp = "myPropValue";

            if (window.postMessage)
                window.parent.postMessage("propertiesSet", "*");
        }

        setTest = function()
        {

            log("\n----- test that functions could not be injected cross-frame using Object.prototype -----\n");

            shouldBe("window.hasOwnProperty('injectedGetter')", "false");
            shouldBe("window.__lookupGetter__('injectedGetter')", "undefined");
            shouldBe("window.hasOwnProperty('injectedSetter')", "false");
            shouldBe("window.__lookupSetter__('injectedSetter')", "undefined");
            shouldBe("window.injectedGetter", "undefined");
            shouldBe("window.injectedSetter = 1", "1");

            if (window.testRunner)
                testRunner.notifyDone();
        }
    </script>
</head>
<body>
    <pre id="console"></pre>
</body>
</html>
