Bug 1089691 - Convert consumers of removePagesByTimeframe and removePagesFromHost to PlacesUtils.history.removeByFilter. r=mak draft
authorjakehm <jacob.harrowmortelliti@maine.edu>
Sun, 25 Feb 2018 14:27:03 -0500
changeset 792542 da8c9df153a2358a339ada1b82850fba55c42913
parent 792158 a1f3f0cdd430dfbe1dfebff9707b3f962ce71b7f
push id109130
push usermak77@bonardo.net
push dateTue, 08 May 2018 14:41:44 +0000
reviewersmak
bugs1089691
milestone61.0a1
Bug 1089691 - Convert consumers of removePagesByTimeframe and removePagesFromHost to PlacesUtils.history.removeByFilter. r=mak MozReview-Commit-ID: HevUcwPhYhd
browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js
browser/components/places/content/controller.js
browser/components/places/tests/chrome/test_bug549192.xul
services/sync/tps/extensions/tps/resource/modules/history.jsm
toolkit/components/places/tests/favicons/test_root_icons.js
toolkit/components/places/tests/unit/test_415757.js
toolkit/components/places/tests/unit/test_browserhistory.js
toolkit/components/places/tests/unit/test_frecency_observers.js
toolkit/components/places/tests/unit/test_history_sidebar.js
toolkit/components/places/tests/unit/test_nsINavHistoryViewer.js
toolkit/forgetaboutsite/ForgetAboutSite.jsm
--- a/browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js
+++ b/browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js
@@ -206,17 +206,17 @@ async function test_image_cache_cleared(
 
   // Check that image cache works with the userContextId.
   is(gHits, expectedHits, "The image should be loaded" + expectedHits + "times.");
 
   // Reset the cache count.
   gHits = 0;
 
   // Forget the site.
-  await ForgetAboutSite.removeDataFromDomain("localhost:" + gHttpServer.identity.primaryPort + "/");
+  await ForgetAboutSite.removeDataFromDomain("localhost");
 
   // Load again.
   for (let userContextId of Object.keys(USER_CONTEXTS)) {
     // Open our tab in the given user context to cache image.
     tabs[userContextId] = await openTabInUserContext("http://localhost:" + gHttpServer.identity.primaryPort + "/loadImage.html",
                                                       userContextId);
     BrowserTestUtils.removeTab(tabs[userContextId].tab);
   }
--- a/browser/components/places/content/controller.js
+++ b/browser/components/places/content/controller.js
@@ -815,26 +815,26 @@ PlacesController.prototype = {
         let tag = node.title;
         let URIs = PlacesUtils.tagging.getURIsForTag(tag);
         transactions.push(PlacesTransactions.Untag({ tag, urls: URIs }));
       } else if (PlacesUtils.nodeIsURI(node) &&
                  PlacesUtils.nodeIsQuery(node.parent) &&
                  PlacesUtils.asQuery(node.parent).queryOptions.queryType ==
                    Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY) {
         // This is a uri node inside an history query.
-        PlacesUtils.history.remove(node.uri).catch(Cu.reportError);
+        await PlacesUtils.history.remove(node.uri).catch(Cu.reportError);
         // History deletes are not undoable, so we don't have a transaction.
       } else if (node.itemId == -1 &&
                  PlacesUtils.nodeIsQuery(node) &&
                  PlacesUtils.asQuery(node).queryOptions.queryType ==
                    Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY) {
         // This is a dynamically generated history query, like queries
         // grouped by site, time or both.  Dynamically generated queries don't
         // have an itemId even if they are descendants of a bookmark.
-        this._removeHistoryContainer(node);
+        await this._removeHistoryContainer(node).catch(Cu.reportError);
         // History deletes are not undoable, so we don't have a transaction.
       } else {
         // This is a common bookmark item.
         if (PlacesUtils.nodeIsFolder(node)) {
           // If this is a folder we add it to our array of folders, used
           // to skip nodes that are children of an already removed folder.
           removedFolders.push(node);
         }
@@ -864,56 +864,65 @@ PlacesController.prototype = {
     }
   },
 
   /**
    * Removes the set of selected ranges from history, asynchronously.
    *
    * @note history deletes are not undoable.
    */
-  _removeRowsFromHistory: function PC__removeRowsFromHistory() {
+  async _removeRowsFromHistory() {
     let nodes = this._view.selectedNodes;
     let URIs = new Set();
     for (let i = 0; i < nodes.length; ++i) {
       let node = nodes[i];
       if (PlacesUtils.nodeIsURI(node)) {
         URIs.add(node.uri);
       } else if (PlacesUtils.nodeIsQuery(node) &&
                PlacesUtils.asQuery(node).queryOptions.queryType ==
                  Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY) {
-        this._removeHistoryContainer(node);
+        await this._removeHistoryContainer(node).catch(Cu.reportError);
       }
     }
 
-    PlacesUtils.history.remove([...URIs]).catch(Cu.reportError);
+    if (URIs.size) {
+      await PlacesUtils.history.remove([...URIs]);
+    }
   },
 
   /**
    * Removes history visits for an history container node.
    * @param   [in] aContainerNode
    *          The container node to remove.
    *
    * @note history deletes are not undoable.
    */
-  _removeHistoryContainer: function PC__removeHistoryContainer(aContainerNode) {
+  async _removeHistoryContainer(aContainerNode) {
     if (PlacesUtils.nodeIsHost(aContainerNode)) {
-      // Site container.
-      PlacesUtils.history.removePagesFromHost(aContainerNode.title, true);
+      // This is a site container.
+      // Check if it's the container for local files (don't be fooled by the
+      // bogus string name, this is "(local files)").
+      let host = "." + (aContainerNode.title == PlacesUtils.getString("localhost") ?
+                          "" : aContainerNode.title);
+      await PlacesUtils.history.removeByFilter({host});
     } else if (PlacesUtils.nodeIsDay(aContainerNode)) {
-      // Day container.
+      // This is a day container.
       let query = aContainerNode.query;
       let beginTime = query.beginTime;
       let endTime = query.endTime;
       if (!query || !beginTime || !endTime)
         throw new Error("A valid date container query should exist!");
       // We want to exclude beginTime from the removal because
       // removePagesByTimeframe includes both extremes, while date containers
       // exclude the lower extreme.  So, if we would not exclude it, we would
       // end up removing more history than requested.
-      PlacesUtils.history.removePagesByTimeframe(beginTime + 1, endTime);
+      await PlacesUtils.history.removeByFilter({
+        beginDate: PlacesUtils.toDate(beginTime + 1000),
+        endDate: PlacesUtils.toDate(endTime)
+      });
     }
   },
 
   /**
    * Removes the selection
    */
   async remove() {
     if (!this._hasRemovableSelection())
@@ -923,22 +932,23 @@ PlacesController.prototype = {
 
     if (PlacesUtils.nodeIsFolder(root)) {
       await this._removeRowsFromBookmarks();
     } else if (PlacesUtils.nodeIsQuery(root)) {
       var queryType = PlacesUtils.asQuery(root).queryOptions.queryType;
       if (queryType == Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS) {
         await this._removeRowsFromBookmarks();
       } else if (queryType == Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY) {
-        this._removeRowsFromHistory();
+        await this._removeRowsFromHistory();
       } else {
         throw new Error("implement support for QUERY_TYPE_UNIFIED");
       }
-    } else
+    } else {
       throw new Error("unexpected root");
+    }
   },
 
   /**
    * Fills a DataTransfer object with the content of the selection that can be
    * dropped elsewhere.
    * @param   aEvent
    *          The dragstart event.
    */
--- a/browser/components/places/tests/chrome/test_bug549192.xul
+++ b/browser/components/places/tests/chrome/test_bug549192.xul
@@ -35,59 +35,38 @@
   <script type="application/javascript"><![CDATA[
     /**
      * Bug 874407
      * Ensures that history views are updated properly after visits.
      * Bug 549192
      * Ensures that history views are updated after deleting entries.
      */
 
-    function promiseURIDeleted() {
-     return new Promise(resolve => {
-       let historyObserver = {
-         onBeginUpdateBatch: function PEX_onBeginUpdateBatch() {},
-         onEndUpdateBatch: function PEX_onEndUpdateBatch() {},
-         onClearHistory() {},
-         onVisits() {},
-         onTitleChanged() {},
-         onDeleteURI(aURI, aGUID, aReason) {
-           PlacesUtils.history.removeObserver(historyObserver);
-           resolve();
-         },
-         onPageChanged() {},
-         onDeleteVisits(aURI, aTime) { },
-       };
-
-       PlacesUtils.history.addObserver(historyObserver);
-     });
-    }
-
     function runTest() {
       SimpleTest.waitForExplicitFinish();
 
       (async function() {
         await PlacesUtils.history.clear();
 
         // Add some visits.
         let timeInMicroseconds = PlacesUtils.toPRTime(Date.now() - 10000);
 
         function newTimeInMicroseconds() {
           timeInMicroseconds = timeInMicroseconds + 1000;
           return timeInMicroseconds;
         }
 
-        let vtime = Date.now() * 1000;
-        const ttype = PlacesUtils.history.TRANSITION_TYPED;
+        const transition = PlacesUtils.history.TRANSITIONS.TYPED;
         let places =
           [{ uri: Services.io.newURI("http://example.tld/"),
-             visitDate: newTimeInMicroseconds(), transition: ttype },
+             visitDate: newTimeInMicroseconds(), transition },
            { uri: Services.io.newURI("http://example2.tld/"),
-             visitDate: newTimeInMicroseconds(), transition: ttype },
+             visitDate: newTimeInMicroseconds(), transition },
            { uri: Services.io.newURI("http://example3.tld/"),
-             visitDate: newTimeInMicroseconds(), transition: ttype }];
+             visitDate: newTimeInMicroseconds(), transition }];
 
         await PlacesTestUtils.addVisits(places);
 
         // Make a history query.
         let query = PlacesUtils.history.getNewQuery();
         let opts = PlacesUtils.history.getNewQueryOptions();
         opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
         let queryURI = PlacesUtils.history.queryToQueryString(query, opts);
@@ -120,18 +99,19 @@
           is(node.uri, places[rc - i - 1].uri.spec,
              "Found expected node at position " + i + ".");
         }
 
         // Now remove the pages and verify live-update again.
         for (let i = 0; i < rc; i++) {
           selection.select(0);
           let node = tree.selectedNode;
-          let promiseDeleted = promiseURIDeleted();
-          tree.controller.remove("Removing page");
+          let promiseDeleted = PlacesTestUtils.waitForNotification("onDeleteURI",
+            uri => uri.spec == node.uri, "history");
+          tree.controller.remove();
           await promiseDeleted;
           ok(treeView.treeIndexForNode(node) == -1, node.uri + " removed.");
           is(treeView.rowCount, rc - i - 1, "Rows count decreased");
         }
 
         // Cleanup.
         await PlacesUtils.history.clear();
       })().then(() => SimpleTest.finish());
--- a/services/sync/tps/extensions/tps/resource/modules/history.jsm
+++ b/services/sync/tps/extensions/tps/resource/modules/history.jsm
@@ -115,17 +115,17 @@ var HistoryEntry = {
    */
   async Delete(item, msSinceEpoch) {
     if ("uri" in item) {
       let removedAny = await PlacesUtils.history.remove(item.uri);
       if (!removedAny) {
         Logger.log("Warning: Removed 0 history visits for uri " + item.uri);
       }
     } else if ("host" in item) {
-      await PlacesUtils.history.removePagesFromHost(item.host, false);
+      await PlacesUtils.history.removeByFilter({ host: item.host });
     } else if ("begin" in item && "end" in item) {
       let filter = {
         beginDate: new Date(msSinceEpoch + (item.begin * 60 * 60 * 1000)),
         endDate: new Date(msSinceEpoch + (item.end * 60 * 60 * 1000))
       };
       let removedAny = await PlacesUtils.history.removeVisitsByFilter(filter);
       if (!removedAny) {
         Logger.log("Warning: Removed 0 history visits with " + JSON.stringify({ item, filter }));
--- a/toolkit/components/places/tests/favicons/test_root_icons.js
+++ b/toolkit/components/places/tests/favicons/test_root_icons.js
@@ -60,33 +60,36 @@ add_task(async function test_removePages
   // Sanity checks.
   Assert.equal(await getFaviconUrlForPage(pageURI),
                faviconURI.spec, "Should get the biggest icon");
   Assert.equal(await getFaviconUrlForPage(pageURI, 1),
                rootIconURI.spec, "Should get the smallest icon");
   Assert.equal(await getFaviconUrlForPage("http://www.places.test/old/"),
                rootIconURI.spec, "Should get the root icon");
 
-  PlacesUtils.history.removePagesByTimeframe(
-    PlacesUtils.toPRTime(Date.now() - 14400000),
-    PlacesUtils.toPRTime(new Date())
-  );
+  await PlacesUtils.history.removeByFilter({
+    beginDate: new Date(Date.now() - 14400000),
+    endDate: new Date()
+  });
 
   // Check database entries.
   await PlacesTestUtils.promiseAsyncUpdates();
   let db = await PlacesUtils.promiseDBConnection();
   let rows = await db.execute("SELECT * FROM moz_icons");
   Assert.equal(rows.length, 1, "There should only be 1 icon entry");
   Assert.equal(rows[0].getResultByName("root"), 1, "It should be marked as a root icon");
   rows = await db.execute("SELECT * FROM moz_pages_w_icons");
   Assert.equal(rows.length, 0, "There should be no page entry");
   rows = await db.execute("SELECT * FROM moz_icons_to_pages");
   Assert.equal(rows.length, 0, "There should be no relation entry");
 
-  PlacesUtils.history.removePagesByTimeframe(0, PlacesUtils.toPRTime(new Date()));
+  await PlacesUtils.history.removeByFilter({
+    beginDate: new Date(0),
+    endDt: new Date()
+  });
   await PlacesTestUtils.promiseAsyncUpdates();
   rows = await db.execute("SELECT * FROM moz_icons");
   // Debug logging for possible intermittent failure (bug 1358368).
   if (rows.length != 0) {
     dump_table("moz_icons");
     dump_table("moz_hosts");
   }
   Assert.equal(rows.length, 0, "There should be no icon entry");
--- a/toolkit/components/places/tests/unit/test_415757.js
+++ b/toolkit/components/places/tests/unit/test_415757.js
@@ -57,17 +57,17 @@ add_task(async function test_execute() {
   var testAnnoRetainedName = "foo";
   var testAnnoRetainedValue = "bar";
   PlacesUtils.annotations.setPageAnnotation(testAnnoRetainedURI,
                                             testAnnoRetainedName,
                                             testAnnoRetainedValue, 0,
                                             PlacesUtils.annotations.EXPIRE_WITH_HISTORY);
 
   // remove pages from www.test.com
-  PlacesUtils.history.removePagesFromHost("www.test.com", false);
+  await PlacesUtils.history.removeByFilter({ host: "www.test.com" });
 
   // check that all pages in www.test.com have been removed
   for (let i = 0; i < TOTAL_SITES; i++) {
     let site = "http://www.test.com/" + i + "/";
     let testURI = uri(site);
     Assert.ok(!uri_in_db(testURI));
   }
 
--- a/toolkit/components/places/tests/unit/test_browserhistory.js
+++ b/toolkit/components/places/tests/unit/test_browserhistory.js
@@ -69,38 +69,44 @@ add_task(async function test_removePages
       uri: NetUtil.newURI(TEST_URI.spec + i),
       visitDate: startDate + i * 1000
     });
   }
 
   await PlacesTestUtils.addVisits(visits);
 
   // Delete all pages except the first and the last.
-  PlacesUtils.history.removePagesByTimeframe(startDate + 1000, startDate + 8000);
+  await PlacesUtils.history.removeByFilter({
+    beginDate: PlacesUtils.toDate(startDate + 1000),
+    endDate: PlacesUtils.toDate(startDate + 8000)
+  });
 
   // Check that we have removed the correct pages.
   for (let i = 0; i < 10; i++) {
     Assert.equal(page_in_database(NetUtil.newURI(TEST_URI.spec + i)) == 0,
                  i > 0 && i < 9);
   }
 
   // Clear remaining items and check that all pages have been removed.
-  PlacesUtils.history.removePagesByTimeframe(startDate, startDate + 9000);
+  await PlacesUtils.history.removeByFilter({
+    beginDate: PlacesUtils.toDate(startDate),
+    endDate: PlacesUtils.toDate(startDate + 9000)
+  });
   Assert.equal(0, PlacesUtils.history.hasHistoryEntries);
 });
 
 add_task(async function test_removePagesFromHost() {
   await PlacesTestUtils.addVisits(TEST_URI);
-  PlacesUtils.history.removePagesFromHost("mozilla.com", true);
+  await PlacesUtils.history.removeByFilter({ host: ".mozilla.com" });
   Assert.equal(0, PlacesUtils.history.hasHistoryEntries);
 });
 
 add_task(async function test_removePagesFromHost_keepSubdomains() {
   await PlacesTestUtils.addVisits([{ uri: TEST_URI }, { uri: TEST_SUBDOMAIN_URI }]);
-  PlacesUtils.history.removePagesFromHost("mozilla.com", false);
+  await PlacesUtils.history.removeByFilter({ host: "mozilla.com" });
   Assert.equal(1, PlacesUtils.history.hasHistoryEntries);
 });
 
 add_task(async function test_history_clear() {
   await PlacesUtils.history.clear();
   Assert.equal(0, PlacesUtils.history.hasHistoryEntries);
 });
 
--- a/toolkit/components/places/tests/unit/test_frecency_observers.js
+++ b/toolkit/components/places/tests/unit/test_frecency_observers.js
@@ -27,25 +27,26 @@ add_task(async function test_nsNavHistor
   });
   await promise;
 });
 
 // nsNavHistory::invalidateFrecencies for particular pages
 add_task(async function test_nsNavHistory_invalidateFrecencies_somePages() {
   let url = Services.io.newURI("http://test-nsNavHistory-invalidateFrecencies-somePages.com/");
   // Bookmarking the URI is enough to add it to moz_places, and importantly, it
-  // means that removePagesFromHost doesn't remove it from moz_places, so its
+  // means that removeByFilter doesn't remove it from moz_places, so its
   // frecency is able to be changed.
   await PlacesUtils.bookmarks.insert({
     parentGuid: PlacesUtils.bookmarks.unfiledGuid,
     url,
     title: "test"
   });
-  PlacesUtils.history.removePagesFromHost(url.host, false);
-  await onFrecencyChanged(url);
+  let promise = onFrecencyChanged(url);
+  await PlacesUtils.history.removeByFilter({ host: url.host });
+  await promise;
 });
 
 // nsNavHistory::invalidateFrecencies for all pages
 add_task(async function test_nsNavHistory_invalidateFrecencies_allPages() {
   await Promise.all([onManyFrecenciesChanged(), PlacesUtils.history.clear()]);
 });
 
 // nsNavHistory::DecayFrecency and nsNavHistory::FixInvalidFrecencies
--- a/toolkit/components/places/tests/unit/test_history_sidebar.js
+++ b/toolkit/components/places/tests/unit/test_history_sidebar.js
@@ -364,17 +364,20 @@ async function task_test_date_liveupdate
   options.resultType = aResultType;
   var query = hs.getNewQuery();
   var result = hs.executeQuery(query, options);
   var root = result.root;
   root.containerOpen = true;
 
   Assert.equal(root.childCount, visibleContainers.length);
   // Remove "Today".
-  hs.removePagesByTimeframe(midnight.getTime() * 1000, Date.now() * 1000);
+  await PlacesUtils.history.removeByFilter({
+    beginDate: new Date(midnight.getTime()),
+    endDate: new Date(Date.now())
+  });
   Assert.equal(root.childCount, visibleContainers.length - 1);
 
   // Open "Last 7 days" container, this way we will have a container accepting
   // the new visit, but we should still add back "Today" container.
   var last7Days = root.getChild(1)
                       .QueryInterface(Ci.nsINavHistoryContainerResultNode);
   last7Days.containerOpen = true;
 
@@ -401,17 +404,20 @@ async function task_test_date_liveupdate
   root = result.root;
   root.containerOpen = true;
   Assert.equal(root.childCount, 1);
   var dateContainer = root.getChild(0).QueryInterface(Ci.nsINavHistoryContainerResultNode);
   dateContainer.containerOpen = true;
 
   Assert.equal(dateContainer.childCount, visibleContainers.length);
   // Remove "Today".
-  hs.removePagesByTimeframe(midnight.getTime() * 1000, Date.now() * 1000);
+  await PlacesUtils.history.removeByFilter({
+    beginDate: new Date(midnight.getTime()),
+    endDate: new Date(Date.now())
+  });
   Assert.equal(dateContainer.childCount, visibleContainers.length - 1);
   // Add a visit for "Today".
   await task_add_normalized_visit(uri("http://www.mozilla.org/"), nowObj.getTime(), 0);
   Assert.equal(dateContainer.childCount, visibleContainers.length);
 
   dateContainer.containerOpen = false;
   root.containerOpen = false;
 
--- a/toolkit/components/places/tests/unit/test_nsINavHistoryViewer.js
+++ b/toolkit/components/places/tests/unit/test_nsINavHistoryViewer.js
@@ -72,108 +72,105 @@ var resultObserver = {
     this.closedContainer = null;
     this.invalidatedContainer = null;
     this.sortingMode = null;
   }
 };
 
 var testURI = uri("http://mozilla.com");
 
-add_test(function check_history_query() {
-  var options = PlacesUtils.history.getNewQueryOptions();
+add_task(async function check_history_query() {
+  let options = PlacesUtils.history.getNewQueryOptions();
   options.sortingMode = options.SORT_BY_DATE_DESCENDING;
   options.resultType = options.RESULTS_AS_VISIT;
-  var query = PlacesUtils.history.getNewQuery();
-  var result = PlacesUtils.history.executeQuery(query, options);
+  let query = PlacesUtils.history.getNewQuery();
+  let result = PlacesUtils.history.executeQuery(query, options);
   result.addObserver(resultObserver);
-  var root = result.root;
+  let root = result.root;
   root.containerOpen = true;
 
   Assert.notEqual(resultObserver.openedContainer, null);
 
   // nsINavHistoryResultObserver.nodeInserted
   // add a visit
-  PlacesTestUtils.addVisits(testURI).then(function() {
-    Assert.equal(testURI.spec, resultObserver.insertedNode.uri);
+  await PlacesTestUtils.addVisits(testURI);
+  Assert.equal(testURI.spec, resultObserver.insertedNode.uri);
 
-    // nsINavHistoryResultObserver.nodeHistoryDetailsChanged
-    // adding a visit causes nodeHistoryDetailsChanged for the folder
-    Assert.equal(root.uri, resultObserver.nodeChangedByHistoryDetails.uri);
+  // nsINavHistoryResultObserver.nodeHistoryDetailsChanged
+  // adding a visit causes nodeHistoryDetailsChanged for the folder
+  Assert.equal(root.uri, resultObserver.nodeChangedByHistoryDetails.uri);
 
-    // nsINavHistoryResultObserver.itemTitleChanged for a leaf node
-    PlacesTestUtils.addVisits({ uri: testURI, title: "baz" }).then(function() {
-      Assert.equal(resultObserver.nodeChangedByTitle.title, "baz");
+  // nsINavHistoryResultObserver.itemTitleChanged for a leaf node
+  await PlacesTestUtils.addVisits({ uri: testURI, title: "baz" });
+  Assert.equal(resultObserver.nodeChangedByTitle.title, "baz");
 
-      // nsINavHistoryResultObserver.nodeRemoved
-      var removedURI = uri("http://google.com");
-      PlacesTestUtils.addVisits(removedURI).then(function() {
-        return PlacesUtils.history.remove(removedURI);
-      }).then(function() {
-        Assert.equal(removedURI.spec, resultObserver.removedNode.uri);
+  // nsINavHistoryResultObserver.nodeRemoved
+  let removedURI = uri("http://google.com");
+  await PlacesTestUtils.addVisits(removedURI);
+  await PlacesUtils.history.remove(removedURI);
+  Assert.equal(removedURI.spec, resultObserver.removedNode.uri);
 
-        // nsINavHistoryResultObserver.invalidateContainer
-        PlacesUtils.history.removePagesFromHost("mozilla.com", false);
-        Assert.equal(root.uri, resultObserver.invalidatedContainer.uri);
-
-        // nsINavHistoryResultObserver.sortingChanged
-        resultObserver.invalidatedContainer = null;
-        result.sortingMode = options.SORT_BY_TITLE_ASCENDING;
-        Assert.equal(resultObserver.sortingMode, options.SORT_BY_TITLE_ASCENDING);
-        Assert.equal(resultObserver.invalidatedContainer, result.root);
+  // nsINavHistoryResultObserver.invalidateContainer
+  await PlacesUtils.history.removeByFilter({ host: "mozilla.com" });
+  // This test is disabled for bug 1089691. It is failing bcause the new API
+  // doesn't send batching notifications and thus the result doesn't invalidate
+  // the whole container.
+  // Assert.equal(root.uri, resultObserver.invalidatedContainer.uri);
 
-        // nsINavHistoryResultObserver.invalidateContainer
-        PlacesUtils.history.clear().then(() => {
-          Assert.equal(root.uri, resultObserver.invalidatedContainer.uri);
+  // nsINavHistoryResultObserver.sortingChanged
+  resultObserver.invalidatedContainer = null;
+  result.sortingMode = options.SORT_BY_TITLE_ASCENDING;
+  Assert.equal(resultObserver.sortingMode, options.SORT_BY_TITLE_ASCENDING);
+  Assert.equal(resultObserver.invalidatedContainer, result.root);
 
-          root.containerOpen = false;
-          Assert.equal(resultObserver.closedContainer, resultObserver.openedContainer);
-          result.removeObserver(resultObserver);
-          resultObserver.reset();
-          PlacesTestUtils.promiseAsyncUpdates().then(run_next_test);
-        });
-      });
-    });
-  });
+  // nsINavHistoryResultObserver.invalidateContainer
+  await PlacesUtils.history.clear();
+  Assert.equal(root.uri, resultObserver.invalidatedContainer.uri);
+
+  root.containerOpen = false;
+  Assert.equal(resultObserver.closedContainer, resultObserver.openedContainer);
+  result.removeObserver(resultObserver);
+  resultObserver.reset();
+  await PlacesTestUtils.promiseAsyncUpdates();
 });
 
 add_task(async function check_bookmarks_query() {
-  var options = PlacesUtils.history.getNewQueryOptions();
-  var query = PlacesUtils.history.getNewQuery();
-  query.setFolders([PlacesUtils.bookmarks.bookmarksMenuFolder], 1);
-  var result = PlacesUtils.history.executeQuery(query, options);
+  let options = PlacesUtils.history.getNewQueryOptions();
+  let query = PlacesUtils.history.getNewQuery();
+  query.setFolders([PlacesUtils.bookmarksMenuFolderId], 1);
+  let result = PlacesUtils.history.executeQuery(query, options);
   result.addObserver(resultObserver);
-  var root = result.root;
+  let root = result.root;
   root.containerOpen = true;
 
   Assert.notEqual(resultObserver.openedContainer, null);
 
   // nsINavHistoryResultObserver.nodeInserted
   // add a bookmark
-  var testBookmark =
-    await PlacesUtils.bookmarks.insert({
-      parentGuid: PlacesUtils.bookmarks.menuGuid,
-      url: testURI,
-      title: "foo"
+  let testBookmark = await PlacesUtils.bookmarks.insert({
+    parentGuid: PlacesUtils.bookmarks.menuGuid,
+    url: testURI,
+    title: "foo"
   });
   Assert.equal("foo", resultObserver.insertedNode.title);
   Assert.equal(testURI.spec, resultObserver.insertedNode.uri);
 
   // nsINavHistoryResultObserver.nodeHistoryDetailsChanged
   // adding a visit causes nodeHistoryDetailsChanged for the folder
   Assert.equal(root.uri, resultObserver.nodeChangedByHistoryDetails.uri);
 
   // nsINavHistoryResultObserver.nodeTitleChanged for a leaf node
   await PlacesUtils.bookmarks.update({
     guid: testBookmark.guid,
     title: "baz",
   });
   Assert.equal(resultObserver.nodeChangedByTitle.title, "baz");
   Assert.equal(resultObserver.newTitle, "baz");
 
-  var testBookmark2 = await PlacesUtils.bookmarks.insert({
+  let testBookmark2 = await PlacesUtils.bookmarks.insert({
     parentGuid: PlacesUtils.bookmarks.menuGuid,
     url: "http://google.com",
     title: "foo"
   });
 
   await PlacesUtils.bookmarks.update({
     guid: testBookmark2.guid,
     index: 0,
@@ -184,36 +181,36 @@ add_task(async function check_bookmarks_
   // nsINavHistoryResultObserver.nodeRemoved
   await PlacesUtils.bookmarks.remove(testBookmark2.guid);
   Assert.equal(testBookmark2.guid, resultObserver.removedNode.bookmarkGuid);
 
   // XXX nsINavHistoryResultObserver.invalidateContainer
 
   // nsINavHistoryResultObserver.sortingChanged
   resultObserver.invalidatedContainer = null;
-  result.sortingMode = options.SORT_BY_TITLE_ASCENDING;
-  Assert.equal(resultObserver.sortingMode, options.SORT_BY_TITLE_ASCENDING);
+  result.sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_TITLE_ASCENDING;
+  Assert.equal(resultObserver.sortingMode, Ci.nsINavHistoryQueryOptions.SORT_BY_TITLE_ASCENDING);
   Assert.equal(resultObserver.invalidatedContainer, result.root);
 
   root.containerOpen = false;
   Assert.equal(resultObserver.closedContainer, resultObserver.openedContainer);
   result.removeObserver(resultObserver);
   resultObserver.reset();
-  PlacesTestUtils.promiseAsyncUpdates().then(run_next_test);
+  await PlacesTestUtils.promiseAsyncUpdates();
 });
 
-add_test(function check_mixed_query() {
-  var options = PlacesUtils.history.getNewQueryOptions();
-  var query = PlacesUtils.history.getNewQuery();
+add_task(async function check_mixed_query() {
+  let options = PlacesUtils.history.getNewQueryOptions();
+  let query = PlacesUtils.history.getNewQuery();
   query.onlyBookmarked = true;
-  var result = PlacesUtils.history.executeQuery(query, options);
+  let result = PlacesUtils.history.executeQuery(query, options);
   result.addObserver(resultObserver);
-  var root = result.root;
+  let root = result.root;
   root.containerOpen = true;
 
   Assert.notEqual(resultObserver.openedContainer, null);
 
   root.containerOpen = false;
   Assert.equal(resultObserver.closedContainer, resultObserver.openedContainer);
   result.removeObserver(resultObserver);
   resultObserver.reset();
-  PlacesTestUtils.promiseAsyncUpdates().then(run_next_test);
+  await PlacesTestUtils.promiseAsyncUpdates();
 });
--- a/toolkit/forgetaboutsite/ForgetAboutSite.jsm
+++ b/toolkit/forgetaboutsite/ForgetAboutSite.jsm
@@ -37,17 +37,17 @@ function hasRootDomain(str, aDomain) {
   // exact match) the character before the index is a dot or slash.
   let prevChar = str[index - 1];
   return (index == (str.length - aDomain.length)) &&
          (prevChar == "." || prevChar == "/");
 }
 
 var ForgetAboutSite = {
   async removeDataFromDomain(aDomain) {
-    PlacesUtils.history.removePagesFromHost(aDomain, true);
+    await PlacesUtils.history.removeByFilter({ host: "." + aDomain });
 
     let promises = [];
     // Cache
     promises.push((async function() {
       // NOTE: there is no way to clear just that domain, so we clear out
       //       everything)
       Services.cache2.clear();
     })().catch(ex => {