bug 483781 - make tests that require the toolkit dlmgr UI not fail with new SeaMonkey dlmgr UI work, r=sdwilsh
authorRobert Kaiser <kairo@kairo.at>
Fri, 08 May 2009 13:46:36 +0200
changeset 28126 ab664753cc722d7fef0c741899246e801f8531a1
parent 28125 c4fcaec2898a3e95aad0692845f61fffb80ab964
child 28127 515054a2dc431c86f588eb676aec1597be81805b
push id6901
push userkairo@kairo.at
push dateFri, 08 May 2009 11:47:31 +0000
treeherdermozilla-central@ab664753cc72 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssdwilsh
bugs483781
milestone1.9.2a1pre
bug 483781 - make tests that require the toolkit dlmgr UI not fail with new SeaMonkey dlmgr UI work, r=sdwilsh
toolkit/mozapps/downloads/tests/chrome/test_basic_functionality.xul
toolkit/mozapps/downloads/tests/chrome/test_bug_412360.xul
toolkit/mozapps/downloads/tests/chrome/test_bug_429247.xul
toolkit/mozapps/downloads/tests/chrome/test_cleanup_search.xul
toolkit/mozapps/downloads/tests/chrome/test_clear_button_disabled.xul
toolkit/mozapps/downloads/tests/chrome/test_close_download_manager.xul
toolkit/mozapps/downloads/tests/chrome/test_delete_key_removes.xul
toolkit/mozapps/downloads/tests/chrome/test_esc_key_closes_clears.xul
toolkit/mozapps/downloads/tests/chrome/test_multi_select.xul
toolkit/mozapps/downloads/tests/chrome/test_multiword_search.xul
toolkit/mozapps/downloads/tests/chrome/test_pause_button_state.xul
toolkit/mozapps/downloads/tests/chrome/test_privatebrowsing_title.xul
toolkit/mozapps/downloads/tests/chrome/test_removeDownload_updates_ui.xul
toolkit/mozapps/downloads/tests/chrome/test_search_clearlist.xul
toolkit/mozapps/downloads/tests/chrome/test_search_keys.xul
toolkit/mozapps/downloads/tests/chrome/test_select_all.xul
toolkit/mozapps/downloads/tests/chrome/test_space_key_pauses_resumes.xul
toolkit/mozapps/downloads/tests/chrome/test_ui_stays_open_on_alert_clickback.xul
toolkit/mozapps/downloads/tests/chrome/utils.js
--- a/toolkit/mozapps/downloads/tests/chrome/test_basic_functionality.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_basic_functionality.xul
@@ -47,24 +47,22 @@
 <window title="Download Manager Test"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
 var dmFile = Cc["@mozilla.org/file/directory_service;1"].
              getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
 dmFile.append("dm-ui-test.file");
 dmFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
 var gTestPath = ios.newFileURI(dmFile).spec;
 
 // Downloads are sorted by endTime, so make sure the end times are distinct
@@ -178,16 +176,22 @@ function test_properDownloadData(aWin)
 
 var testFuncs = [
     test_numberOfRichlistitems
   , test_properDownloadData
 ];
 
 function test()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   var dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
   var db = dm.DBConnection;
 
   // First, we populate the database with some fake data
   db.executeSimpleSQL("DELETE FROM moz_downloads");
   var rawStmt = db.createStatement(
     "INSERT INTO moz_downloads (name, source, target, startTime, endTime, " +
@@ -210,17 +214,17 @@ function test()
            getService(Ci.nsIWindowMediator);
   var win = wm.getMostRecentWindow("Download:Manager");
   if (win)
     win.close();
 
   let os = Cc["@mozilla.org/observer-service;1"].
            getService(Ci.nsIObserverService);
   const DLMGR_UI_DONE = "download-manager-ui-done";
- 
+
   let testObs = {
     observe: function(aSubject, aTopic, aData)
     {
       if (aTopic != DLMGR_UI_DONE)
         return;
 
       let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
 
@@ -234,18 +238,17 @@ function test()
       SimpleTest.finish();
     }
   };
 
   // Register with the observer service
   os.addObserver(testObs, DLMGR_UI_DONE, false);
 
   // Show the Download Manager UI
-  Cc["@mozilla.org/download-manager-ui;1"].
-  getService(Ci.nsIDownloadManagerUI).show();
+  dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/mozapps/downloads/tests/chrome/test_bug_412360.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_bug_412360.xul
@@ -48,62 +48,73 @@
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 let didFail = false;
 var file;
 
+let prefBranch = Cc["@mozilla.org/preferences-service;1"].
+                 getService(Ci.nsIPrefBranch);
+
 let factory = {
   createInstance: function(aOuter, aIid) {
     if (aOuter != null)
       throw Components.results.NS_ERROR_NO_AGGREGATION;
     return promptService.QueryInterface(aIid);
   }
 };
 
 let promptService = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIPromptService]),
   alert: function() {
     ok(didFail, "javascript: uri failed and showed a message");
     file.remove(false);
 
-    // Unregister the factory so we do not leak
-    Components.manager.QueryInterface(Ci.nsIComponentRegistrar).
-    unregisterFactory(
-      Components.ID("{6cc9c9fe-bc0b-432b-a410-253ef8bcc699}"),
-      factory
-    );
-
+    cleanUpFactory();
     SimpleTest.finish();
   }
 };
 
 Components.manager.QueryInterface(Ci.nsIComponentRegistrar).
 registerFactory(Components.ID("{6cc9c9fe-bc0b-432b-a410-253ef8bcc699}"),
   "PromptService", "@mozilla.org/embedcomp/prompt-service;1",
   factory
 );
 
+function cleanUpFactory() {
+    // Unregister the factory so we do not leak
+    Components.manager.QueryInterface(Ci.nsIComponentRegistrar).
+    unregisterFactory(
+      Components.ID("{6cc9c9fe-bc0b-432b-a410-253ef8bcc699}"),
+      factory
+    );
+}
+
 function test()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    cleanUpFactory();
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   let dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
   let db = dm.DBConnection;
 
   // Empty any old downloads
   db.executeSimpleSQL("DELETE FROM moz_downloads");
 
   let stmt = db.createStatement(
@@ -173,18 +184,17 @@ function test()
       os.removeObserver(testObs, DLMGR_UI_DONE);
     }
   };
 
   // Register with the observer service
   os.addObserver(testObs, DLMGR_UI_DONE, false);
 
   // Show the Download Manager UI
-  Cc["@mozilla.org/download-manager-ui;1"].
-  getService(Ci.nsIDownloadManagerUI).show();
+  dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/mozapps/downloads/tests/chrome/test_bug_429247.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_bug_429247.xul
@@ -48,26 +48,30 @@
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 function test()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
   let dmFile = Cc["@mozilla.org/file/directory_service;1"].
                getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
   dmFile.append("dm-ui-test.file");
   dmFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
   let gTestPath = ios.newFileURI(dmFile).spec;
 
   // Data to populate the download manager with
@@ -159,18 +163,17 @@ function test()
       win.close();
       obs.removeObserver(testObs, DLMGR_UI_DONE);
       SimpleTest.finish();
     }
   };
   obs.addObserver(testObs, DLMGR_UI_DONE, false);
 
   // Show the Download Manager UI
-  Cc["@mozilla.org/download-manager-ui;1"].
-  getService(Ci.nsIDownloadManagerUI).show();
+  dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/mozapps/downloads/tests/chrome/test_cleanup_search.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_cleanup_search.xul
@@ -48,26 +48,30 @@
 <window title="Download Manager Test"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 function test()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   let dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
   let db = dm.DBConnection;
 
   // Empty any old downloads
   db.executeSimpleSQL("DELETE FROM moz_downloads");
 
   // Make a file name for the downloads
@@ -160,18 +164,17 @@ function test()
 
           break;
       }
     }
   };
   obs.addObserver(testObs, DLMGR_UI_DONE, false);
 
   // Show the Download Manager UI
-  Cc["@mozilla.org/download-manager-ui;1"].
-  getService(Ci.nsIDownloadManagerUI).show();
+  dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/mozapps/downloads/tests/chrome/test_clear_button_disabled.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_clear_button_disabled.xul
@@ -86,16 +86,22 @@ const ActiveDownloadData = [
     startTime: 1180493839859230,
     endTime: 1180493839859239,
     state: Ci.nsIDownloadManager.DOWNLOAD_DOWNLOADING,
     currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0 }
 ];
 
 function runTest()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   setCleanState();
   populateDM(DoneDownloadData);
 
   let obs = Cc["@mozilla.org/observer-service;1"].
             getService(Ci.nsIObserverService);
   const DLMGR_UI_DONE = "download-manager-ui-done";
 
   let testPhase = 0;
@@ -159,18 +165,16 @@ function runTest()
 
           break;
       }
     }
   };
 
   obs.addObserver(testObs, DLMGR_UI_DONE, false);
 
-  let dmui = Cc["@mozilla.org/download-manager-ui;1"].
-             getService(Ci.nsIDownloadManagerUI);
   dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
--- a/toolkit/mozapps/downloads/tests/chrome/test_close_download_manager.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_close_download_manager.xul
@@ -56,18 +56,17 @@
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
 
   <![CDATA[
 
-const dmui = Cc["@mozilla.org/download-manager-ui;1"].
-             getService(Ci.nsIDownloadManagerUI);
+const dmui = getDMUI();
 
 function testCloseDMWithEscKey(aWin)
 {
   function dmWindowClosedListener() {
     aWin.removeEventListener("unload", dmWindowClosedListener, false);
     ok(!dmui.visible, "DMUI closes with ESC key");
     dmui.show();
   }
@@ -86,16 +85,21 @@ function testCloseDMWithAccelKey(aWin)
   }
   aWin.addEventListener("unload", dmWindowClosedListener, false);
 
   synthesizeKey("w", { accelKey: true }, aWin);
 }
 
 function runTest()
 {
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   const DLMGR_UI_DONE = "download-manager-ui-done";
 
   // Close the DM UI if it is already open
   let dm_win = getDMWindow();
   if (dm_win) dm_win.close();
 
   let testPhase = 0;
   // Specify an observer that will be notified when the dm has been rendered on screen
--- a/toolkit/mozapps/downloads/tests/chrome/test_delete_key_removes.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_delete_key_removes.xul
@@ -48,24 +48,22 @@
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
 var dmFile = Cc["@mozilla.org/file/directory_service;1"].
              getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
 dmFile.append("dm-ui-test.file");
 dmFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
 var gTestPath = ios.newFileURI(dmFile).spec;
 
 // Downloads are sorted by endTime, so make sure the end times are distinct
@@ -112,16 +110,22 @@ const DownloadData = [
     endTime: 1180493839859229,
     state: Ci.nsIDownloadManager.DOWNLOAD_BLOCKED_POLICY,
     currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0 }
 ];
 
 
 function test()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   var dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
   var db = dm.DBConnection;
 
   // First, we populate the database with some fake data
   db.executeSimpleSQL("DELETE FROM moz_downloads");
   var rawStmt = db.createStatement(
     "INSERT INTO moz_downloads (name, source, target, startTime, endTime, " +
@@ -188,18 +192,17 @@ function test()
       SimpleTest.finish();
     }
   };
 
   // Register with the observer service
   os.addObserver(testObs, DLMGR_UI_DONE, false);
 
   // Show the Download Manager UI
-  Cc["@mozilla.org/download-manager-ui;1"].
-  getService(Ci.nsIDownloadManagerUI).show();
+  dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/mozapps/downloads/tests/chrome/test_esc_key_closes_clears.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_esc_key_closes_clears.xul
@@ -47,26 +47,30 @@
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 function test()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   // Close the UI if necessary
   let wm = Cc["@mozilla.org/appshell/window-mediator;1"].
            getService(Ci.nsIWindowMediator);
   let win = wm.getMostRecentWindow("Download:Manager");
   if (win) win.close();
 
   let os = Cc["@mozilla.org/observer-service;1"].
            getService(Ci.nsIObserverService);
@@ -103,18 +107,17 @@ function test()
       SimpleTest.finish();
     }
   };
 
   // Register with the observer service
   os.addObserver(testObs, DLMGR_UI_DONE, false);
 
   // Show the Download Manager UI
-  Cc["@mozilla.org/download-manager-ui;1"].
-  getService(Ci.nsIDownloadManagerUI).show();
+  dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/mozapps/downloads/tests/chrome/test_multi_select.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_multi_select.xul
@@ -48,26 +48,30 @@
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 function test()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   let dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
   let db = dm.DBConnection;
 
   // Empty any old downloads
   db.executeSimpleSQL("DELETE FROM moz_downloads");
 
   let stmt = db.createStatement(
@@ -212,20 +216,19 @@ function test()
 
       // We're done!
       win.close();
       obs.removeObserver(testObs, DLMGR_UI_DONE);
       SimpleTest.finish();
     }
   };
   obs.addObserver(testObs, DLMGR_UI_DONE, false);
- 
+
   // Show the Download Manager UI
-  Cc["@mozilla.org/download-manager-ui;1"].
-  getService(Ci.nsIDownloadManagerUI).show();
+  dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/mozapps/downloads/tests/chrome/test_multiword_search.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_multiword_search.xul
@@ -46,26 +46,30 @@
 <window title="Download Manager Test"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 function test()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   let dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
   let db = dm.DBConnection;
 
   // Empty any old downloads
   db.executeSimpleSQL("DELETE FROM moz_downloads");
 
   // Make a file name for the downloads
@@ -146,20 +150,19 @@ function test()
           obs.removeObserver(testObs, DLMGR_UI_DONE);
           SimpleTest.finish();
 
           break;
       }
     }
   };
   obs.addObserver(testObs, DLMGR_UI_DONE, false);
- 
+
   // Show the Download Manager UI
-  Cc["@mozilla.org/download-manager-ui;1"].
-  getService(Ci.nsIDownloadManagerUI).show();
+  dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/mozapps/downloads/tests/chrome/test_pause_button_state.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_pause_button_state.xul
@@ -46,24 +46,22 @@
 <window title="Download Manager Test"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
 var dmFile = Cc["@mozilla.org/file/directory_service;1"].
              getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
 dmFile.append("dm-ui-test.file");
 dmFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
 var gTestPath = ios.newFileURI(dmFile).spec;
 
 const DownloadData = [
@@ -82,16 +80,22 @@ const DownloadData = [
     endTime: 1200185939538520,
     entityID: "",
     state: Ci.nsIDownloadManager.DOWNLOAD_DOWNLOADING,
     currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0 }
 ];
 
 function test()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   var dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
   var db = dm.DBConnection;
 
   // First, we populate the database with some fake data
   db.executeSimpleSQL("DELETE FROM moz_downloads");
   var rawStmt = db.createStatement(
     "INSERT INTO moz_downloads (name, source, target, startTime, endTime, " +
@@ -159,18 +163,17 @@ function test()
       SimpleTest.finish();
     }
   }
 
   // Register with the observer service
   os.addObserver(testObs, DLMGR_UI_DONE, false);
 
   // Show the Download Manager UI
-  Cc["@mozilla.org/download-manager-ui;1"].
-  getService(Ci.nsIDownloadManagerUI).show();
+  dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/mozapps/downloads/tests/chrome/test_privatebrowsing_title.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_privatebrowsing_title.xul
@@ -47,34 +47,40 @@
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 function test()
 {
   // The private browsing service might not be available
   let pbs = null;
   try {
     pbs = Cc["@mozilla.org/privatebrowsing;1"].getService(Ci.nsIPrivateBrowsingService);
   } catch (e) {
   }
-  if (!pbs)
+  if (!pbs) {
+    todo(false, "skip test - no private browsing supported");
     return;
+  }
+
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
 
   // We should prevent the private browsing service from changing the current
   // session on private mode transitions, in order to play nice with the
   // Mochitest test harness.
   let prefBranch = Cc["@mozilla.org/preferences-service;1"].
                    getService(Ci.nsIPrefBranch);
   prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true);
 
@@ -123,18 +129,17 @@ function test()
       win.close();
       prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");
       SimpleTest.finish();
     }
   };
   obs.addObserver(testObs, DLMGR_UI_DONE, false);
 
   // Show the Download Manager UI
-  Cc["@mozilla.org/download-manager-ui;1"].
-  getService(Ci.nsIDownloadManagerUI).show();
+  dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/mozapps/downloads/tests/chrome/test_removeDownload_updates_ui.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_removeDownload_updates_ui.xul
@@ -45,24 +45,22 @@
 <window title="Download Manager Test"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
 var dmFile = Cc["@mozilla.org/file/directory_service;1"].
              getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
 dmFile.append("dm-ui-test.file");
 dmFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
 var gTestPath = ios.newFileURI(dmFile).spec;
 
 const DownloadData = [
@@ -72,16 +70,22 @@ const DownloadData = [
     startTime: 1180493839859230,
     endTime: 1180493839859239,
     state: Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
     currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0 }
 ];
 
 function test()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   var dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
   var db = dm.DBConnection;
 
   // First, we populate the database with some fake data
   db.executeSimpleSQL("DELETE FROM moz_downloads");
   var rawStmt = db.createStatement(
     "INSERT INTO moz_downloads (name, source, target, startTime, endTime, " +
@@ -142,18 +146,17 @@ function test()
       SimpleTest.finish();
     }
   }
 
   // Register with the observer service
   os.addObserver(testObs, DLMGR_UI_DONE, false);
 
   // Show the Download Manager UI
-  Cc["@mozilla.org/download-manager-ui;1"].
-  getService(Ci.nsIDownloadManagerUI).show();
+  dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/mozapps/downloads/tests/chrome/test_search_clearlist.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_search_clearlist.xul
@@ -45,26 +45,30 @@
 <window title="Download Manager Test"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 function test()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   let dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
   let db = dm.DBConnection;
 
   // Empty any old downloads
   db.executeSimpleSQL("DELETE FROM moz_downloads");
 
   // Make a file name for the downloads
@@ -156,18 +160,17 @@ function test()
 
           break;
       }
     }
   };
   obs.addObserver(testObs, DLMGR_UI_DONE, false);
 
   // Show the Download Manager UI
-  Cc["@mozilla.org/download-manager-ui;1"].
-  getService(Ci.nsIDownloadManagerUI).show();
+  dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/mozapps/downloads/tests/chrome/test_search_keys.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_search_keys.xul
@@ -49,24 +49,22 @@
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 function test_meta_k(aWin)
 {
   let doc = aWin.document;
   let searchbox = doc.getElementById("searchbox");
   let richlistbox = doc.getElementById("downloadView");
 
   // Enusre the serachbox is not focused
   richlistbox.focus();
@@ -78,16 +76,22 @@ function test_meta_k(aWin)
 }
 
 let testFuncs = [
   test_meta_k,
 ]
 
 function test()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   let dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
 
   // See if the DM is already open, and if it is, close it!
   let wm = Cc["@mozilla.org/appshell/window-mediator;1"].
            getService(Ci.nsIWindowMediator);
   let win = wm.getMostRecentWindow("Download:Manager");
   if (win)
@@ -114,18 +118,17 @@ function test()
       SimpleTest.finish();
     }
   };
 
   // Register with the observer service
   os.addObserver(testObs, DLMGR_UI_DONE, false);
 
   // Show the Download Manager UI
-  Cc["@mozilla.org/download-manager-ui;1"].
-  getService(Ci.nsIDownloadManagerUI).show();
+  dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/mozapps/downloads/tests/chrome/test_select_all.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_select_all.xul
@@ -47,26 +47,30 @@
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 function test()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   let dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
   let db = dm.DBConnection;
 
   // Empty any old downloads
   db.executeSimpleSQL("DELETE FROM moz_downloads");
 
   // Make a file name for the downloads
@@ -130,18 +134,17 @@ function test()
       win.close();
       obs.removeObserver(testObs, DLMGR_UI_DONE);
       SimpleTest.finish();
     }
   };
   obs.addObserver(testObs, DLMGR_UI_DONE, false);
 
   // Show the Download Manager UI
-  Cc["@mozilla.org/download-manager-ui;1"].
-  getService(Ci.nsIDownloadManagerUI).show();
+  dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/mozapps/downloads/tests/chrome/test_space_key_pauses_resumes.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_space_key_pauses_resumes.xul
@@ -48,24 +48,22 @@
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 function bug413985obs(aWin)
 {
   this.mWin = aWin;
   this.wasPaused = false;
   this.wasResumed = false;
 }
 bug413985obs.prototype = {
   observe: function(aSubject, aTopic, aData)
@@ -107,16 +105,22 @@ bug413985obs.prototype = {
     }
   },
   onStateChange: function(a, b, c, d, e) { },
   onProgressChange: function(a, b, c, d, e, f, g) { },
   onSecurityChange: function(a, b, c, d) { }
 };
 function test()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   var dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
 
   function addDownload() {
     function createURI(aObj) {
       var ios = Cc["@mozilla.org/network/io-service;1"].
                 getService(Ci.nsIIOService);
       return (aObj instanceof Ci.nsIFile) ? ios.newFileURI(aObj) :
@@ -156,17 +160,17 @@ function test()
            getService(Ci.nsIWindowMediator);
   var win = wm.getMostRecentWindow("Download:Manager");
   if (win)
     win.close();
 
   let os = Cc["@mozilla.org/observer-service;1"].
            getService(Ci.nsIObserverService);
   const DLMGR_UI_DONE = "download-manager-ui-done";
- 
+
   let testObs = {
     observe: function(aSubject, aTopic, aData)
     {
       if (aTopic != DLMGR_UI_DONE)
         return;
 
       let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
       let doc = win.document;
@@ -178,18 +182,17 @@ function test()
       os.removeObserver(testObs, DLMGR_UI_DONE);
     }
   };
 
   // Register with the observer service
   os.addObserver(testObs, DLMGR_UI_DONE, false);
 
   // Show the Download Manager UI
-  Cc["@mozilla.org/download-manager-ui;1"].
-  getService(Ci.nsIDownloadManagerUI).show();
+  dmui.show();
 
   SimpleTest.waitForExplicitFinish();
 }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
--- a/toolkit/mozapps/downloads/tests/chrome/test_ui_stays_open_on_alert_clickback.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_ui_stays_open_on_alert_clickback.xul
@@ -46,26 +46,30 @@
 <window title="Download Manager Test"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="test();">
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
 
   <script type="application/javascript">
   <![CDATA[
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cr = Components.results;
-
 function test()
 {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   let dm = Cc["@mozilla.org/download-manager;1"].
            getService(Ci.nsIDownloadManager);
 
   // Empty any old downloads
   dm.DBConnection.executeSimpleSQL("DELETE FROM moz_downloads");
 
   let setClose = function(aVal) Cc["@mozilla.org/preferences-service;1"].
     getService(Ci.nsIPrefBranch).
@@ -75,30 +79,28 @@ function test()
   let wm = Cc["@mozilla.org/appshell/window-mediator;1"].
            getService(Ci.nsIWindowMediator);
   let win = wm.getMostRecentWindow("Download:Manager");
   if (win) win.close();
 
   let os = Cc["@mozilla.org/observer-service;1"].
            getService(Ci.nsIObserverService);
   const DLMGR_UI_DONE = "download-manager-ui-done";
- 
+
   let testObs = {
     observe: function(aSubject, aTopic, aData)
     {
       if (aTopic != DLMGR_UI_DONE)
         return;
 
       let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
 
       // Note:  This test will not be valid if the download list is built
       //        synchronously in Startup in downloads.js
       // Make sure the window stays open
-      let dmui = Cc["@mozilla.org/download-manager-ui;1"].
-                 getService(Ci.nsIDownloadManagerUI);
       ok(dmui.visible, "Download Manager stays open on alert click");
 
       win.close();
       setClose(false);
       os.removeObserver(testObs, DLMGR_UI_DONE);
 
       Cc["@mozilla.org/preferences-service;1"].
       getService(Ci.nsIPrefBranch).
--- a/toolkit/mozapps/downloads/tests/chrome/utils.js
+++ b/toolkit/mozapps/downloads/tests/chrome/utils.js
@@ -40,16 +40,32 @@
  * Provides utility functions for the download manager chrome tests.
  */
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 
 /**
+ * Returns the toolkit implementation of the download manager UI service.
+ * If the toolkit implementation of the service can't be found (e.g. because
+ * SeaMonkey doesn't package that version but an own implementation that calls
+ * different UI), then returns false (see bug 483781).
+ *
+ * @returns toolkit's nsIDownloadManagerUI implementation or false if not found
+ */
+function getDMUI()
+{
+  if (Components.classesByID["{7dfdf0d1-aff6-4a34-bad1-d0fe74601642}"])
+    return Components.classesByID["{7dfdf0d1-aff6-4a34-bad1-d0fe74601642}"].
+           getService(Ci.nsIDownloadManagerUI);
+  return false;
+}
+
+/**
  * Adds a live download to the download manager.
  *
  * @param [optional] aName
  *        The name that will be assigned to the downloaded file.
  * @returns an instance of nsIDownload.
  */
 function addDownload(aName) {
     function createURI(aObj) {