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 } |
11 | 11 |
12 function lastPathComponent(url) | 12 function lastPathComponent(url) |
13 { | 13 { |
14 return url.split('/').pop(); | 14 return url.split('/').pop(); |
15 } | 15 } |
16 | 16 |
17 function hashOf(url) | 17 function hashOf(url) |
18 { | 18 { |
19 return url.substring(url.lastIndexOf('#')); | 19 return url.substring(url.lastIndexOf('#')); |
20 } | 20 } |
21 | 21 |
22 function runFirstStageOfTest() | 22 function runFirstStageOfTest() |
23 { | 23 { |
24 history.replaceState("FirstEntry", null, "#FirstEntry"); | 24 history.replaceState("FirstEntry", null, "#FirstEntry"); |
25 history.pushState("SecondEntry", null, "#SecondEntry"); | 25 history.pushState("SecondEntry", null, "#SecondEntry"); |
26 history.back(); | 26 history.back(); |
27 } | 27 } |
28 | 28 |
29 function runSecondStageOfTest() | |
30 { | |
31 alert("Last path component of location is " + lastPathComponent(location.hre
f)); | |
32 setTimeout("history.back();", 0); | |
33 } | |
34 | |
35 function runThirdStageOfTest() | |
36 { | |
37 alert("Final stage of test loaded"); | |
38 } | |
39 | |
40 function runTest() | 29 function runTest() |
41 { | 30 { |
42 alert("LOADED"); | 31 alert("LOADED"); |
43 if (!sessionStorage.stage) | 32 if (!sessionStorage.stage) |
44 runFirstStageOfTest(); | 33 runFirstStageOfTest(); |
45 else if (sessionStorage.stage == 2) | |
46 runSecondStageOfTest(); | |
47 else if (sessionStorage.stage == 3) | |
48 runThirdStageOfTest(); | |
49 } | 34 } |
50 | 35 |
51 onpopstate = function() | 36 onpopstate = function() |
52 { | 37 { |
53 alert("State popped - " + event.state + " (type " + typeof event.state + ")"
); | 38 alert("State popped - " + event.state + " (type " + typeof event.state + ")"
); |
54 | 39 |
55 // FIXME: Once the popstate and hashchange events fire asynchronously, we | 40 // FIXME: Once the popstate and hashchange events fire asynchronously, we |
56 // can eliminate this setTimeout hack. The hashchange event currently runs | 41 // can eliminate this setTimeout hack. The hashchange event currently runs |
57 // synchronously following the popstate event, but the calls to | 42 // synchronously following the popstate event, but the calls to |
58 // replaceState cause the location to change immediately. That confuses | 43 // replaceState cause the location to change immediately. That confuses |
(...skipping 28 matching lines...) Expand all Loading... |
87 <body onload="runTest();" onunload="/* disable page cache */"> | 72 <body onload="runTest();" onunload="/* disable page cache */"> |
88 <pre> | 73 <pre> |
89 This test: | 74 This test: |
90 -Builds up a list of state object entries with fragment URLs. | 75 -Builds up a list of state object entries with fragment URLs. |
91 -Navigates through them to verify that the popstate and hashchanged events are f
ired. | 76 -Navigates through them to verify that the popstate and hashchanged events are f
ired. |
92 -Navigates away to a new document, with the old document being destroyed. | 77 -Navigates away to a new document, with the old document being destroyed. |
93 -Navigates back to the state object entries and verifies the popstate event is f
ired even on the new documents. | 78 -Navigates back to the state object entries and verifies the popstate event is f
ired even on the new documents. |
94 </pre> | 79 </pre> |
95 </body> | 80 </body> |
96 </html> | 81 </html> |
OLD | NEW |