tor-browser

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

test_bug565388.xhtml (2396B)


      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=565388
      6 -->
      7 <window title="Mozilla Bug 565388"
      8        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
      9 
     10  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     11 
     12  <!-- test code goes here -->
     13  <script type="application/javascript">
     14  <![CDATA[
     15 
     16  /** Test for Bug 565388 */
     17  SimpleTest.waitForExplicitFinish();
     18 
     19 function test() {
     20  var progressListener = {
     21    add(docShell, callback) {
     22      this.callback = callback;
     23      this.docShell = docShell;
     24      docShell.
     25            QueryInterface(Ci.nsIInterfaceRequestor).
     26            getInterface(Ci.nsIWebProgress).
     27            addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_WINDOW);
     28    },
     29 
     30    finish() {
     31      this.docShell.
     32            QueryInterface(Ci.nsIInterfaceRequestor).
     33            getInterface(Ci.nsIWebProgress).
     34            removeProgressListener(this);
     35      this.callback();
     36    },
     37 
     38    onStateChange (webProgress, req, flags) {
     39      if (req.name.startsWith("data:application/vnd.mozilla.xul")) {
     40        if (flags & Ci.nsIWebProgressListener.STATE_STOP)
     41          this.finish();
     42      }
     43    },
     44 
     45    QueryInterface: ChromeUtils.generateQI([
     46      "nsIWebProgressListener",
     47      "nsISupportsWeakReference",
     48    ]),
     49  }
     50 
     51  var systemPrincipal = Cc["@mozilla.org/systemprincipal;1"]
     52                          .getService(Ci.nsIPrincipal);
     53  var webNav = SpecialPowers.Services.appShell.createWindowlessBrowser(true);
     54  var docShell = webNav.docShell;
     55  docShell.createAboutBlankDocumentViewer(systemPrincipal, systemPrincipal);
     56  var win = docShell.docViewer.DOMDocument.defaultView;
     57 
     58  progressListener.add(docShell, function(){
     59    is(win.document.documentURI, "data:application/xhtml+xml;charset=utf-8,<window/>");
     60    webNav.close();
     61    SimpleTest.finish();
     62  });
     63 
     64  win.location = "data:application/xhtml+xml;charset=utf-8,<window/>";
     65 }
     66 
     67 addLoadEvent(function onLoad() {
     68  test();
     69 });
     70 
     71  ]]>
     72  </script>
     73 
     74  <!-- test results are displayed in the html:body -->
     75  <body xmlns="http://www.w3.org/1999/xhtml">
     76  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=565388"
     77     target="_blank">Mozilla Bug 565388</a>
     78  </body>
     79 </window>