Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / loader / stateobjects / document-destroyed-navigate-back.html
1 <html>
2 <head>
3 <script>
4
5 if (window.testRunner) {
6     if (!sessionStorage.stage)
7         testRunner.clearBackForwardList();
8     testRunner.dumpAsText();
9     testRunner.waitUntilDone();
10 }
11
12 function lastPathComponent()
13 {
14     return window.location.href.split('/').pop();
15 }
16
17 function runFirstStageOfTest()
18 {
19     history.replaceState("FirstEntry", null, "?FirstEntry");
20     history.pushState("SecondEntry", null, "?SecondEntry");
21     history.back();
22 }
23
24 function runTest()
25 {
26     if (!sessionStorage.stage) {
27         // Location changes need to happen outside the onload handler to generate history entries.
28         setTimeout(runFirstStageOfTest, 0);
29     } else if (sessionStorage.stage == 2)
30         alert("Last path component of location is " + lastPathComponent());
31 }
32
33 function continueTest(state)
34 {
35     if (state == "FirstEntry") {
36         history.replaceState("FirstEntryWillLaterBeReactivated", null, "?FirstEntryWillLaterBeReactivated");
37         history.forward();
38     } else if (state == "SecondEntry") {
39         history.replaceState("SecondEntryWillLaterBeReactivated", null, "?SecondEntryWillLaterBeReactivated");
40         window.location = "resources/navigate-back.html";
41     } else if (state == "SecondEntryWillLaterBeReactivated")
42         history.back();
43     else if (state == "FirstEntryWillLaterBeReactivated") {
44         alert("Test complete");
45         sessionStorage.clear();
46         if (window.testRunner)
47             testRunner.notifyDone();
48     }
49 }
50
51 window.onpopstate = function statePopped()
52 {
53     var state = event.state;
54     alert("State popped - " + state + " (type " + typeof state + ")");
55     continueTest(state);
56 }
57
58 window.onpageshow = function pageShown()
59 {
60     if (sessionStorage.stage == 2) {
61         var state = history.state;
62         alert("Page shown - " + state + " (type " + typeof state + ")");
63         continueTest(state);
64     }
65 }
66
67 </script>
68 <body onload="runTest();" onunload="/* disable page cache */">
69 <pre>
70 This test:
71 -Builds up a list of state object entries with fragment URLs.
72 -Navigates through them to verify that the popstate event is fired.
73 -Navigates away to a new document, with the old document being destroyed.
74 -Navigates back to the state object entries and verifies the pageshow or popstate events are fired on the new documents.
75 </pre><br>
76 <pre id="logger"></pre>
77 </body>
78 </html>