Modified test for bug 396024, this should not cause test failures when no printer is installed
authormartijn.martijn@gmail.com
Wed, 05 Dec 2007 14:07:12 -0800
changeset 8777 8d1b0b8211cd15e924c5b580b319254cdf1a1a55
parent 8776 3d0117dce6da499e518e619c2336759a72d5446c
child 8778 afa937f28c935982623d47ea3bbd8f2cdf66e026
push idunknown
push userunknown
push dateunknown
bugs396024
milestone1.9b2pre
Modified test for bug 396024, this should not cause test failures when no printer is installed
layout/base/tests/Makefile.in
layout/base/tests/test_bug396024.html
--- a/layout/base/tests/Makefile.in
+++ b/layout/base/tests/Makefile.in
@@ -78,16 +78,17 @@ include $(topsrcdir)/config/rules.mk
 
 DEFINES += -D_IMPL_NS_LAYOUT
 
 ifdef MOZ_MOCHITEST
 
 _TEST_FILES =	\
 		test_bug66619.html \
 		test_bug388019.html \
+		test_bug396024.html \
 		test_bug399284.html \
 		test_bug399951.html \
 		test_bug404209.xhtml \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
 
--- a/layout/base/tests/test_bug396024.html
+++ b/layout/base/tests/test_bug396024.html
@@ -33,40 +33,45 @@ function printpreview() {
             return this;
       throw Components.results.NS_NOINTERFACE;
     }
   }
   var prefs = Components.classes["@mozilla.org/preferences-service;1"]
                             .getService(Components.interfaces.nsIPrefBranch);
   prefs.setBoolPref('print.show_print_progress', false);
   //XXX I would have thought this would work, instead I'm forced to use prefs service
-  // I'm disabling showPrintProgress dialog, because it stays as a zombie dialog, see bug 405588
   gWbp.globalPrintSettings.showPrintProgress = false; 
   gWbp.printPreview(gWbp.globalPrintSettings, null, listener);
   prefs.clearUserPref('print.show_print_progress');
 }
 
 function exitprintpreview() {
   netscape.security.PrivilegeManager.enablePrivilege('UniversalPreferencesRead UniversalPreferencesWrite UniversalXPConnect');
   window.frames[0].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
    .getInterface(Components.interfaces.nsIWebBrowserPrint).exitPrintPreview(); 
 }
 
 function run()
 {
 /** Test for Bug 396024 **/
-  window.frames[0].frameElement.setAttribute('onload', 'run2()');
   netscape.security.PrivilegeManager.enablePrivilege('UniversalPreferencesRead UniversalPreferencesWrite UniversalXPConnect');
-  SimpleTest.waitForExplicitFinish();
-  printpreview();
-  ok(gWbp.doingPrintPreview, "Should be doing print preview");
-  exitprintpreview();
-  ok(!gWbp.doingPrintPreview, "Should not be doing print preview anymore1");
-  printpreview();
-  window.frames[0].location.reload();
+  var printService = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
+                               .getService(Components.interfaces.nsIPrintSettingsService);
+  if (printService.defaultPrinterName != '') {
+    window.frames[0].frameElement.setAttribute('onload', 'run2()');
+    SimpleTest.waitForExplicitFinish();
+    printpreview();
+    ok(gWbp.doingPrintPreview, "Should be doing print preview");
+    exitprintpreview();
+    ok(!gWbp.doingPrintPreview, "Should not be doing print preview anymore1");
+    printpreview();
+    window.frames[0].location.reload();
+  } else {
+    todo(false, "No printer seems installed on this machine, that is necessary for this test")
+  }
 }
 
 function run2() {
   netscape.security.PrivilegeManager.enablePrivilege('UniversalPreferencesRead UniversalPreferencesWrite UniversalXPConnect');
   gWbp = window.frames[0].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
              .getInterface(Components.interfaces.nsIWebBrowserPrint);
   ok(!gWbp.doingPrintPreview, "Should not be doing print preview anymore2");
   window.frames[0].frameElement.removeAttribute('onload');
@@ -83,9 +88,8 @@ function run2() {
   exitprintpreview();
   SimpleTest.finish(); //should not have crashed after all of this
 }
 </script>
 <iframe onload="run()" src="data:text/html;charset=utf-8,"></iframe>
 </pre>
 </body>
 </html>
-