blob: 8ee1d99b8def562d4f78ed4ac0cc395914e0912a [file] [log] [blame]
beidson@apple.com08c61752009-12-03 19:04:40 +00001<html>
2<head>
3<script>
4
rniwa@webkit.org03b9c6d2012-07-16 01:41:53 +00005if (window.testRunner) {
6 testRunner.clearBackForwardList();
7 testRunner.dumpAsText();
8 testRunner.waitUntilDone();
beidson@apple.com08c61752009-12-03 19:04:40 +00009}
10
11function log(txt)
12{
13 document.getElementById("logger").innerText += txt + "\n";
14}
15
16function runTest()
17{
18 history.pushState("StateStringData", "New title");
19 log("History length is " + history.length);
20 history.back();
21}
22
23function 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.org03b9c6d2012-07-16 01:41:53 +000029 } else if (window.testRunner)
30 testRunner.notifyDone();
beidson@apple.com08c61752009-12-03 19:04:40 +000031}
32
33</script>
commit-queue@webkit.org78da3b82015-10-02 15:13:05 +000034<body onload="runTest();">
beidson@apple.com08c61752009-12-03 19:04:40 +000035<pre>
36This 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>
46document.body.onpopstate = statePopped;
47</script>
48</html>