WebCore:
[WebKit-https.git] / LayoutTests / http / tests / security / cross-frame-access-history-get.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("\n----- tests for getting window.history and its properties -----\n");
38
39             // history object
40             shouldBeFalse("canGet('targetWindow.history.length')");
41
42             shouldBeTrue("canGet('targetWindow.history.back')");
43             shouldBeTrue("canGet('targetWindow.history.forward')");
44             shouldBeTrue("canGet('targetWindow.history.go')");
45
46             // FIXME: Calling these currently cause the subsequent test to include a dump of this test's render tree.
47             // (see http://bugs.webkit.org/show_bug.cgi?id=16510)
48             // shouldBeTrue("canCall('targetWindow.history.back')");
49             // shouldBeTrue("canCall('targetWindow.history.forward')");
50             // shouldBeTrue("canCall('targetWindow.history.go', '-1')");
51
52             shouldBeTrue("canGet('targetWindow.history.toString')");
53             shouldBe("toString('targetWindow.history')", "'[object History]'");
54
55             shouldBeFalse("canGet('targetWindow.__proto__')");
56             shouldBeFalse("canGet('targetWindow.constructor')");
57
58             // Check custom properties
59             shouldBeFalse("canGet('targetWindow.history.existingCustomProperty')");
60             shouldBeFalse("canGet('targetWindow.history.__proto__.prototypeCustomProperty')");
61             shouldBeFalse("canCall('targetWindow.history.existingCustomFunction')");
62             shouldBeFalse("canCall('targetWindow.history.prototypeCustomFunction')");
63         }
64     </script>
65 </head>
66 <body>
67 <iframe src="http://localhost:8000/security/resources/cross-frame-iframe-for-history-get-test.html"></iframe>
68 <pre id="console"></pre>
69 </body>
70 </html>