Bumping manifests a=b2g-bump
[gecko.git] / docshell / test / test_bug509055.html
blobbe163cafaa4b2176f8fcaf91cc63e1f660f716e5
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">
21 /** Test for Bug 509055 **/
23 SimpleTest.waitForExplicitFinish();
25 var gGen;
27 function shortWait() {
28 setTimeout(function() { gGen.next(); }, 0, false);
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();
38 function onChildLoad(e) {
39 if(gGen)
40 gGen.next();
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;
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;
58 popup.location.hash = "#1";
59 dump('Waiting for hashchange.\n');
60 yield undefined;
62 popup.history.back();
63 dump('Waiting for second hashchange.\n');
64 yield undefined; // wait for hashchange
66 popup.document.title = "Changed";
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;
73 var sh = SpecialPowers.wrap(popup)
74 .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
75 .getInterface(SpecialPowers.Ci.nsIWebNavigation)
76 .sessionHistory;
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.");
82 popup.close();
84 SimpleTest.executeSoon(SimpleTest.finish);
85 dump('Final yield.\n');
86 yield undefined;
89 window.addEventListener('load', function() {
90 gGen = runTest();
91 gGen.next();
92 }, false);
94 </script>
96 </body>
97 </html>