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 testRunner.clearBackForwardList(); | 6 testRunner.clearBackForwardList(); |
7 testRunner.dumpAsText(); | 7 testRunner.dumpAsText(); |
8 testRunner.waitUntilDone(); | 8 testRunner.waitUntilDone(); |
9 } | 9 } |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 history.pushState("BufferEntry", "Last entry"); | 38 history.pushState("BufferEntry", "Last entry"); |
39 history.back(); | 39 history.back(); |
40 } | 40 } |
41 | 41 |
42 function lastPathComponent(url) | 42 function lastPathComponent(url) |
43 { | 43 { |
44 return url.split('/').pop(); | 44 return url.split('/').pop(); |
45 } | 45 } |
46 | 46 |
47 var beganTest = false; | |
48 | |
49 onpopstate = function(event) | 47 onpopstate = function(event) |
50 { | 48 { |
51 // The first time popstate fires, it's because the page has finished loading
. | |
52 // Only then can we begin the test. | |
53 if (!beganTest) { | |
54 beganTest = true; | |
55 runTest(); | |
56 return; | |
57 } | |
58 | |
59 log("State popped with event " + event.state + " (type " + typeof event.stat
e + ") and last path component " + lastPathComponent(location.href)); | 49 log("State popped with event " + event.state + " (type " + typeof event.stat
e + ") and last path component " + lastPathComponent(location.href)); |
60 if (event.state != "OriginalEntry") | 50 if (event.state != "OriginalEntry") |
61 setTimeout("history.back();", 0); | 51 setTimeout("history.back();", 0); |
62 else if (window.testRunner) | 52 else if (window.testRunner) |
63 testRunner.notifyDone(); | 53 testRunner.notifyDone(); |
64 } | 54 } |
65 | 55 |
66 onhashchange = function(event) | 56 onhashchange = function(event) |
67 { | 57 { |
68 log("Hash change fired and last path component is " + lastPathComponent(even
t.newURL)); | 58 log("Hash change fired and last path component is " + lastPathComponent(even
t.newURL)); |
69 } | 59 } |
70 | 60 |
71 </script> | 61 </script> |
72 <body> | 62 <body onload="runTest();"> |
73 <pre> | 63 <pre> |
74 This test pushes a series of state objects with different URLs and fragment iden
tifiers meant to test the hashChange event as states are popped. | 64 This test pushes a series of state objects with different URLs and fragment iden
tifiers meant to test the hashChange event as states are popped. |
75 </pre><br> | 65 </pre><br> |
76 <pre id="logger"></pre> | 66 <pre id="logger"></pre> |
77 </body> | 67 </body> |
78 </html> | 68 </html> |
OLD | NEW |