WebCore:
[WebKit-https.git] / LayoutTests / http / tests / security / cross-frame-access-history-get-override.html
1 <html>
2 <head>
3     <script src="resources/cross-frame-access.js"></script>
4     <script>
5         window.onload = function()
6         {
7             if (window.layoutTestController) {
8                 layoutTestController.dumpAsText();
9                 layoutTestController.waitUntilDone();
10             }
11
12             if (window.layoutTestController) {
13                 setTimeout(pollForTest, 1);
14             } else {
15                 log("To run the test, click the button below when the opened window finishes loading.");
16                 var button = document.createElement("button");
17                 button.appendChild(document.createTextNode("Run Test"));
18                 button.onclick = runTest;
19                 document.body.appendChild(button);
20             }
21         }
22
23         pollForTest = function()
24         {
25             if (!layoutTestController.globalFlag) {
26                 setTimeout(pollForTest, 1);
27                 return;
28             }
29             runTest();
30             layoutTestController.notifyDone();
31         }
32
33         runTest = function()
34         {
35             window.targetWindow = frames[0];
36
37             log("----- tests for getting custorm overrides of window.history's functions  -----\n");
38
39             // Overriden using window.history.back = function() { return "new back" }
40             newBack = function() { return "new back"; }
41             shouldBeTrue("canGet('targetWindow.history.back')");
42             shouldBe("toString('targetWindow.history.back')", "toString(newBack)");
43
44             // Overriden using window.history.__proto__.forward = function() { return "new forward;" }
45             newForward = function() { return "new forward"; }
46             shouldBeTrue("canGet('targetWindow.history.forward')");
47             shouldBe("toString('targetWindow.history.forward')", "toString(newForward)");
48
49             // Overriden using window.history.go = "new go"
50             shouldBeTrue("canGet('targetWindow.history.go')");
51             shouldBe("toString('targetWindow.history.go')", "'new go'");
52         }
53     </script>
54 </head>
55 <body>
56 <iframe src="http://localhost:8000/security/resources/cross-frame-iframe-for-history-get-override-test.html"></iframe>
57 <pre id="console"></pre>
58 </body>
59 </html>