summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/loader/stateobjects/state-attribute-popstate-event.html
blob: eb881055e4a7594102ed793e78c55521b8157628 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<html>
<head>
    <script src="../../../resources/js-test.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);

        setTimeout(finishJSTest, 0);
    }

    debug("Go back");
    window.onload = function() {
        history.back();
    };
</script>
</body>
</html>