Bug 928349 - Add a build-time setting to use only the JavaScript API for downloads, and enable it in Firefox for Desktop. r=enn a=lsblakk
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Fri, 25 Oct 2013 15:35:38 +0200
changeset 160834 651537e2968a32bfbab112b7c8b32ecb16fb54b8
parent 160833 cc6e947e42843f261c76e47c3488a7116ee1f39f
child 160835 4253a66382fa080f2b5b0b902d1bd84c54bb765a
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenn, lsblakk
bugs928349
milestone26.0a2
Bug 928349 - Add a build-time setting to use only the JavaScript API for downloads, and enable it in Firefox for Desktop. r=enn a=lsblakk
browser/app/profile/firefox.js
browser/components/downloads/src/DownloadsCommon.jsm
browser/components/downloads/src/DownloadsStartup.js
browser/components/nsBrowserGlue.js
browser/confvars.sh
configure.in
security/manager/ssl/tests/mochitest/mixedcontent/test_bug383369.html
toolkit/components/downloads/nsDownloadManager.cpp
toolkit/components/downloads/test/moz.build
toolkit/components/downloads/test/unit/bug_401582_downloads.sqlite
toolkit/components/downloads/test/unit/bug_409179_downloads.sqlite
toolkit/components/downloads/test/unit/empty_downloads.rdf
toolkit/components/downloads/test/unit/head_download_manager.js
toolkit/components/downloads/test/unit/test_bug_401582.js
toolkit/components/downloads/test/unit/test_bug_409179.js
toolkit/components/downloads/test/unit/test_old_download_files_removed.js
toolkit/components/downloads/test/unit/xpcshell.ini
toolkit/forgetaboutsite/ForgetAboutSite.jsm
toolkit/forgetaboutsite/test/unit/downloads.empty.sqlite
toolkit/forgetaboutsite/test/unit/head_forgetaboutsite.js
toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js
toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain_activeDownloads.js
toolkit/forgetaboutsite/test/unit/xpcshell.ini
toolkit/mozapps/downloads/DownloadTaskbarProgress.jsm
toolkit/mozapps/downloads/tests/chrome/test_taskbarprogress_service.xul
toolkit/mozapps/downloads/tests/chrome/utils.js
uriloader/exthandler/tests/moz.build
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -330,22 +330,16 @@ pref("browser.download.manager.showWhenS
 pref("browser.download.manager.closeWhenDone", false);
 pref("browser.download.manager.focusWhenStarting", false);
 pref("browser.download.manager.flashCount", 2);
 pref("browser.download.manager.addToRecentDocs", true);
 pref("browser.download.manager.quitBehavior", 0);
 pref("browser.download.manager.scanWhenDone", true);
 pref("browser.download.manager.resumeOnWakeDelay", 10000);
 
-// Enables the asynchronous Downloads API in the Downloads Panel.
-pref("browser.download.useJSTransfer", true);
-
-// This allows disabling the Downloads Panel in favor of the old interface.
-pref("browser.download.useToolkitUI", false);
-
 // This allows disabling the animated notifications shown by
 // the Downloads Indicator when a download starts or completes.
 pref("browser.download.animateNotifications", true);
 
 // This records whether or not the panel has been shown at least once.
 pref("browser.download.panel.shown", false);
 
 // This records whether or not at least one session with the Downloads Panel
--- a/browser/components/downloads/src/DownloadsCommon.jsm
+++ b/browser/components/downloads/src/DownloadsCommon.jsm
@@ -230,25 +230,22 @@ this.DownloadsCommon = {
     if (hours < 48) { // two days
       return DownloadsCommon.strings["shortTimeLeftHours"](hours);
     }
     let days = Math.round(hours / 24);
     return DownloadsCommon.strings["shortTimeLeftDays"](Math.min(days, 99));
   },
 
   /**
-   * Indicates whether we should show the full Download Manager window interface
-   * instead of the simplified panel interface.  The behavior of downloads
-   * across browsing session is consistent with the selected interface.
+   * Indicates that we should show the simplified panel interface instead of the
+   * full Download Manager window interface.  The code associated with the
+   * Download Manager window interface will be removed in bug 899110.
    */
   get useToolkitUI()
   {
-    try {
-      return Services.prefs.getBoolPref("browser.download.useToolkitUI");
-    } catch (ex) { }
     return false;
   },
 
   /**
    * Indicates whether we should show visual notification on the indicator
    * when a download event is triggered.
    */
   get animateNotifications()
@@ -565,27 +562,22 @@ XPCOMUtils.defineLazyGetter(DownloadsCom
   if (os != "WINNT") {
     return false;
   }
   let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
   return parseFloat(sysInfo.getProperty("version")) >= 6;
 });
 
 /**
- * Returns true if we should hook the panel to the JavaScript API for downloads
- * instead of the nsIDownloadManager back-end.  In order for the logic to work
- * properly, this value never changes during the execution of the application,
- * even if the underlying preference value has changed.  A restart is required
- * for the change to take effect.
+ * Returns true to indicate that we should hook the panel to the JavaScript API
+ * for downloads instead of the nsIDownloadManager back-end.  The code
+ * associated with nsIDownloadManager will be removed in bug 899110.
  */
 XPCOMUtils.defineLazyGetter(DownloadsCommon, "useJSTransfer", function () {
-  try {
-    return Services.prefs.getBoolPref("browser.download.useJSTransfer");
-  } catch (ex) { }
-  return false;
+  return true;
 });
 
 ////////////////////////////////////////////////////////////////////////////////
 //// DownloadsData
 
 /**
  * Retrieves the list of past and completed downloads from the underlying
  * Download Manager data, and provides asynchronous notifications allowing to
--- a/browser/components/downloads/src/DownloadsStartup.js
+++ b/browser/components/downloads/src/DownloadsStartup.js
@@ -88,39 +88,23 @@ DownloadsStartup.prototype = {
       case "profile-after-change":
         // Override Toolkit's nsIDownloadManagerUI implementation with our own.
         // This must be done at application startup and not in the manifest to
         // ensure that our implementation overrides the original one.
         Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
                           .registerFactory(kDownloadsUICid, "",
                                            kDownloadsUIContractId, null);
 
-        // If the integration preference is enabled, override Toolkit's
-        // nsITransfer implementation with the one from the JavaScript API for
-        // downloads.  This should be used only by developers while testing new
-        // code that uses the JavaScript API, and will eventually be removed
-        // when nsIDownloadManager will not be available anymore (bug 851471).
-        let useJSTransfer = false;
-        try {
-          // For performance reasons, we don't want to load the DownloadsCommon
-          // module during startup, so we read the preference value directly.
-          useJSTransfer =
-            Services.prefs.getBoolPref("browser.download.useJSTransfer");
-        } catch (ex) { }
-        if (useJSTransfer) {
-          Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
-                            .registerFactory(kTransferCid, "",
-                                             kTransferContractId, null);
-        } else {
-          // The other notifications are handled internally by the JavaScript
-          // API for downloads, no need to observe when that API is enabled.
-          for (let topic of kObservedTopics) {
-            Services.obs.addObserver(this, topic, true);
-          }
-        }
+        // Override Toolkit's nsITransfer implementation with the one from the
+        // JavaScript API for downloads.  This will eventually be removed when
+        // nsIDownloadManager will not be available anymore (bug 851471).  The
+        // old code in this module will be removed in bug 899110.
+        Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
+                          .registerFactory(kTransferCid, "",
+                                           kTransferContractId, null);
         break;
 
       case "sessionstore-windows-restored":
       case "sessionstore-browser-state-restored":
         // Unless there is no saved session, there is a chance that we are
         // starting up after a restart or a crash.  We should check the disk
         // database to see if there are completed downloads to recover and show
         // in the panel, in addition to in-progress downloads.
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1423,19 +1423,16 @@ BrowserGlue.prototype = {
           currentset = currentset.replace(/(^|,)home-button($|,)/,
                                           "$1downloads-button,home-button$2")
         } else {
           currentset = currentset.replace(/(^|,)window-controls($|,)/,
                                           "$1downloads-button,window-controls$2")
         }
         this._setPersist(toolbarResource, currentsetResource, currentset);
       }
-
-      Services.prefs.clearUserPref("browser.download.useToolkitUI");
-      Services.prefs.clearUserPref("browser.library.useNewDownloadsView");
     }
 
 #ifdef XP_WIN
     if (currentUIVersion < 10) {
       // For Windows systems with display set to > 96dpi (i.e. systemDefaultScale
       // will return a value > 1.0), we want to discard any saved full-zoom settings,
       // as we'll now be scaling the content according to the system resolution
       // scale factor (Windows "logical DPI" setting)
--- a/browser/confvars.sh
+++ b/browser/confvars.sh
@@ -53,8 +53,10 @@ MOZ_PROFILE_MIGRATOR=1
 MOZ_EXTENSION_MANAGER=1
 MOZ_APP_STATIC_INI=1
 MOZ_WEBAPP_RUNTIME=1
 MOZ_MEDIA_NAVIGATOR=1
 if test "$OS_TARGET" = "WINNT" -o "$OS_TARGET" = "Darwin"; then
   MOZ_FOLD_LIBS=1
 fi
 MOZ_WEBGL_CONFORMANT=1
+MOZ_JSDOWNLOADS=1
+
--- a/configure.in
+++ b/configure.in
@@ -8510,16 +8510,21 @@ AC_SUBST(USE_DEPENDENT_LIBS)
 
 AC_SUBST(MOZ_BUILD_ROOT)
 AC_SUBST(MOZ_OS2_TOOLS)
 
 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
 AC_SUBST(MOZ_LINKER_EXTRACT)
 
+AC_SUBST(MOZ_JSDOWNLOADS)
+if test -n "$MOZ_JSDOWNLOADS"; then
+  AC_DEFINE(MOZ_JSDOWNLOADS)
+fi
+
 dnl ========================================================
 dnl = Mac bundle name prefix
 dnl ========================================================
 MOZ_ARG_WITH_STRING(macbundlename-prefix,
 [  --with-macbundlename-prefix=prefix
                           Prefix for MOZ_MACBUNDLE_NAME],
 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
 
--- a/security/manager/ssl/tests/mochitest/mixedcontent/test_bug383369.html
+++ b/security/manager/ssl/tests/mochitest/mixedcontent/test_bug383369.html
@@ -41,18 +41,21 @@
     prefs.setIntPref("folderList", 2);
     prefs.setBoolPref("manager.closeWhenDone", true);
     prefs.setBoolPref("manager.showWhenStarting", false);
   
     var theWindow = window;
 
     var useJSTransfer = false;
     try {
-      useJSTransfer = prefs.getBoolPref("useJSTransfer");
-    } catch (ex) { }
+      // This method throws an exception if the old Download Manager is disabled.
+      Services.downloads.activeDownloadCount;
+    } catch (ex) {
+      useJSTransfer = true;
+    }
 
     if (useJSTransfer) {
       var Downloads = SpecialPowers.Cu.import("resource://gre/modules/Downloads.jsm").Downloads;
       Downloads.getList(Downloads.PUBLIC).then(list => {
         list = SpecialPowers.wrap(list);
         list.addView({
           onDownloadAdded: function (aDownload) {
             list.removeView(this);
--- a/toolkit/components/downloads/nsDownloadManager.cpp
+++ b/toolkit/components/downloads/nsDownloadManager.cpp
@@ -35,16 +35,17 @@
 #include "nsToolkitCompsCID.h"
 
 #include "SQLFunctions.h"
 
 #include "mozilla/Preferences.h"
 
 #ifdef XP_WIN
 #include <shlobj.h>
+#include "nsWindowsHelpers.h"
 #ifdef DOWNLOAD_SCANNER
 #include "nsDownloadScanner.h"
 #endif
 #endif
 
 #ifdef XP_MACOSX
 #include <CoreFoundation/CoreFoundation.h>
 #endif
@@ -932,17 +933,35 @@ nsDownloadManager::Init()
     mozilla::services::GetStringBundleService();
   if (!bundleService)
     return NS_ERROR_FAILURE;
 
   rv = bundleService->CreateBundle(DOWNLOAD_MANAGER_BUNDLE,
                                    getter_AddRefs(mBundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
+#if defined(MOZ_JSDOWNLOADS) && !defined(XP_WIN)
+
+  // When MOZ_JSDOWNLOADS is defined on a non-Windows platform, this component
+  // is always disabled and we can safely omit the initialization code.
+  mUseJSTransfer = true;
+
+#else
+
+#if defined(MOZ_JSDOWNLOADS) && defined(XP_WIN)
+  // When MOZ_JSDOWNLOADS is defined on Windows, this component is disabled
+  // unless we are running in Windows Metro.  The conversion of Windows Metro
+  // to use the JavaScript API for downloads is tracked in bug 906042.
+  mUseJSTransfer = !IsRunningInWindowsMetro();
+#else
+  // When MOZ_JSDOWNLOADS is undefined, we still check the preference that can
+  // be used to enable the JavaScript API during the migration process.
   mUseJSTransfer = Preferences::GetBool(PREF_BD_USEJSTRANSFER, false);
+#endif
+
   if (mUseJSTransfer)
     return NS_OK;
 
   // Clean up any old downloads.rdf files from before Firefox 3
   {
     nsCOMPtr<nsIFile> oldDownloadsFile;
     bool fileExists;
     if (NS_SUCCEEDED(NS_GetSpecialDirectory(NS_APP_DOWNLOADS_50_FILE,
@@ -1003,16 +1022,18 @@ nsDownloadManager::Init()
   (void)mObserverService->AddObserver(this, NS_IOSERVICE_GOING_OFFLINE_TOPIC, true);
   (void)mObserverService->AddObserver(this, NS_IOSERVICE_OFFLINE_STATUS_TOPIC, true);
   (void)mObserverService->AddObserver(this, "last-pb-context-exited", true);
   (void)mObserverService->AddObserver(this, "last-pb-context-exiting", true);
 
   if (history)
     (void)history->AddObserver(this, true);
 
+#endif // defined(MOZ_JSDOWNLOADS) && !defined(XP_WIN)
+
   return NS_OK;
 }
 
 int32_t
 nsDownloadManager::GetRetentionBehavior()
 {
   // We use 0 as the default, which is "remove when done"
   nsresult rv;
--- a/toolkit/components/downloads/test/moz.build
+++ b/toolkit/components/downloads/test/moz.build
@@ -1,11 +1,13 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-TEST_DIRS += ['browser']
-
 MODULE = 'test_dm'
 
-XPCSHELL_TESTS_MANIFESTS += ['schema_migration/xpcshell.ini', 'unit/xpcshell.ini']
+if not CONFIG['MOZ_JSDOWNLOADS']:
+    TEST_DIRS += ['browser']
+    XPCSHELL_TESTS_MANIFESTS += ['schema_migration/xpcshell.ini']
+
+XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
deleted file mode 100644
index a81e9d65a873f270189d2813225feac925b5f450..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 324e4aaba1de1e8e5fa75dbbf8702e4c7de1e035..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/toolkit/components/downloads/test/unit/head_download_manager.js
+++ b/toolkit/components/downloads/test/unit/head_download_manager.js
@@ -51,35 +51,16 @@ var provider = {
         iid.equals(Ci.nsISupports)) {
       return this;
     }
     throw Cr.NS_ERROR_NO_INTERFACE;
   }
 };
 dirSvc.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider);
 
-/**
- * Imports a download test file to use.  Works with rdf and sqlite files.
- *
- * @param aFName
- *        The name of the file to import.  This file should be located in the
- *        same directory as this file.
- */
-function importDownloadsFile(aFName)
-{
-  var file = do_get_file(aFName);
-  var newFile = dirSvc.get("ProfD", Ci.nsIFile);
-  if (/\.rdf$/i.test(aFName))
-    file.copyTo(newFile, "downloads.rdf");
-  else if (/\.sqlite$/i.test(aFName))
-    file.copyTo(newFile, "downloads.sqlite");
-  else
-    do_throw("Unexpected filename!");
-}
-
 var gDownloadCount = 0;
 /**
  * Adds a download to the DM, and starts it.
  * @param server: a HttpServer used to serve the sourceURI
  * @param aParams (optional): an optional object which contains the function
  *                            parameters:
  *                              resultFileName: leaf node for the target file
  *                              targetFile: nsIFile for the target (overrides resultFileName)
@@ -238,14 +219,15 @@ XPCOMUtils.defineLazyGetter(this, "Servi
 Services.prefs.setBoolPref("browser.download.manager.showAlertOnComplete", false);
 
 do_register_cleanup(function() {
   Services.obs.notifyObservers(null, "quit-application", null);
 });
 
 function oldDownloadManagerDisabled() {
   try {
-    if (Services.prefs.getBoolPref("browser.download.useJSTransfer")) {
-      return true;
-    }
-  } catch (ex) { }
+    // This method throws an exception if the old Download Manager is disabled.
+    Services.downloads.activeDownloadCount;
+  } catch (ex) {
+    return true;
+  }
   return false;
 }
\ No newline at end of file
deleted file mode 100644
--- a/toolkit/components/downloads/test/unit/test_bug_401582.js
+++ /dev/null
@@ -1,36 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-// This tests that downloads in the scanning state are set to a completed state
-// upon service initialization.
-
-importDownloadsFile("bug_401582_downloads.sqlite");
-
-const nsIDownloadManager = Ci.nsIDownloadManager;
-const dm = Cc["@mozilla.org/download-manager;1"].getService(nsIDownloadManager);
-
-function test_noScanningDownloads()
-{
-  var stmt = dm.DBConnection.createStatement(
-    "SELECT * " +
-    "FROM moz_downloads " +
-    "WHERE state = ?1");
-  stmt.bindByIndex(0, nsIDownloadManager.DOWNLOAD_SCANNING);
-
-  do_check_false(stmt.executeStep());
-  stmt.reset();
-  stmt.finalize();
-}
-
-var tests = [test_noScanningDownloads];
-
-function run_test()
-{
-  if (oldDownloadManagerDisabled()) {
-    return;
-  }
-
-  for (var i = 0; i < tests.length; i++)
-    tests[i]();
-}
deleted file mode 100644
--- a/toolkit/components/downloads/test/unit/test_bug_409179.js
+++ /dev/null
@@ -1,24 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-// This file ensures that the download manager service can be instantiated with
-// a certain downloads.sqlite file that had incorrect data.
-
-importDownloadsFile("bug_409179_downloads.sqlite");
-
-function run_test()
-{
-  if (oldDownloadManagerDisabled()) {
-    return;
-  }
-
-  var caughtException = false;
-  try {
-    var dm = Cc["@mozilla.org/download-manager;1"].
-             getService(Ci.nsIDownloadManager);
-  } catch (e) {
-    caughtException = true;
-  }
-  do_check_false(caughtException);
-}
deleted file mode 100644
--- a/toolkit/components/downloads/test/unit/test_old_download_files_removed.js
+++ /dev/null
@@ -1,24 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-// Make sure we remove old, now-unused downloads.rdf (pre-Firefox 3 storage)
-// when starting the download manager.
-
-function run_test()
-{
-  if (oldDownloadManagerDisabled()) {
-    return;
-  }
-
-  // Create the downloads.rdf file
-  importDownloadsFile("empty_downloads.rdf");
-
-  // Make sure it got created
-  let rdfFile = dirSvc.get("DLoads", Ci.nsIFile);
-  do_check_true(rdfFile.exists());
-
-  // Initialize the download manager, which will delete downloads.rdf
-  Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager);
-  do_check_false(rdfFile.exists());
-}
--- a/toolkit/components/downloads/test/unit/xpcshell.ini
+++ b/toolkit/components/downloads/test/unit/xpcshell.ini
@@ -3,29 +3,26 @@ head = head_download_manager.js
 tail = tail_download_manager.js
 firefox-appdir = browser
 
 [test_app_rep.js]
 [test_bug_382825.js]
 [test_bug_384744.js]
 [test_bug_395092.js]
 [test_bug_401430.js]
-[test_bug_401582.js]
 [test_bug_406857.js]
-[test_bug_409179.js]
 [test_bug_420230.js]
 [test_cancel_download_files_removed.js]
 # Bug 676989: test hangs consistently on Android
 skip-if = os == "android"
 [test_download_manager.js]
 [test_download_samename.js]
 # Bug 676989: test hangs consistently on Android
 skip-if = os == "android"
 [test_guid.js]
 [test_history_expiration.js]
 [test_offline_support.js]
-[test_old_download_files_removed.js]
 [test_private_resume.js]
 [test_privatebrowsing.js]
 [test_privatebrowsing_cancel.js]
 [test_removeDownloadsByTimeframe.js]
 [test_resume.js]
 [test_sleep_wake.js]
--- a/toolkit/forgetaboutsite/ForgetAboutSite.jsm
+++ b/toolkit/forgetaboutsite/ForgetAboutSite.jsm
@@ -93,18 +93,21 @@ this.ForgetAboutSite = {
           // Ignore errors from the plugin
         }
       }
     }
 
     // Downloads
     let useJSTransfer = false;
     try {
-      useJSTransfer = Services.prefs.getBoolPref("browser.download.useJSTransfer");
-    } catch(ex) { }
+      // This method throws an exception if the old Download Manager is disabled.
+      Services.downloads.activeDownloadCount;
+    } catch (ex) {
+      useJSTransfer = true;
+    }
 
     if (useJSTransfer) {
       Task.spawn(function() {
         let list = yield Downloads.getList(Downloads.ALL);
         list.removeFinished(download => hasRootDomain(
              NetUtil.newURI(download.source.url).host, aDomain));
       }).then(null, Cu.reportError);
     }
deleted file mode 100644
index c6f03e6a08ae14cad5bd47cecd6514b102b71ee1..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
--- a/toolkit/forgetaboutsite/test/unit/head_forgetaboutsite.js
+++ b/toolkit/forgetaboutsite/test/unit/head_forgetaboutsite.js
@@ -25,8 +25,19 @@ function cleanUp()
   for (let i = 0; i < files.length; i++) {
     let file = dirSvc.get("ProfD", Ci.nsIFile);
     file.append(files[i]);
     if (file.exists())
       file.remove(false);
   }
 }
 cleanUp();
+
+function oldDownloadManagerDisabled()
+{
+  try {
+    // This method throws an exception if the old Download Manager is disabled.
+    Services.downloads.activeDownloadCount;
+  } catch (ex) {
+    return true;
+  }
+  return false;
+}
--- a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js
+++ b/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js
@@ -440,32 +440,44 @@ function test_cookie_not_cleared_with_ur
   add_cookie(TEST_DOMAIN);
   ForgetAboutSite.removeDataFromDomain("mozilla.org");
   check_cookie_exists(TEST_DOMAIN, true);
 }
 
 // Download Manager
 function test_download_history_cleared_with_direct_match()
 {
+  if (oldDownloadManagerDisabled()) {
+    return;
+  }
+
   const TEST_URI = "http://mozilla.org/foo";
   add_download(TEST_URI, false);
   ForgetAboutSite.removeDataFromDomain("mozilla.org");
   check_downloaded(TEST_URI, false);
 }
 
 function test_download_history_cleared_with_subdomain()
 {
+  if (oldDownloadManagerDisabled()) {
+    return;
+  }
+
   const TEST_URI = "http://www.mozilla.org/foo";
   add_download(TEST_URI, false);
   ForgetAboutSite.removeDataFromDomain("mozilla.org");
   check_downloaded(TEST_URI, false);
 }
 
 function test_download_history_not_cleared_with_active_direct_match()
 {
+  if (oldDownloadManagerDisabled()) {
+    return;
+  }
+
   // Tests that downloads marked as active in the db are not deleted from the db
   const TEST_URI = "http://mozilla.org/foo";
   add_download(TEST_URI, true);
   ForgetAboutSite.removeDataFromDomain("mozilla.org");
   check_downloaded(TEST_URI, true);
 
   // Reset state
   let db = Cc["@mozilla.org/download-manager;1"].
deleted file mode 100644
--- a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain_activeDownloads.js
+++ /dev/null
@@ -1,133 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: sw=2 ts=2 sts=2
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Test added with bug 460086 to test the behavior of the new API that was added
- * to remove all traces of visiting a site.
- */
-
-Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource://gre/modules/ForgetAboutSite.jsm");
-
-////////////////////////////////////////////////////////////////////////////////
-//// Utility Functions
-
-/**
- * Creates an nsIURI object for the given file.
- *
- * @param aFile
- *        The nsIFile of the URI to create.
- * @returns an nsIURI representing aFile.
- */
-function uri(aFile)
-{
-  return Cc["@mozilla.org/network/io-service;1"].
-         getService(Ci.nsIIOService).
-         newFileURI(aFile);
-}
-
-/**
- * Checks to ensure a URI string is in download history or not.
- *
- * @param aURIString
- *        The string of the URI to check.
- * @param aIsActive
- *        True if the URI should be actively downloaded, false otherwise.
- */
-function check_active_download(aURIString, aIsActive)
-{
-  let dm = Cc["@mozilla.org/download-manager;1"].
-           getService(Ci.nsIDownloadManager);
-  let enumerator = dm.activeDownloads;
-  let found = false;
-  while (enumerator.hasMoreElements()) {
-    let dl = enumerator.getNext().QueryInterface(Ci.nsIDownload);
-    if (dl.source.spec == aURIString)
-      found = true;
-  }
-  let checker = aIsActive ? do_check_true : do_check_false;
-  checker(found);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//// Test Functions
-
-let destFile = dirSvc.get("TmpD", Ci.nsIFile);
-destFile.append("dm-test-file");
-destFile = uri(destFile);
-let data = [
-  { source: "http://mozilla.org/direct_match",
-    target: destFile.spec,
-    removed: true
-  },
-  { source: "http://www.mozilla.org/subdomain",
-    target: destFile.spec,
-    removed: true
-  },
-  { source: "http://ilovemozilla.org/contains_domain",
-    target: destFile.spec,
-    removed: false
-  },
-];
-
-function makeGUID() {
-  let guid = "";
-  for (var i = 0; i < 12; i++)
-    guid += Math.floor(Math.random() * 10);
-  return guid;
-}
-
-function run_test()
-{
-  // We add this data to the database first, but we cannot instantiate the
-  // download manager service, otherwise these downloads will not be placed in
-  // the active downloads array.
-
-  // Copy the empty downloads database to our profile directory
-  let downloads = do_get_file("downloads.empty.sqlite");
-  downloads.copyTo(dirSvc.get("ProfD", Ci.nsIFile), "downloads.sqlite");
-
-  // Open the database
-  let ss = Cc["@mozilla.org/storage/service;1"].
-           getService(Ci.mozIStorageService);
-  let file = dirSvc.get("ProfD", Ci.nsIFile);
-  file.append("downloads.sqlite");
-  let db = ss.openDatabase(file);
-
-  // Insert the data
-  let stmt = db.createStatement(
-    "INSERT INTO moz_downloads (source, target, state, autoResume, entityID, guid) " +
-    "VALUES (:source, :target, :state, :autoResume, :entityID, :guid)"
-  );
-  for (let i = 0; i < data.length; i++) {
-    stmt.params.source = data[i].source;
-    stmt.params.target = data[i].target;
-    stmt.params.state = Ci.nsIDownloadManager.DOWNLOAD_PAUSED;
-    stmt.params.autoResume = 0; // DONT_RESUME is 0
-    stmt.params.entityID = "foo" // just has to be non-null for our test
-    stmt.params.guid = makeGUID();
-    stmt.execute();
-    stmt.reset();
-  }
-  stmt.finalize();
-  stmt = null;
-  db.close();
-  db = null;
-
-  // Check to make sure it's all there
-  for (let i = 0; i < data.length; i++)
-    check_active_download(data[i].source, true);
-
-  // Dispatch the remove call
-  ForgetAboutSite.removeDataFromDomain("mozilla.org");
-
-  // And check our data
-  for (let i = 0; i < data.length; i++)
-    check_active_download(data[i].source, !data[i].removed);
-
-  // Shutdown the download manager.
-  Services.obs.notifyObservers(null, "quit-application", null);
-}
--- a/toolkit/forgetaboutsite/test/unit/xpcshell.ini
+++ b/toolkit/forgetaboutsite/test/unit/xpcshell.ini
@@ -1,6 +1,6 @@
 [DEFAULT]
 head = head_forgetaboutsite.js
 tail =
 
 [test_removeDataFromDomain.js]
-[test_removeDataFromDomain_activeDownloads.js]
+
--- a/toolkit/mozapps/downloads/DownloadTaskbarProgress.jsm
+++ b/toolkit/mozapps/downloads/DownloadTaskbarProgress.jsm
@@ -112,25 +112,16 @@ var DownloadTaskbarProgressUpdater =
    */
   _init: function DTPU_init()
   {
     if (this._initialized) {
       return; // Already initialized
     }
     this._initialized = true;
 
-    // Taskbar progress is disabled until this component is updated to use the
-    // asynchronous JavaScript API for downloads.
-    try {
-      if (Services.prefs.getBoolPref("browser.download.useJSTransfer")) {
-        DownloadTaskbarProgressUpdater = null;
-        return;
-      }
-    } catch (ex) { }
-
     if (kTaskbarIDWin in Cc) {
       this._taskbar = Cc[kTaskbarIDWin].getService(Ci.nsIWinTaskbar);
       if (!this._taskbar.available) {
         // The Windows version is probably too old
         DownloadTaskbarProgressUpdater = null;
         return;
       }
     } else if (kTaskbarIDMac in Cc) {
--- a/toolkit/mozapps/downloads/tests/chrome/test_taskbarprogress_service.xul
+++ b/toolkit/mozapps/downloads/tests/chrome/test_taskbarprogress_service.xul
@@ -24,16 +24,22 @@ const DOWNLOAD_MANAGER_URL = "chrome://m
 const DLMGR_UI_DONE = "download-manager-ui-done";
 
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 let DownloadTaskbarProgress, TaskbarService, observerService, wwatch, chromeWindow;
 let gGen = null;
 
 function test() {
+  var dmui = getDMUI();
+  if (!dmui) {
+    todo(false, "skip test for toolkit download manager UI");
+    return;
+  }
+
   let isWin7OrHigher = false;
   try {
     let version = Cc["@mozilla.org/system-info;1"]
                     .getService(Ci.nsIPropertyBag2)
                     .getProperty("version");
     isWin7OrHigher = (parseFloat(version) >= 6.1);
   } catch (ex) { }
 
--- a/toolkit/mozapps/downloads/tests/chrome/utils.js
+++ b/toolkit/mozapps/downloads/tests/chrome/utils.js
@@ -18,20 +18,21 @@ Components.utils.import("resource://gre/
  * 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()
 {
   try {
-    if (Services.prefs.getBoolPref("browser.download.useJSTransfer")) {
-      return false;
-    }
-  } catch (ex) { }
+    // This method throws an exception if the old Download Manager is disabled.
+    Services.downloads.activeDownloadCount;
+  } catch (ex) {
+    return false;
+  }
   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.
--- a/uriloader/exthandler/tests/moz.build
+++ b/uriloader/exthandler/tests/moz.build
@@ -7,17 +7,20 @@
 DIRS += ['mochitest']
 
 MODULE = 'test_uriloader_exthandler'
 
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 #FIXME/bug 575918: out-of-process xpcshell is broken on OS X
 if CONFIG['OS_ARCH'] != 'Darwin':
-    XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini']
+    # The encoding test is already implemented in the Downloads API by a set of
+    # test cases with the string "content_encoding" in their names.
+    if not CONFIG['MOZ_JSDOWNLOADS']:
+        XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini']
 
 sources = [
     'WriteArgument',
 ]
 
 CPP_SOURCES += [
     '%s.cpp' % s for s in sources
 ]