docshell/test/chrome/test_bug565388.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/docshell/test/chrome/test_bug565388.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,81 @@
     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="/tests/SimpleTest/test.css"?>
     1.7 +<!--
     1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=565388
     1.9 +-->
    1.10 +<window title="Mozilla Bug 565388"
    1.11 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.12 +
    1.13 +  <script type="application/javascript"
    1.14 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.15 +
    1.16 +  <!-- test code goes here -->
    1.17 +  <script type="application/javascript">
    1.18 +  <![CDATA[
    1.19 +
    1.20 +  /** Test for Bug 565388 **/
    1.21 +  SimpleTest.waitForExplicitFinish();
    1.22 +
    1.23 +  var Ci = Components.interfaces;
    1.24 +  var Cc = Components.classes;
    1.25 +
    1.26 +  var progressListener = {
    1.27 +    add: function(docShell, callback) {
    1.28 +      this.callback = callback;
    1.29 +      this.docShell = docShell;
    1.30 +      docShell.
    1.31 +            QueryInterface(Ci.nsIInterfaceRequestor).
    1.32 +            getInterface(Ci.nsIWebProgress).
    1.33 +            addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_WINDOW);
    1.34 +    },
    1.35 +
    1.36 +    finish: function() {
    1.37 +      this.docShell.
    1.38 +            QueryInterface(Ci.nsIInterfaceRequestor).
    1.39 +            getInterface(Ci.nsIWebProgress).
    1.40 +            removeProgressListener(this);
    1.41 +      this.callback();
    1.42 +    },
    1.43 +
    1.44 +    onStateChange: function (webProgress, req, flags, status) {
    1.45 +      if (req.name.startsWith("data:application/vnd.mozilla.xul")) {
    1.46 +        if (flags & Ci.nsIWebProgressListener.STATE_STOP)
    1.47 +          this.finish();
    1.48 +      }
    1.49 +    },
    1.50 +
    1.51 +    QueryInterface: function(iid) {
    1.52 +      if (iid.equals(Components.interfaces.nsIWebProgressListener) ||
    1.53 +          iid.equals(Components.interfaces.nsISupportsWeakReference))
    1.54 +        return this;
    1.55 +      throw Components.results.NS_ERROR_NO_INTERFACE;
    1.56 +    }
    1.57 +  }
    1.58 +
    1.59 +  var systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].
    1.60 +  createInstance(Ci.nsIPrincipal);
    1.61 +  var docShell = Cc["@mozilla.org/appshell/appShellService;1"].
    1.62 +  getService(Ci.nsIAppShellService).
    1.63 +  createWindowlessBrowser(true).
    1.64 +  QueryInterface(Ci.nsIInterfaceRequestor).
    1.65 +  getInterface(Ci.nsIDocShell);
    1.66 +  docShell.createAboutBlankContentViewer(systemPrincipal);
    1.67 +  var win = docShell.contentViewer.DOMDocument.defaultView;
    1.68 +
    1.69 +  progressListener.add(docShell, function(){
    1.70 +    is(win.document.documentURI, "data:application/vnd.mozilla.xul+xml;charset=utf-8,<window/>");
    1.71 +    SimpleTest.finish();
    1.72 +  });
    1.73 +
    1.74 +  win.location = "data:application/vnd.mozilla.xul+xml;charset=utf-8,<window/>";
    1.75 +
    1.76 +  ]]>
    1.77 +  </script>
    1.78 +
    1.79 +  <!-- test results are displayed in the html:body -->
    1.80 +  <body xmlns="http://www.w3.org/1999/xhtml">
    1.81 +  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=565388"
    1.82 +     target="_blank">Mozilla Bug 565388</a>
    1.83 +  </body>
    1.84 +</window>

mercurial