Bug 594821 - Trigger a sync paint on intial window show. r=roc, a=final.
[mozilla-central.git] / docshell / test / test_bug509055.html
blob76cd27ab27ca386fea43ad3d7819c45f059b72aa
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="/MochiKit/packed.js"></script>
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
12 </head>
13 <body>
14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=509055">Mozilla Bug 509055</a>
15 <p id="display"></p>
16 <div id="status"></div>
17 <div id="content">
18 </div>
19 <pre id="test">
20 <script type="application/javascript;version=1.7">
22 /** Test for Bug 509055 **/
24 SimpleTest.waitForExplicitFinish();
26 var gGen;
28 function shortWait() {
29 setTimeout(function() { gGen.next(); }, 0, false);
32 function onChildLoad(e) {
33 if(gGen)
34 gGen.next();
37 function runTest() {
38 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
40 var popup = window.open("file_bug509055.html", "popup 0",
41 "height=200,width=200,location=yes," +
42 "menubar=yes,status=yes,toolbar=yes,dependent=yes");
43 popup.onload = onChildLoad;
44 yield; // wait for load
46 // Not sure why this wait is necessary, but without it, the change to
47 // location.hash below doesn't create a SHEntry or enable the back button.
48 shortWait();
49 yield;
51 // Both setting location.hash and calling history.back() happen
52 // synchronously, so there's no need to yield here.
53 popup.location.hash = "#1";
54 popup.history.back();
56 popup.document.title = "Changed";
58 // Wait for listeners to be notified of the title change.
59 shortWait();
60 yield;
62 var sh = popup.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
63 .getInterface(Components.interfaces.nsIWebNavigation)
64 .sessionHistory;
66 // Get the title of the inner popup's current SHEntry
67 var sheTitle = sh.getEntryAtIndex(sh.index, false).title;
68 is(sheTitle, "Changed", "SHEntry's title should change when we change.");
70 popup.close();
72 SimpleTest.finish();
73 yield;
76 window.addEventListener('load', function() {
77 gGen = runTest();
78 gGen.next();
79 }, false);
81 </script>
83 </body>
84 </html>