| <html> |
| <head> |
| <script> |
| |
| if (window.layoutTestController) { |
| layoutTestController.clearBackForwardList(); |
| layoutTestController.dumpAsText(); |
| layoutTestController.waitUntilDone(); |
| } |
| |
| function log(txt) |
| { |
| document.getElementById("logger").innerText += txt + "\n"; |
| } |
| |
| function runTest() |
| { |
| history.pushState("StateStringData", "New title"); |
| log("History length is " + history.length); |
| history.replaceState(1, "Replaced title"); |
| log("History length is " + history.length); |
| history.back(); |
| } |
| |
| var beganTest = false; |
| |
| onpopstate = function(event) |
| { |
| // The first time popstate fires, it's because the page has finished loading. |
| // Only then can we begin the test. |
| if (!beganTest) { |
| beganTest = true; |
| runTest(); |
| return; |
| } |
| |
| log("State popped - " + event.state + " (type " + typeof event.state + ")"); |
| if (event.state == null) |
| history.forward(); |
| else if (window.layoutTestController) |
| layoutTestController.notifyDone(); |
| } |
| |
| </script> |
| <body> |
| <pre> |
| This test does the following: |
| -Makes a call to pushState() |
| -Makes sure the history length is correct |
| -Makes a call to replaceState() |
| -Makes sure the history length is correct |
| -Goes back, and makes sure the popstate event is correct |
| -Goes forward, and makes sure the popstate event represents the replaced state object |
| </pre><br> |
| <pre id="logger"></pre> |
| </body> |
| </html> |