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");
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");
38 } else if (state
== "SecondEntry") {
39 history
.replaceState("SecondEntryWillLaterBeReactivated", null, "?SecondEntryWillLaterBeReactivated");
40 window
.location
= "resources/navigate-back.html";
41 } else if (state
== "SecondEntryWillLaterBeReactivated")
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
+ ")");
58 window
.onpageshow
= function pageShown()
60 if (sessionStorage
.stage
== 2) {
61 var state
= history
.state
;
62 alert("Page shown - " + state
+ " (type " + typeof state
+ ")");
68 <body onload=
"runTest();" onunload=
"/* disable page cache */">
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.
76 <pre id=
"logger"></pre>