layout/base/tests/chrome/printpreview_bug482976_helper.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.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
michael@0 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
michael@0 4 type="text/css"?>
michael@0 5 <!--
michael@0 6 https://bugzilla.mozilla.org/show_bug.cgi?id=482976
michael@0 7 -->
michael@0 8 <window title="Mozilla Bug 482976" onload="run1()"
michael@0 9 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 10 <iframe src="about:blank" type="content"></iframe>
michael@0 11 <iframe src="about:blank" type="content"></iframe>
michael@0 12 <script type="application/javascript">
michael@0 13 <![CDATA[
michael@0 14 var is = window.opener.wrappedJSObject.is;
michael@0 15 var ok = window.opener.wrappedJSObject.ok;
michael@0 16 var todo = window.opener.wrappedJSObject.todo;
michael@0 17 var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
michael@0 18 var gWbp;
michael@0 19 function printpreview() {
michael@0 20 gWbp = window.frames[1].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
michael@0 21 .getInterface(Components.interfaces.nsIWebBrowserPrint);
michael@0 22 var listener = {
michael@0 23 onLocationChange: function(webProgress, request, location, flags) { },
michael@0 24 onProgressChange: function(webProgress, request, curSelfProgress,
michael@0 25 maxSelfProgress, curTotalProgress,
michael@0 26 maxTotalProgress) { },
michael@0 27 onSecurityChange: function(webProgress, request, state) { },
michael@0 28 onStateChange: function(webProgress, request, stateFlags, status) { },
michael@0 29 onStatusChange: function(webProgress, request, status, message) { },
michael@0 30 QueryInterface: function(iid) {
michael@0 31 if (iid.equals(Components.interfaces.nsIWebProgessListener) ||
michael@0 32 iid.equals(Components.interfaces.nsISupportsWeakReference))
michael@0 33 return this;
michael@0 34 throw Components.results.NS_NOINTERFACE;
michael@0 35 }
michael@0 36 }
michael@0 37 var prefs = Components.classes["@mozilla.org/preferences-service;1"]
michael@0 38 .getService(Components.interfaces.nsIPrefBranch);
michael@0 39 prefs.setBoolPref('print.show_print_progress', false);
michael@0 40 //XXX I would have thought this would work, instead I'm forced to use prefs service
michael@0 41 gWbp.globalPrintSettings.showPrintProgress = false;
michael@0 42 gWbp.printPreview(gWbp.globalPrintSettings, window.frames[0], listener);
michael@0 43 prefs.clearUserPref('print.show_print_progress');
michael@0 44 }
michael@0 45
michael@0 46 function exitprintpreview() {
michael@0 47 window.frames[1].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
michael@0 48 .getInterface(Components.interfaces.nsIWebBrowserPrint).exitPrintPreview();
michael@0 49 }
michael@0 50
michael@0 51 function finish() {
michael@0 52 SimpleTest.finish();
michael@0 53 window.close();
michael@0 54 }
michael@0 55
michael@0 56 function run1()
michael@0 57 {
michael@0 58 /** Test for Bug 482976 **/
michael@0 59 var printService = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
michael@0 60 .getService(Components.interfaces.nsIPrintSettingsService);
michael@0 61
michael@0 62 try {
michael@0 63 Components.classes["@mozilla.org/gfx/printerenumerator;1"]
michael@0 64 .getService(Components.interfaces.nsIPrinterEnumerator);
michael@0 65 } catch(e) {
michael@0 66 todo(false, "Test skipped on MacOSX, as the print preview code doesn't work there");
michael@0 67 finish();
michael@0 68 return;
michael@0 69 }
michael@0 70
michael@0 71 if (printService.defaultPrinterName != '') {
michael@0 72 printpreview();
michael@0 73 ok(gWbp.doingPrintPreview, "Should be doing print preview");
michael@0 74 exitprintpreview();
michael@0 75 ok(!gWbp.doingPrintPreview, "Should not be doing print preview anymore");
michael@0 76 } else {
michael@0 77 todo(false, "No printer seems installed on this machine, that is necessary for this test");
michael@0 78 }
michael@0 79 finish();
michael@0 80 }
michael@0 81 ]]></script>
michael@0 82 </window>

mercurial