beidson@apple.com | 08c6175 | 2009-12-03 19:04:40 +0000 | [diff] [blame] | 1 | <html> |
| 2 | <head> |
| 3 | <script> |
| 4 | |
rniwa@webkit.org | 03b9c6d | 2012-07-16 01:41:53 +0000 | [diff] [blame] | 5 | if (window.testRunner) { |
| 6 | testRunner.clearBackForwardList(); |
| 7 | testRunner.dumpAsText(); |
| 8 | testRunner.waitUntilDone(); |
beidson@apple.com | 08c6175 | 2009-12-03 19:04:40 +0000 | [diff] [blame] | 9 | } |
| 10 | |
| 11 | function log(txt) |
| 12 | { |
| 13 | document.getElementById("logger").innerText += txt + "\n"; |
| 14 | } |
| 15 | |
| 16 | function runTest() |
| 17 | { |
| 18 | history.pushState("StateStringData", "New title"); |
| 19 | log("History length is " + history.length); |
| 20 | history.back(); |
| 21 | } |
| 22 | |
| 23 | function statePopped() |
| 24 | { |
| 25 | log("State popped - " + event.state + " (type " + typeof event.state + ")"); |
| 26 | if (event.state == null) { |
| 27 | document.body.onpopstate = statePopped; |
| 28 | history.forward(); |
rniwa@webkit.org | 03b9c6d | 2012-07-16 01:41:53 +0000 | [diff] [blame] | 29 | } else if (window.testRunner) |
| 30 | testRunner.notifyDone(); |
beidson@apple.com | 08c6175 | 2009-12-03 19:04:40 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | </script> |
commit-queue@webkit.org | 78da3b8 | 2015-10-02 15:13:05 +0000 | [diff] [blame] | 34 | <body onload="runTest();"> |
beidson@apple.com | 08c6175 | 2009-12-03 19:04:40 +0000 | [diff] [blame] | 35 | <pre> |
| 36 | This test does the following: |
| 37 | -Uses body.onpopstate to add a popstate handler (both by using the inline attribute and a script-assigned attribute) |
| 38 | -Makes a call to pushState() |
| 39 | -Makes sure the history length is correct |
| 40 | -Goes back, and makes sure the popstate event is correct |
| 41 | -Goes forward, and makes sure the popstate event is correct |
| 42 | </pre><br> |
| 43 | <pre id="logger"></pre> |
| 44 | </body> |
| 45 | <script> |
| 46 | document.body.onpopstate = statePopped; |
| 47 | </script> |
| 48 | </html> |