docshell/test/chrome/test_bug565388.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="/tests/SimpleTest/test.css"?>
     4 <!--
     5 https://bugzilla.mozilla.org/show_bug.cgi?id=565388
     6 -->
     7 <window title="Mozilla Bug 565388"
     8         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    10   <script type="application/javascript"
    11           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    13   <!-- test code goes here -->
    14   <script type="application/javascript">
    15   <![CDATA[
    17   /** Test for Bug 565388 **/
    18   SimpleTest.waitForExplicitFinish();
    20   var Ci = Components.interfaces;
    21   var Cc = Components.classes;
    23   var progressListener = {
    24     add: function(docShell, callback) {
    25       this.callback = callback;
    26       this.docShell = docShell;
    27       docShell.
    28             QueryInterface(Ci.nsIInterfaceRequestor).
    29             getInterface(Ci.nsIWebProgress).
    30             addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_WINDOW);
    31     },
    33     finish: function() {
    34       this.docShell.
    35             QueryInterface(Ci.nsIInterfaceRequestor).
    36             getInterface(Ci.nsIWebProgress).
    37             removeProgressListener(this);
    38       this.callback();
    39     },
    41     onStateChange: function (webProgress, req, flags, status) {
    42       if (req.name.startsWith("data:application/vnd.mozilla.xul")) {
    43         if (flags & Ci.nsIWebProgressListener.STATE_STOP)
    44           this.finish();
    45       }
    46     },
    48     QueryInterface: function(iid) {
    49       if (iid.equals(Components.interfaces.nsIWebProgressListener) ||
    50           iid.equals(Components.interfaces.nsISupportsWeakReference))
    51         return this;
    52       throw Components.results.NS_ERROR_NO_INTERFACE;
    53     }
    54   }
    56   var systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].
    57   createInstance(Ci.nsIPrincipal);
    58   var docShell = Cc["@mozilla.org/appshell/appShellService;1"].
    59   getService(Ci.nsIAppShellService).
    60   createWindowlessBrowser(true).
    61   QueryInterface(Ci.nsIInterfaceRequestor).
    62   getInterface(Ci.nsIDocShell);
    63   docShell.createAboutBlankContentViewer(systemPrincipal);
    64   var win = docShell.contentViewer.DOMDocument.defaultView;
    66   progressListener.add(docShell, function(){
    67     is(win.document.documentURI, "data:application/vnd.mozilla.xul+xml;charset=utf-8,<window/>");
    68     SimpleTest.finish();
    69   });
    71   win.location = "data:application/vnd.mozilla.xul+xml;charset=utf-8,<window/>";
    73   ]]>
    74   </script>
    76   <!-- test results are displayed in the html:body -->
    77   <body xmlns="http://www.w3.org/1999/xhtml">
    78   <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=565388"
    79      target="_blank">Mozilla Bug 565388</a>
    80   </body>
    81 </window>

mercurial