<html>
<head>
    <script src="cross-frame-access.js"></script>
    <script>
        var assignOld;
        var replaceOld;
        var reloadOld;
        var toStringOld;
        var customAttributeOld;

        receiver = function(e)
        {
            if (e.data == "settingValuesComplete")
                setCheck();
        }
        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 Check"));
                button.onclick = setCheck;
                document.body.appendChild(button);
            }

            window.location.customAttribute = "customAttribute";

            assignOld = window.location.assign;
            replaceOld = window.location.replace;
            reloadOld = window.location.reload;
            toStringOld = window.location.toString;
            customAttributeOld = window.location.customAttribute;

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

        setCheck = function()
        {
            log("\n----- tests for putting window.history and its properties -----\n");

            shouldBe("window.location.assign", "assignOld");
            shouldBe("window.location.replace", "replaceOld");
            shouldBe("window.location.reload", "reloadOld");
            shouldBe("window.location.toString", "toStringOld");
            shouldBe("window.location.customAttribute", "customAttributeOld");

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