summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/loader/hashchange-event-async.html
blob: f4eeb8e2afcab2ec87486c448fe16e904c9b0474 (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
45
46
47
48
49
50
51
52
53
54
55
<html>
<body>
    <div>
    This test checks to make sure the hashchange event is fired __ansynchronously__ when the value of location.hash changes.<br/>
    It assumes there is a hashchange event for each location.hash change.<br/>
    <br/>
    </div>
    <div id="msg"></div>
</body>
<script language="javascript">
<!--

var hashChanging = false;
var failed = false;
var msgs = [];

var lc = window.testRunner;
if (lc) {
    lc.dumpAsText();
    lc.waitUntilDone();
}

function updateHash (hash) {
    msgs.push('updateHash("' + hash + '")');
    location.href = hash;
};

function loadHandler () {
    hashChanging = true;
    updateHash('#foo');
    updateHash('#bar');
    hashChanging = false;
};

var cnt = 0;
function hashChangeHandler () {
    msgs.push('hashChangeHandler()');
    if (hashChanging) {
        failed = true;
    }
    if (++cnt == 2) {
        msgs.push('', failed ? "FAILURE" : "SUCCESS");
        document.getElementById("msg").innerHTML = msgs.join('<br/>');
        if (lc) {
            lc.notifyDone();
        }
    }
};

window.addEventListener('load', loadHandler, false);
window.addEventListener('hashchange', hashChangeHandler, false);

//-->
</script>
</html>