OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script> | 3 <script> |
4 | 4 |
5 if (window.testRunner) { | 5 if (window.testRunner) { |
6 if (!sessionStorage.stage) | 6 if (!sessionStorage.stage) |
7 testRunner.clearBackForwardList(); | 7 testRunner.clearBackForwardList(); |
8 testRunner.dumpAsText(); | 8 testRunner.dumpAsText(); |
9 testRunner.waitUntilDone(); | 9 testRunner.waitUntilDone(); |
10 } | 10 } |
(...skipping 24 matching lines...) Expand all Loading... |
35 { | 35 { |
36 if (!sessionStorage.stage) { | 36 if (!sessionStorage.stage) { |
37 // Location changes need to happen outside the onload handler to generat
e history entries. | 37 // Location changes need to happen outside the onload handler to generat
e history entries. |
38 setTimeout(runFirstStageOfTest, 0); | 38 setTimeout(runFirstStageOfTest, 0); |
39 } else if (sessionStorage.stage == 2) | 39 } else if (sessionStorage.stage == 2) |
40 runSecondStageOfTest(); | 40 runSecondStageOfTest(); |
41 else if (sessionStorage.stage == 3) | 41 else if (sessionStorage.stage == 3) |
42 runThirdStageOfTest(); | 42 runThirdStageOfTest(); |
43 } | 43 } |
44 | 44 |
45 var beganTest = false; | |
46 | |
47 function statePopped() | 45 function statePopped() |
48 { | 46 { |
49 // The first time popstate fires, it's because the page has finished loading
. | |
50 // Only then can we begin the test. | |
51 if (!beganTest) { | |
52 beganTest = true; | |
53 runTest(); | |
54 // Continue with the handler if we've already began the test. | |
55 if (!sessionStorage.stage) | |
56 return; | |
57 } | |
58 | |
59 alert("State popped - " + event.state + " (type " + typeof event.state + ")"
); | 47 alert("State popped - " + event.state + " (type " + typeof event.state + ")"
); |
60 if (event.state == "FirstEntry") { | 48 if (event.state == "FirstEntry") { |
61 history.replaceState("FirstEntryWillLaterBeReactivated", null, "?FirstEn
tryWillLaterBeReactivated"); | 49 history.replaceState("FirstEntryWillLaterBeReactivated", null, "?FirstEn
tryWillLaterBeReactivated"); |
62 history.forward(); | 50 history.forward(); |
63 } else if (event.state == "SecondEntry") { | 51 } else if (event.state == "SecondEntry") { |
64 history.replaceState("SecondEntryWillLaterBeReactivated", null, "?Second
EntryWillLaterBeReactivated"); | 52 history.replaceState("SecondEntryWillLaterBeReactivated", null, "?Second
EntryWillLaterBeReactivated"); |
65 window.location = "resources/navigate-back.html"; | 53 window.location = "resources/navigate-back.html"; |
66 } else if (event.state == "SecondEntryWillLaterBeReactivated") | 54 } else if (event.state == "SecondEntryWillLaterBeReactivated") |
67 history.back(); | 55 history.back(); |
68 else if (event.state == "FirstEntryWillLaterBeReactivated") { | 56 else if (event.state == "FirstEntryWillLaterBeReactivated") { |
69 alert("Test complete"); | 57 alert("Test complete"); |
70 sessionStorage.clear(); | 58 sessionStorage.clear(); |
71 if (window.testRunner) | 59 if (window.testRunner) |
72 testRunner.notifyDone(); | 60 testRunner.notifyDone(); |
73 } | 61 } |
74 } | 62 } |
75 | 63 |
76 </script> | 64 </script> |
77 <body onpopstate="statePopped();" onunload="/* disable page cache */"> | 65 <body onload="runTest();" onpopstate="statePopped();" onunload="/* disable page
cache */"> |
78 <pre> | 66 <pre> |
79 This test: | 67 This test: |
80 -Builds up a list of state object entries with fragment URLs. | 68 -Builds up a list of state object entries with fragment URLs. |
81 -Navigates through them to verify that the popstate event is fired. | 69 -Navigates through them to verify that the popstate event is fired. |
82 -Navigates away to a new document, with the old document being destroyed. | 70 -Navigates away to a new document, with the old document being destroyed. |
83 -Navigates back to the state object entries and verifies the popstate event is f
ired even on the new documents. | 71 -Navigates back to the state object entries and verifies the popstate event is f
ired even on the new documents. |
84 </pre><br> | 72 </pre><br> |
85 <pre id="logger"></pre> | 73 <pre id="logger"></pre> |
86 </body> | 74 </body> |
87 </html> | 75 </html> |
OLD | NEW |