| <html> |
| <head> |
| <script> |
| |
| if (window.testRunner) { |
| testRunner.clearBackForwardList(); |
| testRunner.dumpAsText(); |
| testRunner.waitUntilDone(); |
| } |
| |
| function log(txt) |
| { |
| document.getElementById("logger").innerText += txt + "\n"; |
| } |
| |
| function runTest() |
| { |
| history.replaceState("OriginalEntry", "original"); |
| history.pushState(null, null, "#"); |
| history.pushState(null, null, ""); |
| history.pushState(null, null, "#hash"); |
| history.pushState(null, null, "#otherhash"); |
| history.pushState(null, null, "#"); |
| history.pushState(null, null, null); |
| history.pushState(null, null, "some-other.html"); |
| history.pushState(null, null, "some-other.html?withquery"); |
| history.pushState(null, null, "some-other.html?withquery#"); |
| history.pushState(null, null, "some-other.html?withquery"); |
| history.pushState(null, null, "some-other.html?withquery#somehash"); |
| history.pushState(null, null, "some-other.html?withquery#"); |
| history.pushState(null, null, "some-other.html?withquery#someotherhash"); |
| history.pushState(null, null, "some-other.html?withsomeotherquery#someotherhash"); |
| history.pushState(null, null, "some-other.html?withsomeotherquery#somehash"); |
| history.pushState(null, null, "some-other.html?withsomeotherquery"); |
| history.pushState(null, null, "some-other.html?withsomeotherquery#"); |
| history.pushState(null, null, "some-other.html?withsomeotherquery"); |
| |
| history.pushState("BufferEntry", "Last entry"); |
| history.back(); |
| } |
| |
| function lastPathComponent(url) |
| { |
| return url.split('/').pop(); |
| } |
| |
| onpopstate = function(event) |
| { |
| log("State popped with event " + event.state + " (type " + typeof event.state + ") and last path component " + lastPathComponent(location.href)); |
| if (event.state != "OriginalEntry") |
| setTimeout("history.back();", 0); |
| else if (window.testRunner) |
| testRunner.notifyDone(); |
| } |
| |
| onhashchange = function(event) |
| { |
| log("Hash change fired and last path component is " + lastPathComponent(event.newURL)); |
| } |
| |
| </script> |
| <body onload="runTest();"> |
| <pre> |
| This test pushes a series of state objects with different URLs and fragment identifiers meant to test the hashChange event as states are popped. |
| </pre><br> |
| <pre id="logger"></pre> |
| </body> |
| </html> |