Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / loader / stateobjects / document-destroyed-navigate-back.html
blobd812aa2a447565697dcceb7d29f297a67afbf368
1 <html>
2 <head>
3 <script>
5 if (window.testRunner) {
6 if (!sessionStorage.stage)
7 testRunner.clearBackForwardList();
8 testRunner.dumpAsText();
9 testRunner.waitUntilDone();
12 function lastPathComponent()
14 return window.location.href.split('/').pop();
17 function runFirstStageOfTest()
19 history.replaceState("FirstEntry", null, "?FirstEntry");
20 history.pushState("SecondEntry", null, "?SecondEntry");
21 history.back();
24 function runTest()
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());
33 function continueTest(state)
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();
51 window.onpopstate = function statePopped()
53 var state = event.state;
54 alert("State popped - " + state + " (type " + typeof state + ")");
55 continueTest(state);
58 window.onpageshow = function pageShown()
60 if (sessionStorage.stage == 2) {
61 var state = history.state;
62 alert("Page shown - " + state + " (type " + typeof state + ")");
63 continueTest(state);
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>