docshell/test/chrome/test_bug565388.xul

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial