docshell/test/chrome/test_bug789773.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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"/>
    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>
    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;
    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();
    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   }
    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);
    57    // Open the window.
    58    var popup = window.open("about:mozilla", "_blank", "width=640,height=400");
    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    }
    69   ]]>
    70   </script>
    71 </window>

mercurial