tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug789773.xhtml (2613B)


      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 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  /* Test for Bug 789773.
     21   *
     22   * See comment 50 for the situation we're testing against here.
     23   *
     24   * Note that the failure mode of this test is to hang, and hang the browser on quit.
     25   * This is an unfortunate occurance, but that's why we're testing it.
     26   */
     27  SimpleTest.waitForExplicitFinish();
     28 
     29  const {AppConstants} = ChromeUtils.importESModule(
     30    "resource://gre/modules/AppConstants.sys.mjs"
     31  );
     32 
     33  var calledListenerForBrowserChromeURL = false;
     34  var testProgressListener = {
     35    START_DOC: Ci.nsIWebProgressListener.STATE_START | Ci.nsIWebProgressListener.STATE_IS_DOCUMENT,
     36    onStateChange(wp, req, stateFlags) {
     37      let browserChromeFileName = AppConstants.BROWSER_CHROME_URL.split("/").reverse()[0];
     38      if (req.name.includes(browserChromeFileName)) {
     39        wp.DOMWindow; // Force the lazy creation of a DOM window.
     40        calledListenerForBrowserChromeURL = true;
     41      }
     42      if (req.name.includes("mozilla.html") && (stateFlags & Ci.nsIWebProgressListener.STATE_STOP))
     43        finishTest();
     44    },
     45    QueryInterface: ChromeUtils.generateQI([
     46      "nsIWebProgressListener",
     47      "nsISupportsWeakReference",
     48    ]),
     49  }
     50 
     51   // Add our progress listener
     52   var webProgress = Cc['@mozilla.org/docloaderservice;1'].getService(Ci.nsIWebProgress);
     53   webProgress.addProgressListener(testProgressListener, Ci.nsIWebProgress.NOTIFY_STATE_REQUEST);
     54 
     55   // Open the window.
     56   var popup = window.open("about:mozilla", "_blank", "width=640,height=400");
     57 
     58   // Wait for the window to load.
     59   function finishTest() {
     60     webProgress.removeProgressListener(testProgressListener);
     61     ok(true, "Loaded the popup window without spinning forever in the event loop!");
     62     ok(calledListenerForBrowserChromeURL, "Should have called the progress listener for browser.xhtml");
     63     popup.close();
     64     SimpleTest.finish();
     65   }
     66 
     67  ]]>
     68  </script>
     69 </window>