docshell/test/chrome/test_bug789773.xul

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:f801f7316b9f
1 <?xml version="1.0"?>
2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
4 <!--
5 https://bugzilla.mozilla.org/show_bug.cgi?id=789773
6 -->
7 <window title="Mozilla Bug 789773"
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
10
11 <!-- test results are displayed in the html:body -->
12 <body xmlns="http://www.w3.org/1999/xhtml">
13 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=789773"
14 target="_blank">Mozilla Bug 789773</a>
15 </body>
16
17 <!-- test code goes here -->
18 <script type="application/javascript">
19 <![CDATA[
20 const Cc = Components.classes;
21 const Ci = Components.interfaces;
22 const Cr = Components.results;
23 const Cu = Components.utils;
24
25 /* Test for Bug 789773.
26 *
27 * See comment 50 for the situation we're testing against here.
28 *
29 * Note that the failure mode of this test is to hang, and hang the browser on quit.
30 * This is an unfortunate occurance, but that's why we're testing it.
31 */
32 SimpleTest.waitForExplicitFinish();
33
34 var calledListenerForBrowserXUL = false;
35 var testProgressListener = {
36 START_DOC: Ci.nsIWebProgressListener.STATE_START | Ci.nsIWebProgressListener.STATE_IS_DOCUMENT,
37 onStateChange: function(wp, req, stateFlags, status) {
38 if (/browser.xul/.test(req.name)) {
39 wp.DOMWindow; // Force the lazy creation of a DOM window.
40 calledListenerForBrowserXUL = true;
41 }
42 if (/mozilla.xhtml/.test(req.name) && (stateFlags & Ci.nsIWebProgressListener.STATE_STOP))
43 finishTest();
44 },
45 QueryInterface: function(iid) {
46 if (iid.equals(Ci.nsISupportsWeakReference) ||
47 iid.equals(Ci.nsIWebProgressListener))
48 return this;
49 throw Cr.NS_ERROR_NO_INTERFACE;
50 }
51 }
52
53 // Add our progress listener
54 var webProgress = Cc['@mozilla.org/docloaderservice;1'].getService(Ci.nsIWebProgress);
55 webProgress.addProgressListener(testProgressListener, Ci.nsIWebProgress.NOTIFY_STATE_REQUEST);
56
57 // Open the window.
58 var popup = window.open("about:mozilla", "_blank", "width=640,height=400");
59
60 // Wait for the window to load.
61 function finishTest() {
62 webProgress.removeProgressListener(testProgressListener);
63 ok(true, "Loaded the popup window without spinning forever in the event loop!");
64 ok(calledListenerForBrowserXUL, "Should have called the progress listener for browser.xul");
65 popup.close();
66 SimpleTest.finish();
67 }
68
69 ]]>
70 </script>
71 </window>

mercurial