|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=509055 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 509055</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"/> |
|
11 </head> |
|
12 <body> |
|
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=509055">Mozilla Bug 509055</a> |
|
14 <p id="display"></p> |
|
15 <div id="status"></div> |
|
16 <div id="content"> |
|
17 </div> |
|
18 <pre id="test"> |
|
19 <script type="application/javascript;version=1.7"> |
|
20 |
|
21 /** Test for Bug 509055 **/ |
|
22 |
|
23 SimpleTest.waitForExplicitFinish(); |
|
24 |
|
25 var gGen; |
|
26 |
|
27 function shortWait() { |
|
28 setTimeout(function() { gGen.next(); }, 0, false); |
|
29 } |
|
30 |
|
31 function onChildHashchange(e) { |
|
32 // gGen might be undefined when we refresh the page, so we have to check here |
|
33 dump("onChildHashchange() called.\n"); |
|
34 if(gGen) |
|
35 gGen.next(); |
|
36 } |
|
37 |
|
38 function onChildLoad(e) { |
|
39 if(gGen) |
|
40 gGen.next(); |
|
41 } |
|
42 |
|
43 function runTest() { |
|
44 var popup = window.open("file_bug509055.html", "popup 0", |
|
45 "height=200,width=200,location=yes," + |
|
46 "menubar=yes,status=yes,toolbar=yes,dependent=yes"); |
|
47 popup.hashchangeCallback = onChildHashchange; |
|
48 popup.onload = onChildLoad; |
|
49 dump('Waiting for initial load.\n'); |
|
50 yield undefined; |
|
51 |
|
52 // Without this wait, the change to location.hash below doesn't create a |
|
53 // SHEntry or enable the back button. |
|
54 shortWait(); |
|
55 dump('Got initial load. Spinning event loop.\n'); |
|
56 yield undefined; |
|
57 |
|
58 popup.location.hash = "#1"; |
|
59 dump('Waiting for hashchange.\n'); |
|
60 yield undefined; |
|
61 |
|
62 popup.history.back(); |
|
63 dump('Waiting for second hashchange.\n'); |
|
64 yield undefined; // wait for hashchange |
|
65 |
|
66 popup.document.title = "Changed"; |
|
67 |
|
68 // Wait for listeners to be notified of the title change. |
|
69 shortWait(); |
|
70 dump('Got second hashchange. Spinning event loop.\n'); |
|
71 yield undefined; |
|
72 |
|
73 var sh = SpecialPowers.wrap(popup) |
|
74 .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) |
|
75 .getInterface(SpecialPowers.Ci.nsIWebNavigation) |
|
76 .sessionHistory; |
|
77 |
|
78 // Get the title of the inner popup's current SHEntry |
|
79 var sheTitle = sh.getEntryAtIndex(sh.index, false).title; |
|
80 is(sheTitle, "Changed", "SHEntry's title should change when we change."); |
|
81 |
|
82 popup.close(); |
|
83 |
|
84 SimpleTest.executeSoon(SimpleTest.finish); |
|
85 dump('Final yield.\n'); |
|
86 yield undefined; |
|
87 } |
|
88 |
|
89 window.addEventListener('load', function() { |
|
90 gGen = runTest(); |
|
91 gGen.next(); |
|
92 }, false); |
|
93 |
|
94 </script> |
|
95 |
|
96 </body> |
|
97 </html> |
|
98 |