blob: 53b7510e3fd317e6391599252d2abd1229b5240c (
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
|
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<div id="description"></div>
<pre id="console"></pre>
<script>
description('Tests that hashchange events have the expected newURL and oldURL properties.');
function hashOf(url)
{
var hashIndex = url.lastIndexOf('#');
return hashIndex != -1 ? url.substring(hashIndex) : '[none]';
}
var goingForward = true;
onload = function()
{
setTimeout(function() {location.href = '#state1';}, 0);
};
onhashchange = function(event)
{
debug('hashchange fired with oldURL hash "' + hashOf(event.oldURL) + '" and newURL hash "' + hashOf(event.newURL) + '"');
switch (hashOf(event.newURL)) {
case '#state1':
if (goingForward)
location.href = '#state2';
else
history.back();
break;
case '#state2':
if (goingForward) {
goingForward = false;
history.back();
} else {
testFailed('should always be going forward at #state2');
}
break;
case '[none]':
finishJSTest();
break;
}
};
var jsTestIsAsync = true;
</script>
</html>
|