<html>
<head>
    <script src="resources/cross-frame-access.js"></script>
    <script>
        if (window.testRunner) {
            testRunner.dumpAsText();
            testRunner.dumpChildFramesAsText();
            testRunner.waitUntilDone();
        }

        onload = function()
        {
            // Add manual run buttons if the browser does not support window.postMessage
            if (!window.postMessage) {
                log("YOUR BROWSER DOES NOT SUPPORT window.postMessage");
                log("To run this test manually, first click the button titled 'Step 1 - Set Test' in this frame.");
                log("Then click the button in the sub frame titled 'Step 2 - Set Check' to finish the test.\n");

                var button = document.createElement("button");
                button.appendChild(document.createTextNode("Step 1 - Set Test"));
                button.onclick = setTest;
                document.body.appendChild(button);
            }
        }

        receiver = function(e)
        {
            if (e.data == "storedOldValuesComplete")
                setTest();
        }
        addEventListener('message', receiver, false);

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

            // Put testing for the many og standard attibutes of the location object is handeled in stand alone test
            // cases because they may produce side effects.
            try { targetWindow.location.assign = "FAIL!! CUSTOM assign"; } catch(e) { log(e); }
            try { targetWindow.location.replace = "FAIL!! CUSTOM replace"; } catch(e) { log(e); }
            try { targetWindow.location.reload = "FAIL!! CUSTOM reload"; } catch(e) { log(e); }
            try { targetWindow.location.toString = "FAIL!! CUSTOM toString"; } catch(e) { log(e); }

            try { targetWindow.location.customAttribute = "FAIL!! CUSTOM customAttribute"; } catch(e) { log(e); }

            if (window.postMessage)
                targetWindow.postMessage("settingValuesComplete", "*");
            else
                log("\nSet Test complete!  Click button entitled 'Step 2 - Set Check' to finish the test.");
        }
    </script>
</head>
<body>
    <iframe src="http://localhost:8000/security/resources/cross-frame-iframe-for-location-put-test.html"></iframe>
    <pre id="console"></pre>
</body>
</html>
