Backed out changeset 7e8ff4c464f9 (bug 847863) on suspicion of causing failures in browser_sanitize-timespans.js
authorEd Morley <emorley@mozilla.com>
Tue, 20 Aug 2013 11:52:34 +0100
changeset 143205 1d6bf2bd4003d23f9f726d85d2e75f83d26eae2a
parent 143204 0620357b639d3978179b0b5961fc1d75829491aa
child 143223 e7f398a716bc3bf8f0e316c5dd8adaadeda5cf91
child 143259 04b11fc91c34cabb45a0d180723f626f34b18c4b
child 143280 c44ddd2bef501f5e0bf8089c4de51a97bd790827
child 155667 3d94af4f67dfc5c2346d1666a90f3143a7d712f0
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
bugs847863
milestone26.0a1
backs out7e8ff4c464f984bfc844bbf5aa1daaf20fc82097
Backed out changeset 7e8ff4c464f9 (bug 847863) on suspicion of causing failures in browser_sanitize-timespans.js
browser/base/content/sanitize.js
browser/base/content/test/browser_sanitize-timespans.js
browser/base/content/test/browser_sanitizeDialog.js
--- a/browser/base/content/sanitize.js
+++ b/browser/base/content/sanitize.js
@@ -82,18 +82,17 @@ Sanitizer.prototype = {
           // Callers should check returned errors and give user feedback
           // about items that could not be sanitized
           let item = this.items[itemName];
           try {
             if (aCanClear)
               item.clear();
           } catch(er) {
             seenError = true;
-            Components.utils.reportError("Error sanitizing " + itemName +
-                                         ": " + er + "\n");
+            Cu.reportError("Error sanitizing " + itemName + ": " + er + "\n");
           }
           onItemComplete();
         };
         this.canClearItem(itemName, clearCallback);
       } else {
         onItemComplete();
       }
     }
@@ -317,17 +316,17 @@ Sanitizer.prototype = {
                             download.startTime <= this.range[1]) : null;
 
             // Clear all completed/cancelled downloads
             let publicList = yield Downloads.getPublicDownloadList();
             publicList.removeFinished(filterByTime);
 
             let privateList = yield Downloads.getPrivateDownloadList();
             privateList.removeFinished(filterByTime);
-          }.bind(this)).then(null, Components.utils.reportError);
+          }.bind(this)).then(null, Cu.reportError);
         }
         else {
           var dlMgr = Components.classes["@mozilla.org/download-manager;1"]
                                 .getService(Components.interfaces.nsIDownloadManager);
 
           if (this.range) {
             // First, remove the completed/cancelled downloads
             dlMgr.removeDownloadsByTimeframe(this.range[0], this.range[1]);
--- a/browser/base/content/test/browser_sanitize-timespans.js
+++ b/browser/base/content/test/browser_sanitize-timespans.js
@@ -1,53 +1,39 @@
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 // Bug 453440 - Test the timespan-based logic of the sanitizer code
 var now_uSec = Date.now() * 1000;
 
+const dm = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager);
+
 const kUsecPerMin = 60 * 1000000;
 
 let tempScope = {};
 Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader)
                                            .loadSubScript("chrome://browser/content/sanitize.js", tempScope);
 let Sanitizer = tempScope.Sanitizer;
 
 let FormHistory = (Components.utils.import("resource://gre/modules/FormHistory.jsm", {})).FormHistory;
-let Downloads = (Components.utils.import("resource://gre/modules/Downloads.jsm", {})).Downloads;
 
 function promiseFormHistoryRemoved() {
   let deferred = Promise.defer();
   Services.obs.addObserver(function onfh() {
     Services.obs.removeObserver(onfh, "satchel-storage-changed", false);
     deferred.resolve();
   }, "satchel-storage-changed", false);
   return deferred.promise;
 }
 
-function promiseDownloadRemoved(list) {
-  let deferred = Promise.defer();
-
-  let view = {
-    onDownloadRemoved: function(download) {
-      list.removeView(view);
-      deferred.resolve();
-    }
-  };
-
-  list.addView(view);
-  
-  return deferred.promise;
-}
-
 function test() {
   waitForExplicitFinish();
 
   Task.spawn(function() {
-    yield setupDownloads();
+    setupDownloads();
     yield setupFormHistory();
     yield setupHistory();
     yield onHistoryReady();
   }).then(finish);
 }
 
 function countEntries(name, message, check) {
   let deferred = Promise.defer();
@@ -89,26 +75,22 @@ function onHistoryReady() {
   itemPrefs.setBoolPref("cache", false);
   itemPrefs.setBoolPref("cookies", false);
   itemPrefs.setBoolPref("formdata", true);
   itemPrefs.setBoolPref("offlineApps", false);
   itemPrefs.setBoolPref("passwords", false);
   itemPrefs.setBoolPref("sessions", false);
   itemPrefs.setBoolPref("siteSettings", false);
 
-  let publicList = yield Downloads.getPublicDownloadList();
-  let downloadPromise = promiseDownloadRemoved(publicList);
-
   // Clear 10 minutes ago
   s.range = [now_uSec - 10*60*1000000, now_uSec];
   s.sanitize();
   s.range = null;
 
   yield promiseFormHistoryRemoved();
-  yield downloadPromise;
 
   ok(!(yield promiseIsURIVisited(makeURI("http://10minutes.com"))),
      "Pretend visit to 10minutes.com should now be deleted");
   ok((yield promiseIsURIVisited(makeURI("http://1hour.com"))),
      "Pretend visit to 1hour.com should should still exist");
   ok((yield promiseIsURIVisited(makeURI("http://1hour10minutes.com"))),
      "Pretend visit to 1hour10minutes.com should should still exist");
   ok((yield promiseIsURIVisited(makeURI("http://2hour.com"))),
@@ -135,37 +117,33 @@ function onHistoryReady() {
   yield countEntries("2hour", "2hour form entry should still exist", checkOne);
   yield countEntries("2hour10minutes", "2hour10minutes form entry should still exist", checkOne);
   yield countEntries("4hour", "4hour form entry should still exist", checkOne);
   yield countEntries("4hour10minutes", "4hour10minutes form entry should still exist", checkOne);
   if (minutesSinceMidnight > 10)
     yield countEntries("today", "today form entry should still exist", checkOne);
   yield countEntries("b4today", "b4today form entry should still exist", checkOne);
 
-  let downloads = yield publicList.getAll();
-  ok(!(yield downloadExists(publicList, "fakefile-10-minutes")), "10 minute download should now be deleted");
-  ok((yield downloadExists(publicList, "fakefile-1-hour")), "<1 hour download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-1-hour-10-minutes")), "1 hour 10 minute download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-2-hour")), "<2 hour old download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-2-hour-10-minutes")), "2 hour 10 minute download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-4-hour")), "<4 hour old download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should still be present");
+  ok(!downloadExists(5555555), "10 minute download should now be deleted");
+  ok(downloadExists(5555551), "<1 hour download should still be present");
+  ok(downloadExists(5555556), "1 hour 10 minute download should still be present");
+  ok(downloadExists(5555550), "Year old download should still be present");
+  ok(downloadExists(5555552), "<2 hour old download should still be present");
+  ok(downloadExists(5555557), "2 hour 10 minute download should still be present");
+  ok(downloadExists(5555553), "<4 hour old download should still be present");
+  ok(downloadExists(5555558), "4 hour 10 minute download should still be present");
 
   if (minutesSinceMidnight > 10)
-    ok((yield downloadExists(publicList, "fakefile-today")), "'Today' download should still be present");
-
-  downloadPromise = promiseDownloadRemoved(publicList);
+    ok(downloadExists(5555554), "'Today' download should still be present");
 
   // Clear 1 hour
   Sanitizer.prefs.setIntPref("timeSpan", 1);
   s.sanitize();
 
   yield promiseFormHistoryRemoved();
-  yield downloadPromise;
 
   ok(!(yield promiseIsURIVisited(makeURI("http://1hour.com"))),
      "Pretend visit to 1hour.com should now be deleted");
   ok((yield promiseIsURIVisited(makeURI("http://1hour10minutes.com"))),
      "Pretend visit to 1hour10minutes.com should should still exist");
   ok((yield promiseIsURIVisited(makeURI("http://2hour.com"))),
      "Pretend visit to 2hour.com should should still exist");
   ok((yield promiseIsURIVisited(makeURI("http://2hour10minutes.com"))),
@@ -186,36 +164,33 @@ function onHistoryReady() {
   yield countEntries("2hour", "2hour form entry should still exist", checkOne);
   yield countEntries("2hour10minutes", "2hour10minutes form entry should still exist", checkOne);
   yield countEntries("4hour", "4hour form entry should still exist", checkOne);
   yield countEntries("4hour10minutes", "4hour10minutes form entry should still exist", checkOne);
   if (hoursSinceMidnight > 1)
     yield countEntries("today", "today form entry should still exist", checkOne);
   yield countEntries("b4today", "b4today form entry should still exist", checkOne);
 
-  ok(!(yield downloadExists(publicList, "fakefile-1-hour")), "<1 hour download should now be deleted");
-  ok((yield downloadExists(publicList, "fakefile-1-hour-10-minutes")), "1 hour 10 minute download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-2-hour")), "<2 hour old download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-2-hour-10-minutes")), "2 hour 10 minute download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-4-hour")), "<4 hour old download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should still be present");
+  ok(!downloadExists(5555551), "<1 hour download should now be deleted");
+  ok(downloadExists(5555556), "1 hour 10 minute download should still be present");
+  ok(downloadExists(5555550), "Year old download should still be present");
+  ok(downloadExists(5555552), "<2 hour old download should still be present");
+  ok(downloadExists(5555557), "2 hour 10 minute download should still be present");
+  ok(downloadExists(5555553), "<4 hour old download should still be present");
+  ok(downloadExists(5555558), "4 hour 10 minute download should still be present");
 
   if (hoursSinceMidnight > 1)
-    ok((yield downloadExists(publicList, "fakefile-today")), "'Today' download should still be present");
+    ok(downloadExists(5555554), "'Today' download should still be present");
   
-  downloadPromise = promiseDownloadRemoved(publicList);
-
   // Clear 1 hour 10 minutes
   s.range = [now_uSec - 70*60*1000000, now_uSec];
   s.sanitize();
   s.range = null;
 
   yield promiseFormHistoryRemoved();
-  yield downloadPromise;
 
   ok(!(yield promiseIsURIVisited(makeURI("http://1hour10minutes.com"))),
      "Pretend visit to 1hour10minutes.com should now be deleted");
   ok((yield promiseIsURIVisited(makeURI("http://2hour.com"))),
      "Pretend visit to 2hour.com should should still exist");
   ok((yield promiseIsURIVisited(makeURI("http://2hour10minutes.com"))),
      "Pretend visit to 2hour10minutes.com should should still exist");
   ok((yield promiseIsURIVisited(makeURI("http://4hour.com"))),
@@ -233,33 +208,30 @@ function onHistoryReady() {
   yield countEntries("2hour", "2hour form entry should still exist", checkOne);
   yield countEntries("2hour10minutes", "2hour10minutes form entry should still exist", checkOne);
   yield countEntries("4hour", "4hour form entry should still exist", checkOne);
   yield countEntries("4hour10minutes", "4hour10minutes form entry should still exist", checkOne);
   if (minutesSinceMidnight > 70)
     yield countEntries("today", "today form entry should still exist", checkOne);
   yield countEntries("b4today", "b4today form entry should still exist", checkOne);
 
-  ok(!(yield downloadExists(publicList, "fakefile-1-hour-10-minutes")), "1 hour 10 minute old download should now be deleted");
-  ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-2-hour")), "<2 hour old download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-2-hour-10-minutes")), "2 hour 10 minute download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-4-hour")), "<4 hour old download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should still be present");
+  ok(!downloadExists(5555556), "1 hour 10 minute old download should now be deleted");
+  ok(downloadExists(5555550), "Year old download should still be present");
+  ok(downloadExists(5555552), "<2 hour old download should still be present");
+  ok(downloadExists(5555557), "2 hour 10 minute download should still be present");
+  ok(downloadExists(5555553), "<4 hour old download should still be present");
+  ok(downloadExists(5555558), "4 hour 10 minute download should still be present");
   if (minutesSinceMidnight > 70)
-    ok((yield downloadExists(publicList, "fakefile-today")), "'Today' download should still be present");
-
-  downloadPromise = promiseDownloadRemoved(publicList);
+    ok(downloadExists(5555554), "'Today' download should still be present");
 
   // Clear 2 hours
   Sanitizer.prefs.setIntPref("timeSpan", 2);
   s.sanitize();
 
   yield promiseFormHistoryRemoved();
-  yield downloadPromise;
 
   ok(!(yield promiseIsURIVisited(makeURI("http://2hour.com"))),
      "Pretend visit to 2hour.com should now be deleted");
   ok((yield promiseIsURIVisited(makeURI("http://2hour10minutes.com"))),
      "Pretend visit to 2hour10minutes.com should should still exist");
   ok((yield promiseIsURIVisited(makeURI("http://4hour.com"))),
      "Pretend visit to 4hour.com should should still exist");
   ok((yield promiseIsURIVisited(makeURI("http://4hour10minutes.com"))),
@@ -274,33 +246,30 @@ function onHistoryReady() {
   yield countEntries("2hour", "2hour form entry should be deleted", checkZero);
   yield countEntries("2hour10minutes", "2hour10minutes form entry should still exist", checkOne);
   yield countEntries("4hour", "4hour form entry should still exist", checkOne);
   yield countEntries("4hour10minutes", "4hour10minutes form entry should still exist", checkOne);
   if (hoursSinceMidnight > 2)
     yield countEntries("today", "today form entry should still exist", checkOne);
   yield countEntries("b4today", "b4today form entry should still exist", checkOne);
 
-  ok(!(yield downloadExists(publicList, "fakefile-2-hour")), "<2 hour old download should now be deleted");
-  ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-2-hour-10-minutes")), "2 hour 10 minute download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-4-hour")), "<4 hour old download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should still be present");
+  ok(!downloadExists(5555552), "<2 hour old download should now be deleted");
+  ok(downloadExists(5555550), "Year old download should still be present");
+  ok(downloadExists(5555557), "2 hour 10 minute download should still be present");
+  ok(downloadExists(5555553), "<4 hour old download should still be present");
+  ok(downloadExists(5555558), "4 hour 10 minute download should still be present");
   if (hoursSinceMidnight > 2)
-    ok((yield downloadExists(publicList, "fakefile-today")), "'Today' download should still be present");
+    ok(downloadExists(5555554), "'Today' download should still be present");
   
-  downloadPromise = promiseDownloadRemoved(publicList);
-
   // Clear 2 hours 10 minutes
   s.range = [now_uSec - 130*60*1000000, now_uSec];
   s.sanitize();
   s.range = null;
 
   yield promiseFormHistoryRemoved();
-  yield downloadPromise;
 
   ok(!(yield promiseIsURIVisited(makeURI("http://2hour10minutes.com"))),
      "Pretend visit to 2hour10minutes.com should now be deleted");
   ok((yield promiseIsURIVisited(makeURI("http://4hour.com"))),
      "Pretend visit to 4hour.com should should still exist");
   ok((yield promiseIsURIVisited(makeURI("http://4hour10minutes.com"))),
      "Pretend visit to 4hour10minutes.com should should still exist");
   if (minutesSinceMidnight > 130) {
@@ -312,31 +281,28 @@ function onHistoryReady() {
 
   yield countEntries("2hour10minutes", "2hour10minutes form entry should be deleted", checkZero);
   yield countEntries("4hour", "4hour form entry should still exist", checkOne);
   yield countEntries("4hour10minutes", "4hour10minutes form entry should still exist", checkOne);
   if (minutesSinceMidnight > 130)
     yield countEntries("today", "today form entry should still exist", checkOne);
   yield countEntries("b4today", "b4today form entry should still exist", checkOne);
 
-  ok(!(yield downloadExists(publicList, "fakefile-2-hour-10-minutes")), "2 hour 10 minute old download should now be deleted");
-  ok((yield downloadExists(publicList, "fakefile-4-hour")), "<4 hour old download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present");
+  ok(!downloadExists(5555557), "2 hour 10 minute old download should now be deleted");
+  ok(downloadExists(5555553), "<4 hour old download should still be present");
+  ok(downloadExists(5555558), "4 hour 10 minute download should still be present");
+  ok(downloadExists(5555550), "Year old download should still be present");
   if (minutesSinceMidnight > 130)
-    ok((yield downloadExists(publicList, "fakefile-today")), "'Today' download should still be present");
-
-  downloadPromise = promiseDownloadRemoved(publicList);
+    ok(downloadExists(5555554), "'Today' download should still be present");
 
   // Clear 4 hours
   Sanitizer.prefs.setIntPref("timeSpan", 3);
   s.sanitize();
 
   yield promiseFormHistoryRemoved();
-  yield downloadPromise;
 
   ok(!(yield promiseIsURIVisited(makeURI("http://4hour.com"))),
      "Pretend visit to 4hour.com should now be deleted");
   ok((yield promiseIsURIVisited(makeURI("http://4hour10minutes.com"))),
      "Pretend visit to 4hour10minutes.com should should still exist");
   if (hoursSinceMidnight > 4) {
     ok((yield promiseIsURIVisited(makeURI("http://today.com"))),
        "Pretend visit to today.com should still exist");
@@ -345,94 +311,85 @@ function onHistoryReady() {
     "Pretend visit to before-today.com should still exist");
 
   yield countEntries("4hour", "4hour form entry should be deleted", checkZero);
   yield countEntries("4hour10minutes", "4hour10minutes form entry should still exist", checkOne);
   if (hoursSinceMidnight > 4)
     yield countEntries("today", "today form entry should still exist", checkOne);
   yield countEntries("b4today", "b4today form entry should still exist", checkOne);
 
-  ok(!(yield downloadExists(publicList, "fakefile-4-hour")), "<4 hour old download should now be deleted");
-  ok((yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should still be present");
-  ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present");
+  ok(!downloadExists(5555553), "<4 hour old download should now be deleted");
+  ok(downloadExists(5555558), "4 hour 10 minute download should still be present");
+  ok(downloadExists(5555550), "Year old download should still be present");
   if (hoursSinceMidnight > 4)
-    ok((yield downloadExists(publicList, "fakefile-today")), "'Today' download should still be present");
-
-  downloadPromise = promiseDownloadRemoved(publicList);
+    ok(downloadExists(5555554), "'Today' download should still be present");
 
   // Clear 4 hours 10 minutes
   s.range = [now_uSec - 250*60*1000000, now_uSec];
   s.sanitize();
   s.range = null;
 
   yield promiseFormHistoryRemoved();
-  yield downloadPromise;
 
   ok(!(yield promiseIsURIVisited(makeURI("http://4hour10minutes.com"))),
      "Pretend visit to 4hour10minutes.com should now be deleted");
   if (minutesSinceMidnight > 250) {
     ok((yield promiseIsURIVisited(makeURI("http://today.com"))),
        "Pretend visit to today.com should still exist");
   }
   ok((yield promiseIsURIVisited(makeURI("http://before-today.com"))),
     "Pretend visit to before-today.com should still exist");
 
   yield countEntries("4hour10minutes", "4hour10minutes form entry should be deleted", checkZero);
   if (minutesSinceMidnight > 250)
     yield countEntries("today", "today form entry should still exist", checkOne);
   yield countEntries("b4today", "b4today form entry should still exist", checkOne);
   
-  ok(!(yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "4 hour 10 minute download should now be deleted");
-  ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present");
+  ok(!downloadExists(5555558), "4 hour 10 minute download should now be deleted");
+  ok(downloadExists(5555550), "Year old download should still be present");
   if (minutesSinceMidnight > 250)
-    ok((yield downloadExists(publicList, "fakefile-today")), "'Today' download should still be present");
-
-  downloadPromise = promiseDownloadRemoved(publicList);
+    ok(downloadExists(5555554), "'Today' download should still be present");
 
   // Clear Today
   Sanitizer.prefs.setIntPref("timeSpan", 4);
   s.sanitize();
 
   yield promiseFormHistoryRemoved();
-  yield downloadPromise;
 
   // Be careful.  If we add our objectss just before midnight, and sanitize
   // runs immediately after, they won't be expired.  This is expected, but
   // we should not test in that case.  We cannot just test for opposite
   // condition because we could cross midnight just one moment after we
   // cache our time, then we would have an even worse random failure.
   var today = isToday(new Date(now_uSec/1000));
   if (today) {
     ok(!(yield promiseIsURIVisited(makeURI("http://today.com"))),
        "Pretend visit to today.com should now be deleted");
 
     yield countEntries("today", "today form entry should be deleted", checkZero);
-    ok(!(yield downloadExists(publicList, "fakefile-today")), "'Today' download should now be deleted");
+    ok(!downloadExists(5555554), "'Today' download should now be deleted");
   }
 
   ok((yield promiseIsURIVisited(makeURI("http://before-today.com"))),
      "Pretend visit to before-today.com should still exist");
   yield countEntries("b4today", "b4today form entry should still exist", checkOne);
-  ok((yield downloadExists(publicList, "fakefile-old")), "Year old download should still be present");
-
-  downloadPromise = promiseDownloadRemoved(publicList);
+  ok(downloadExists(5555550), "Year old download should still be present");
 
   // Choose everything
   Sanitizer.prefs.setIntPref("timeSpan", 0);
   s.sanitize();
 
   yield promiseFormHistoryRemoved();
-  yield downloadPromise;
 
   ok(!(yield promiseIsURIVisited(makeURI("http://before-today.com"))),
      "Pretend visit to before-today.com should now be deleted");
 
   yield countEntries("b4today", "b4today form entry should be deleted", checkZero);
 
-  ok(!(yield downloadExists(publicList, "fakefile-old")), "Year old download should now be deleted");
+  ok(!downloadExists(5555550), "Year old download should now be deleted");
 }
 
 function setupHistory() {
   let deferred = Promise.defer();
 
   let places = [];
 
   function addPlace(aURI, aTitle, aVisitDate) {
@@ -600,124 +557,254 @@ function setupFormHistory() {
   yield countEntries("4hour10minutes", "Checking for 4hour10minutes form history entry creation", checkOne);
   yield countEntries("today", "Checking for today form history entry creation", checkOne);
   yield countEntries("b4today", "Checking for b4today form history entry creation", checkOne);
   is(checks, 9, "9 checks made");
 }
 
 function setupDownloads() {
 
-  let publicList = yield Downloads.getPublicDownloadList();
-
-  let download = yield Downloads.createDownload({
+  // Add 10-minutes download to DB
+  let data = {
+    id:   "5555555",
+    name: "fakefile-10-minutes",
     source: "https://bugzilla.mozilla.org/show_bug.cgi?id=480169",
-    target: "fakefile-10-minutes"
-  });
-  download.startTime = new Date(now_uSec - 10 * kUsecPerMin), // 10 minutes ago, in uSec
-  download.canceled = true;
-  publicList.add(download);
+    target: "fakefile-10-minutes",
+    startTime: now_uSec - 10 * kUsecPerMin, // 10 minutes ago, in uSec
+    endTime: now_uSec - 11 * kUsecPerMin, // 1 minute later
+    state: Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
+    currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0,
+    guid: "a1bcD23eF4g5"
+  };
 
-  download = yield Downloads.createDownload({
+  let db = dm.DBConnection;
+  let stmt = db.createStatement(
+    "INSERT INTO moz_downloads (id, name, source, target, startTime, endTime, " +
+      "state, currBytes, maxBytes, preferredAction, autoResume, guid) " +
+    "VALUES (:id, :name, :source, :target, :startTime, :endTime, :state, " +
+      ":currBytes, :maxBytes, :preferredAction, :autoResume, :guid)");
+  try {
+    for (let prop in data)
+      stmt.params[prop] = data[prop];
+    stmt.execute();
+  }
+  finally {
+    stmt.reset();
+  }
+  
+  // Add within-1-hour download to DB
+  data = {
+    id:   "5555551",
+    name: "fakefile-1-hour",
     source: "https://bugzilla.mozilla.org/show_bug.cgi?id=453440",
-    target: "fakefile-1-hour"
-  });
-  download.startTime = new Date(now_uSec - 45 * kUsecPerMin), // 45 minutes ago, in uSec
-  download.canceled = true;
-  publicList.add(download);
+    target: "fakefile-1-hour",
+    startTime: now_uSec - 45 * kUsecPerMin, // 45 minutes ago, in uSec
+    endTime: now_uSec - 44 * kUsecPerMin, // 1 minute later
+    state: Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
+    currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0,
+    guid: "1bcD23eF4g5a"
+  };
 
-  download = yield Downloads.createDownload({
+  try {
+    for (let prop in data)
+      stmt.params[prop] = data[prop];
+    stmt.execute();
+  }
+  finally {
+    stmt.reset();
+  }
+  
+  // Add 1-hour-10-minutes download to DB
+  data = {
+    id:   "5555556",
+    name: "fakefile-1-hour-10-minutes",
     source: "https://bugzilla.mozilla.org/show_bug.cgi?id=480169",
-    target: "fakefile-1-hour-10-minutes"
-  });
-  download.startTime = new Date(now_uSec - 70 * kUsecPerMin), // 70 minutes ago, in uSec
-  download.canceled = true;
-  publicList.add(download);
+    target: "fakefile-1-hour-10-minutes",
+    startTime: now_uSec - 70 * kUsecPerMin, // 70 minutes ago, in uSec
+    endTime: now_uSec - 71 * kUsecPerMin, // 1 minute later
+    state: Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
+    currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0,
+    guid: "a1cbD23e4Fg5"
+  };
 
-  download = yield Downloads.createDownload({
+  try {
+    for (let prop in data)
+      stmt.params[prop] = data[prop];
+    stmt.execute();
+  }
+  finally {
+    stmt.reset();
+  }
+
+  // Add within-2-hour download  
+  data = {
+    id:   "5555552",
+    name: "fakefile-2-hour",
     source: "https://bugzilla.mozilla.org/show_bug.cgi?id=453440",
-    target: "fakefile-2-hour"
-  });
-  download.startTime = new Date(now_uSec - 90 * kUsecPerMin), // 90 minutes ago, in uSec
-  download.canceled = true;
-  publicList.add(download);
+    target: "fakefile-2-hour",
+    startTime: now_uSec - 90 * kUsecPerMin, // 90 minutes ago, in uSec
+    endTime: now_uSec - 89 * kUsecPerMin, // 1 minute later
+    state: Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
+    currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0,
+    guid: "b1aDc23eFg54"
+  };
 
-  download = yield Downloads.createDownload({
+  try {
+    for (let prop in data)
+      stmt.params[prop] = data[prop];
+    stmt.execute();
+  }
+  finally {
+    stmt.reset();
+  }
+  
+  // Add 2-hour-10-minutes download  
+  data = {
+    id:   "5555557",
+    name: "fakefile-2-hour-10-minutes",
     source: "https://bugzilla.mozilla.org/show_bug.cgi?id=480169",
-    target: "fakefile-2-hour-10-minutes"
-  });
-  download.startTime = new Date(now_uSec - 130 * kUsecPerMin), // 130 minutes ago, in uSec
-  download.canceled = true;
-  publicList.add(download);
+    target: "fakefile-2-hour-10-minutes",
+    startTime: now_uSec - 130 * kUsecPerMin, // 130 minutes ago, in uSec
+    endTime: now_uSec - 131 * kUsecPerMin, // 1 minute later
+    state: Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
+    currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0,
+    guid: "z1bcD23eF4g5"
+  };
+
+  try {
+    for (let prop in data)
+      stmt.params[prop] = data[prop];
+    stmt.execute();
+  }
+  finally {
+    stmt.reset();
+  }
 
-  download = yield Downloads.createDownload({
+  // Add within-4-hour download
+  data = {
+    id:   "5555553",
+    name: "fakefile-4-hour",
     source: "https://bugzilla.mozilla.org/show_bug.cgi?id=453440",
-    target: "fakefile-4-hour"
-  });
-  download.startTime = new Date(now_uSec - 180 * kUsecPerMin), // 180 minutes ago, in uSec
-  download.canceled = true;
-  publicList.add(download);
-
-  download = yield Downloads.createDownload({
+    target: "fakefile-4-hour",
+    startTime: now_uSec - 180 * kUsecPerMin, // 180 minutes ago, in uSec
+    endTime: now_uSec - 179 * kUsecPerMin, // 1 minute later
+    state: Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
+    currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0,
+    guid: "zzzcD23eF4g5"
+  };
+  
+  try {
+    for (let prop in data)
+      stmt.params[prop] = data[prop];
+    stmt.execute();
+  }
+  finally {
+    stmt.reset();
+  }
+  
+  // Add 4-hour-10-minutes download
+  data = {
+    id:   "5555558",
+    name: "fakefile-4-hour-10-minutes",
     source: "https://bugzilla.mozilla.org/show_bug.cgi?id=480169",
-    target: "fakefile-4-hour-10-minutes"
-  });
-  download.startTime = new Date(now_uSec - 250 * kUsecPerMin), // 250 minutes ago, in uSec
-  download.canceled = true;
-  publicList.add(download);
+    target: "fakefile-4-hour-10-minutes",
+    startTime: now_uSec - 250 * kUsecPerMin, // 250 minutes ago, in uSec
+    endTime: now_uSec - 251 * kUsecPerMin, // 1 minute later
+    state: Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
+    currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0,
+    guid: "z1bzz23eF4gz"
+  };
+  
+  try {
+    for (let prop in data)
+      stmt.params[prop] = data[prop];
+    stmt.execute();
+  }
+  finally {
+    stmt.reset();
+  }
 
   // Add "today" download
   let today = new Date();
   today.setHours(0);
   today.setMinutes(0);
   today.setSeconds(1);
-
-  download = yield Downloads.createDownload({
+  
+  data = {
+    id:   "5555554",
+    name: "fakefile-today",
     source: "https://bugzilla.mozilla.org/show_bug.cgi?id=453440",
-    target: "fakefile-today"
-  });
-  download.startTime = new Date(today.getTime() * 1000), // 12:00:30am this morning, in uSec
-  download.canceled = true;
-  publicList.add(download);
+    target: "fakefile-today",
+    startTime: today.getTime() * 1000,  // 12:00:30am this morning, in uSec
+    endTime: (today.getTime() + 1000) * 1000, // 1 second later
+    state: Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
+    currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0,
+    guid: "ffffD23eF4g5"
+  };
+  
+  try {
+    for (let prop in data)
+      stmt.params[prop] = data[prop];
+    stmt.execute();
+  }
+  finally {
+    stmt.reset();
+  }
   
   // Add "before today" download
   let lastYear = new Date();
   lastYear.setFullYear(lastYear.getFullYear() - 1);
-
-  download = yield Downloads.createDownload({
+  data = {
+    id:   "5555550",
+    name: "fakefile-old",
     source: "https://bugzilla.mozilla.org/show_bug.cgi?id=453440",
-    target: "fakefile-old"
-  });
-  download.startTime = new Date(lastYear.getTime() * 1000), // 1 year ago, in uSec
-  download.canceled = true;
-  publicList.add(download);
+    target: "fakefile-old",
+    startTime: lastYear.getTime() * 1000, // 1 year ago, in uSec
+    endTime: (lastYear.getTime() + 1000) * 1000, // 1 second later
+    state: Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
+    currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0,
+    guid: "ggggg23eF4g5"
+  };
+  
+  try {
+    for (let prop in data)
+      stmt.params[prop] = data[prop];
+    stmt.execute();
+  }
+  finally {
+    stmt.finalize();
+  }
   
   // Confirm everything worked
-  let downloads = yield publicList.getAll();
-  is(downloads.length, 9, "9 Pretend downloads added");
-
-  ok((yield downloadExists(publicList, "fakefile-old")), "Pretend download for everything case should exist");
-  ok((yield downloadExists(publicList, "fakefile-10-minutes")), "Pretend download for 10-minutes case should exist");
-  ok((yield downloadExists(publicList, "fakefile-1-hour")), "Pretend download for 1-hour case should exist");
-  ok((yield downloadExists(publicList, "fakefile-1-hour-10-minutes")), "Pretend download for 1-hour-10-minutes case should exist");
-  ok((yield downloadExists(publicList, "fakefile-2-hour")), "Pretend download for 2-hour case should exist");
-  ok((yield downloadExists(publicList, "fakefile-2-hour-10-minutes")), "Pretend download for 2-hour-10-minutes case should exist");
-  ok((yield downloadExists(publicList, "fakefile-4-hour")), "Pretend download for 4-hour case should exist");
-  ok((yield downloadExists(publicList, "fakefile-4-hour-10-minutes")), "Pretend download for 4-hour-10-minutes case should exist");
-  ok((yield downloadExists(publicList, "fakefile-today")), "Pretend download for Today case should exist");
+  ok(downloadExists(5555550), "Pretend download for everything case should exist");
+  ok(downloadExists(5555555), "Pretend download for 10-minutes case should exist");
+  ok(downloadExists(5555551), "Pretend download for 1-hour case should exist");
+  ok(downloadExists(5555556), "Pretend download for 1-hour-10-minutes case should exist");
+  ok(downloadExists(5555552), "Pretend download for 2-hour case should exist");
+  ok(downloadExists(5555557), "Pretend download for 2-hour-10-minutes case should exist");
+  ok(downloadExists(5555553), "Pretend download for 4-hour case should exist");
+  ok(downloadExists(5555558), "Pretend download for 4-hour-10-minutes case should exist");
+  ok(downloadExists(5555554), "Pretend download for Today case should exist");
 }
 
 /**
  * Checks to see if the downloads with the specified id exists.
  *
  * @param aID
  *        The ids of the downloads to check.
  */
-function downloadExists(list, path)
+function downloadExists(aID)
 {
-  return Task.spawn(function() {
-    let listArray = yield list.getAll();
-    throw new Task.Result(listArray.some(i => i.target.path == path));
-  });
+  let db = dm.DBConnection;
+  let stmt = db.createStatement(
+    "SELECT * " +
+    "FROM moz_downloads " +
+    "WHERE id = :id"
+  );
+  stmt.params.id = aID;
+  var rows = stmt.executeStep();
+  stmt.finalize();
+  return rows;
 }
 
 function isToday(aDate) {
   return aDate.getDate() == new Date().getDate();
 }
--- a/browser/base/content/test/browser_sanitizeDialog.js
+++ b/browser/base/content/test/browser_sanitizeDialog.js
@@ -16,27 +16,28 @@
  * Some of this code, especially the history creation parts, was taken from
  * browser/base/content/test/browser_sanitize-timespans.js.
  */
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "FormHistory",
                                   "resource://gre/modules/FormHistory.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "Downloads",
-                                  "resource://gre/modules/Downloads.jsm");
 
 let tempScope = {};
 Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader)
                                            .loadSubScript("chrome://browser/content/sanitize.js", tempScope);
 let Sanitizer = tempScope.Sanitizer;
 
+const dm = Cc["@mozilla.org/download-manager;1"].
+           getService(Ci.nsIDownloadManager);
+
 const kUsecPerMin = 60 * 1000000;
 
-let formEntries, downloadIDs, olderDownloadIDs;
+let formEntries;
 
 // Add tests here.  Each is a function that's called by doNextTest().
 var gAllTests = [
 
   /**
    * Initializes the dialog to its default state.
    */
   function () {
@@ -86,33 +87,16 @@ var gAllTests = [
         yield promiseHistoryClearedState(uris, false);
         yield blankSlate();
         yield promiseHistoryClearedState(uris, true);
       };
       wh.open();
     });
   },
 
-  function () {
-    // Add downloads (within the past hour).
-    Task.spawn(function () {
-      downloadIDs = [];
-      for (let i = 0; i < 5; i++) {
-        yield addDownloadWithMinutesAgo(downloadIDs, i);
-      }
-      // Add downloads (over an hour ago).
-      olderDownloadIDs = [];
-      for (let i = 0; i < 5; i++) {
-        yield addDownloadWithMinutesAgo(olderDownloadIDs, 61 + i);
-      }
-
-      doNextTest();
-    }).then(null, Components.utils.reportError);
-  },
-
   /**
    * Ensures that the combined history-downloads checkbox clears both history
    * visits and downloads when checked; the dialog respects simple timespan.
    */
   function () {
     // Add history (within the past hour).
     let uris = [];
     let places = [];
@@ -126,16 +110,26 @@ var gAllTests = [
     let olderURIs = [];
     for (let i = 0; i < 5; i++) {
       pURI = makeURI("http://" + (61 + i) + "-minutes-ago.com/");
       places.push({uri: pURI, visitDate: visitTimeForMinutesAgo(61 + i)});
       olderURIs.push(pURI);
     }
 
     addVisits(places, function() {
+      // Add downloads (within the past hour).
+      let downloadIDs = [];
+      for (let i = 0; i < 5; i++) {
+        downloadIDs.push(addDownloadWithMinutesAgo(i));
+      }
+      // Add downloads (over an hour ago).
+      let olderDownloadIDs = [];
+      for (let i = 0; i < 5; i++) {
+        olderDownloadIDs.push(addDownloadWithMinutesAgo(61 + i));
+      }
       let totalHistoryVisits = uris.length + olderURIs.length;
 
       let wh = new WindowHelper();
       wh.onload = function () {
         this.selectDuration(Sanitizer.TIMESPAN_HOUR);
         this.checkPrefCheckbox("history", true);
         this.acceptDialog();
 
@@ -147,26 +141,26 @@ var gAllTests = [
                    "history checkbox checked");
         boolPrefIs("cpd.downloads", true,
                    "downloads pref should be true after accepting dialog with " +
                    "history checkbox checked");
       };
       wh.onunload = function () {
         // History visits and downloads within one hour should be cleared.
         yield promiseHistoryClearedState(uris, true);
-        yield ensureDownloadsClearedState(downloadIDs, true);
+        ensureDownloadsClearedState(downloadIDs, true);
 
         // Visits and downloads > 1 hour should still exist.
         yield promiseHistoryClearedState(olderURIs, false);
-        yield ensureDownloadsClearedState(olderDownloadIDs, false);
+        ensureDownloadsClearedState(olderDownloadIDs, false);
 
         // OK, done, cleanup after ourselves.
         yield blankSlate();
         yield promiseHistoryClearedState(olderURIs, true);
-        yield ensureDownloadsClearedState(olderDownloadIDs, true);
+        ensureDownloadsClearedState(olderDownloadIDs, true);
       };
       wh.open();
     });
   },
 
   /**
    * Add form history entries for the next test.
    */
@@ -179,44 +173,37 @@ var gAllTests = [
         yield undefined;
       }
       doNextTest();
     }();
 
     iter.next();
   },
 
-  function () {
-    // Add downloads (within the past hour).
-    Task.spawn(function () {
-      downloadIDs = [];
-      for (let i = 0; i < 5; i++) {
-        yield addDownloadWithMinutesAgo(downloadIDs, i);
-      }
-
-      doNextTest();
-    }).then(null, Components.utils.reportError);
-  },
-
   /**
    * Ensures that the combined history-downloads checkbox removes neither
    * history visits nor downloads when not checked.
    */
   function () {
     // Add history, downloads, form entries (within the past hour).
     let uris = [];
     let places = [];
     let pURI;
     for (let i = 0; i < 5; i++) {
       pURI = makeURI("http://" + i + "-minutes-ago.com/");
       places.push({uri: pURI, visitDate: visitTimeForMinutesAgo(i)});
       uris.push(pURI);
     }
 
     addVisits(places, function() {
+      let downloadIDs = [];
+      for (let i = 0; i < 5; i++) {
+        downloadIDs.push(addDownloadWithMinutesAgo(i));
+      }
+
       let wh = new WindowHelper();
       wh.onload = function () {
         is(this.isWarningPanelVisible(), false,
            "Warning panel should be hidden after previously accepting dialog " +
            "with a predefined timespan");
         this.selectDuration(Sanitizer.TIMESPAN_HOUR);
 
         // Remove only form entries, leave history (including downloads).
@@ -232,27 +219,27 @@ var gAllTests = [
                    "history checkbox unchecked");
         boolPrefIs("cpd.downloads", false,
                    "downloads pref should be false after accepting dialog with " +
                    "history checkbox unchecked");
       };
       wh.onunload = function () {
         // Of the three only form entries should be cleared.
         yield promiseHistoryClearedState(uris, false);
-        yield ensureDownloadsClearedState(downloadIDs, false);
+        ensureDownloadsClearedState(downloadIDs, false);
 
         formEntries.forEach(function (entry) {
           let exists = yield formNameExists(entry);
           is(exists, false, "form entry " + entry + " should no longer exist");
         });
 
         // OK, done, cleanup after ourselves.
         yield blankSlate();
         yield promiseHistoryClearedState(uris, true);
-        yield ensureDownloadsClearedState(downloadIDs, true);
+        ensureDownloadsClearedState(downloadIDs, true);
       };
       wh.open();
     });
   },
 
   /**
    * Ensures that the "Everything" duration option works.
    */
@@ -647,16 +634,20 @@ var gAllTests = [
       var pm = Cc["@mozilla.org/permissionmanager;1"]
                .getService(Ci.nsIPermissionManager);
       is(pm.testPermissionFromPrincipal(principal, "offline-app"), 0, "offline-app permissions removed");
     };
     wh.open();
   }
 ];
 
+// Used as the download database ID for a new download.  Incremented for each
+// new download.  See addDownloadWithMinutesAgo().
+var gDownloadId = 5555551;
+
 // Index in gAllTests of the test currently being run.  Incremented for each
 // test run.  See doNextTest().
 var gCurrTest = 0;
 
 var now_uSec = Date.now() * 1000;
 
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -851,17 +842,17 @@ WindowHelper.prototype = {
 
         executeSoon(function () {
           // Some exceptions that reach here don't reach the test harness, but
           // ok()/is() do...
           try {
             if (wh.onunload) {
               Task.spawn(wh.onunload).then(function() {
                 waitForAsyncUpdates(doNextTest);
-              }).then(null, Components.utils.reportError);
+              });
             } else {
               waitForAsyncUpdates(doNextTest);
             }
           }
           catch (exc) {
             win.close();
             ok(false, "Unexpected exception: " + exc + "\n" + exc.stack);
             finish();
@@ -904,33 +895,50 @@ WindowHelper.prototype = {
 };
 
 /**
  * Adds a download to history.
  *
  * @param aMinutesAgo
  *        The download will be downloaded this many minutes ago
  */
-function addDownloadWithMinutesAgo(aExpectedPathList, aMinutesAgo) {
-  let publicList = yield Downloads.getPublicDownloadList();
-
+function addDownloadWithMinutesAgo(aMinutesAgo) {
   let name = "fakefile-" + aMinutesAgo + "-minutes-ago";
-  let download = yield Downloads.createDownload({
-    source: "https://bugzilla.mozilla.org/show_bug.cgi?id=480169",
-    target: name
-  });
-  download.startTime = now_uSec - (aMinutesAgo * kUsecPerMin);
-  download.canceled = true;
-  publicList.add(download);
+  let data = {
+    id:        gDownloadId,
+    name:      name,
+    source:   "https://bugzilla.mozilla.org/show_bug.cgi?id=480169",
+    target:    name,
+    startTime: now_uSec - (aMinutesAgo * kUsecPerMin),
+    endTime:   now_uSec - ((aMinutesAgo + 1) * kUsecPerMin),
+    state:     Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
+    currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0
+  };
 
-  ok((yield downloadExists(name)),
-     "Sanity check: download " + name +
+  let db = dm.DBConnection;
+  let stmt = db.createStatement(
+    "INSERT INTO moz_downloads (id, name, source, target, startTime, endTime, " +
+      "state, currBytes, maxBytes, preferredAction, autoResume) " +
+    "VALUES (:id, :name, :source, :target, :startTime, :endTime, :state, " +
+      ":currBytes, :maxBytes, :preferredAction, :autoResume)");
+  try {
+    for (let prop in data) {
+      stmt.params[prop] = data[prop];
+    }
+    stmt.execute();
+  }
+  finally {
+    stmt.reset();
+  }
+
+  is(downloadExists(gDownloadId), true,
+     "Sanity check: download " + gDownloadId +
      " should exist after creating it");
 
-  aExpectedPathList.push(name);
+  return gDownloadId++;
 }
 
 /**
  * Adds a form entry to history.
  *
  * @param aMinutesAgo
  *        The entry will be added this many minutes ago
  */
@@ -971,47 +979,25 @@ function formNameExists(name)
   return deferred.promise;
 }
 
 /**
  * Removes all history visits, downloads, and form entries.
  */
 function blankSlate() {
   PlacesUtils.bhistory.removeAllPages();
-
-  // The promise is resolved only when removing both downloads and form history are done.
-  let deferred = Promise.defer();
-  let formHistoryDone = false, downloadsDone = false;
+  dm.cleanUp();
 
-  Task.spawn(function deleteAllDownloads() {
-    let publicList = yield Downloads.getPublicDownloadList();
-    let downloads = yield publicList.getAll();
-    for (let download of downloads) {
-      publicList.remove(download);
-      yield download.finalize(true);
-    }
-    downloadsDone = true;
-    if (formHistoryDone) {
-      deferred.resolve();
-    }
-  }).then(null, Components.utils.reportError);
-
+  let deferred = Promise.defer();
   FormHistory.update({ op: "remove" },
                      { handleError: function (error) {
                          do_throw("Error occurred updating form history: " + error);
                          deferred.reject(error);
                        },
-                       handleCompletion: function (reason) {
-                         if (!reason) {
-                           formHistoryDone = true;
-                           if (downloadsDone) {
-                             deferred.resolve();
-                           }
-                         }
-                       }
+                       handleCompletion: function (reason) { if (!reason) deferred.resolve(); }
                      });
   return deferred.promise;
 }
 
 /**
  * Ensures that the given pref is the expected value.
  *
  * @param aPrefName
@@ -1021,29 +1007,34 @@ function blankSlate() {
  * @param aMsg
  *        Passed to is()
  */
 function boolPrefIs(aPrefName, aExpectedVal, aMsg) {
   is(gPrefService.getBoolPref("privacy." + aPrefName), aExpectedVal, aMsg);
 }
 
 /**
- * Checks to see if the download with the specified path exists.
+ * Checks to see if the download with the specified ID exists.
  *
- * @param  aPath
- *         The path of the download to check
+ * @param  aID
+ *         The ID of the download to check
  * @return True if the download exists, false otherwise
  */
-function downloadExists(aPath)
+function downloadExists(aID)
 {
-  return Task.spawn(function() {
-    let publicList = yield Downloads.getPublicDownloadList();
-    let listArray = yield publicList.getAll();
-    throw new Task.Result(listArray.some(i => i.target.path == aPath));
-  });
+  let db = dm.DBConnection;
+  let stmt = db.createStatement(
+    "SELECT * " +
+    "FROM moz_downloads " +
+    "WHERE id = :id"
+  );
+  stmt.params.id = aID;
+  let rows = stmt.executeStep();
+  stmt.finalize();
+  return !!rows;
 }
 
 /**
  * Runs the next test in the gAllTests array.  If all tests have been run,
  * finishes the entire suite.
  */
 function doNextTest() {
   if (gAllTests.length <= gCurrTest) {
@@ -1063,17 +1054,17 @@ function doNextTest() {
  * @param aDownloadIDs
  *        Array of download database IDs
  * @param aShouldBeCleared
  *        True if each download should be cleared, false otherwise
  */
 function ensureDownloadsClearedState(aDownloadIDs, aShouldBeCleared) {
   let niceStr = aShouldBeCleared ? "no longer" : "still";
   aDownloadIDs.forEach(function (id) {
-    is((yield downloadExists(id)), !aShouldBeCleared,
+    is(downloadExists(id), !aShouldBeCleared,
        "download " + id + " should " + niceStr + " exist");
   });
 }
 
 /**
  * Ensures that the given pref is the expected value.
  *
  * @param aPrefName