4 https://bugzilla.mozilla.org/show_bug.cgi?id=640387
7 <title>Test for Bug
640387</title>
8 <script type=
"application/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <script type=
"application/javascript" src=
"/tests/SimpleTest/EventUtils.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=640387">Mozilla Bug
640387</a>
15 <script type='application/javascript;version=
1.7'
>
16 SimpleTest.waitForExplicitFinish();
19 /* Spin the event loop so we get out of the onload handler. */
20 SimpleTest.executeSoon(function() { gGen.next() });
23 popup.history.pushState('', '', '#hash1');
24 popup.history.pushState('', '', '#hash2');
26 // Now the history looks like:
27 // file_bug640387.html
28 // file_bug640387.html#hash1
29 // file_bug640387.html#hash2 <-- current
31 // Going back should trigger a hashchange, which will wake us up from the
35 ok(true, 'Got first hashchange.');
37 // Going back should wake us up again.
40 ok(true, 'Got second hashchange.');
42 // Now the history looks like:
43 // file_bug640387.html <-- current
44 // file_bug640387.html#hash1
45 // file_bug640387.html#hash2
47 // Going forward should trigger a hashchange.
48 popup.history.forward();
50 ok(true, 'Got third hashchange.');
52 // Now modify the history so it looks like:
53 // file_bug640387.html
54 // file_bug640387.html#hash1
55 // file_bug640387.html#hash1 <-- current
56 popup.history.pushState('', '', '#hash1');
58 // Now when we go back, we should not get a hashchange. Instead, wait for a
59 // popstate. We need to asynchronously go back because popstate is fired
61 gHashchangeExpected = false;
62 gCallbackOnPopstate = true;
63 SimpleTest.executeSoon(function() { popup.history.back() });
65 ok(true, 'Got popstate.');
66 gCallbackOnPopstate = false;
68 // Spin the event loop so hashchange has a chance to fire, if it's going to.
69 SimpleTest.executeSoon(function() { gGen.next() });
78 function childLoad() {
83 gHashchangeExpected = true;
84 function childHashchange() {
85 if (gHashchangeExpected) {
89 ok(false,
"Got hashchange when we weren't expecting one.");
93 gCallbackOnPopstate = false;
94 function childPopstate() {
95 if (gCallbackOnPopstate) {
100 /* We need to run this test in a popup, because navigating an iframe
101 * back/forwards tends to cause intermittent orange. */
102 popup = window.open('file_bug640387.html');
104 /* Control now flows up to childLoad(), called once the popup loads. */