| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../../resources/js-test-pre.js"></script> |
| </head/> |
| <body> |
| <script> |
| description("Check that PopStateEvent.state always has a correct value."); |
| |
| window.jsTestIsAsync = true; |
| if (window.testRunner) { |
| testRunner.clearBackForwardList(); |
| testRunner.waitUntilDone(); |
| } |
| |
| shouldBeDefined("history.state"); |
| |
| debug("Push state 1"); |
| history.pushState(1, "", ""); |
| debug("Push state 2"); |
| history.pushState(2, "", ""); |
| shouldEvaluateTo("history.state", 2); |
| |
| var popStateEvent; |
| window.onpopstate = function(e) { |
| popStateEvent = e; |
| shouldEvaluateTo("popStateEvent.state", 1); |
| shouldEvaluateTo("history.state", 1); |
| |
| debug("Push state 3"); |
| history.pushState(3, "", ""); |
| shouldEvaluateTo("popStateEvent.state", 1); |
| shouldEvaluateTo("history.state", 3); |
| |
| var s = document.createElement("script"); |
| s.src = "../../../resources/js-test-post.js"; |
| document.body.appendChild(s); |
| setTimeout(finishJSTest, 0); |
| } |
| |
| debug("Go back"); |
| history.back(); |
| </script> |
| </body> |
| </html> |