1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/docshell/test/chrome/test_bug789773.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet type="text/css" href="chrome://global/skin"?> 1.6 +<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> 1.7 +<!-- 1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=789773 1.9 +--> 1.10 +<window title="Mozilla Bug 789773" 1.11 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.12 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 1.13 + 1.14 + <!-- test results are displayed in the html:body --> 1.15 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.16 + <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=789773" 1.17 + target="_blank">Mozilla Bug 789773</a> 1.18 + </body> 1.19 + 1.20 + <!-- test code goes here --> 1.21 + <script type="application/javascript"> 1.22 + <![CDATA[ 1.23 + const Cc = Components.classes; 1.24 + const Ci = Components.interfaces; 1.25 + const Cr = Components.results; 1.26 + const Cu = Components.utils; 1.27 + 1.28 + /* Test for Bug 789773. 1.29 + * 1.30 + * See comment 50 for the situation we're testing against here. 1.31 + * 1.32 + * Note that the failure mode of this test is to hang, and hang the browser on quit. 1.33 + * This is an unfortunate occurance, but that's why we're testing it. 1.34 + */ 1.35 + SimpleTest.waitForExplicitFinish(); 1.36 + 1.37 + var calledListenerForBrowserXUL = false; 1.38 + var testProgressListener = { 1.39 + START_DOC: Ci.nsIWebProgressListener.STATE_START | Ci.nsIWebProgressListener.STATE_IS_DOCUMENT, 1.40 + onStateChange: function(wp, req, stateFlags, status) { 1.41 + if (/browser.xul/.test(req.name)) { 1.42 + wp.DOMWindow; // Force the lazy creation of a DOM window. 1.43 + calledListenerForBrowserXUL = true; 1.44 + } 1.45 + if (/mozilla.xhtml/.test(req.name) && (stateFlags & Ci.nsIWebProgressListener.STATE_STOP)) 1.46 + finishTest(); 1.47 + }, 1.48 + QueryInterface: function(iid) { 1.49 + if (iid.equals(Ci.nsISupportsWeakReference) || 1.50 + iid.equals(Ci.nsIWebProgressListener)) 1.51 + return this; 1.52 + throw Cr.NS_ERROR_NO_INTERFACE; 1.53 + } 1.54 + } 1.55 + 1.56 + // Add our progress listener 1.57 + var webProgress = Cc['@mozilla.org/docloaderservice;1'].getService(Ci.nsIWebProgress); 1.58 + webProgress.addProgressListener(testProgressListener, Ci.nsIWebProgress.NOTIFY_STATE_REQUEST); 1.59 + 1.60 + // Open the window. 1.61 + var popup = window.open("about:mozilla", "_blank", "width=640,height=400"); 1.62 + 1.63 + // Wait for the window to load. 1.64 + function finishTest() { 1.65 + webProgress.removeProgressListener(testProgressListener); 1.66 + ok(true, "Loaded the popup window without spinning forever in the event loop!"); 1.67 + ok(calledListenerForBrowserXUL, "Should have called the progress listener for browser.xul"); 1.68 + popup.close(); 1.69 + SimpleTest.finish(); 1.70 + } 1.71 + 1.72 + ]]> 1.73 + </script> 1.74 +</window>