Bug 1220654 - Replace removeVisitsTimeframe with History.removeVisitsByFilter and deprecate it. r=mak draft
authorAndrew Krawchyk <akrawchyk@gmail.com>
Sun, 08 Nov 2015 12:01:49 -0500
changeset 307356 19e7df140554949f191eb41b44a984c727fd3138
parent 307344 e2a910c048dc82fc3be53475f18e7f81f03e377b
child 510989 e2ac34bbd6f9adf1f3899c9e295ecfea01787830
push id7297
push userakrawchyk@gmail.com
push dateSun, 08 Nov 2015 17:03:23 +0000
reviewersmak
bugs1220654
milestone45.0a1
Bug 1220654 - Replace removeVisitsTimeframe with History.removeVisitsByFilter and deprecate it. r=mak
services/sync/tps/extensions/tps/resource/modules/history.jsm
toolkit/components/places/nsIBrowserHistory.idl
toolkit/components/places/nsNavHistory.cpp
toolkit/components/places/tests/unit/test_removeVisits.js
toolkit/components/places/tests/unit/test_removeVisitsByTimeframe.js
toolkit/components/places/tests/unit/xpcshell.ini
--- a/services/sync/tps/extensions/tps/resource/modules/history.jsm
+++ b/services/sync/tps/extensions/tps/resource/modules/history.jsm
@@ -184,17 +184,30 @@ var HistoryEntry = {
     if ("uri" in item) {
       let uri = Services.io.newURI(item.uri, null, null);
       PlacesUtils.history.removePage(uri);
     }
     else if ("host" in item) {
       PlacesUtils.history.removePagesFromHost(item.host, false);
     }
     else if ("begin" in item && "end" in item) {
-      PlacesUtils.history.removeVisitsByTimeframe(
-          usSinceEpoch + (item.begin * 60 * 60 * 1000 * 1000),
-          usSinceEpoch + (item.end * 60 * 60 * 1000 * 1000));
+      let cb = Async.makeSpinningCallback();
+      let filter = {
+        beginDate: new Date(usSinceEpoch + (item.begin * 60 * 60 * 1000 * 1000)),
+        endDate: new Date(usSinceEpoch + (item.end * 60 * 60 * 1000 * 1000))
+      };
+      PlacesUtils.history.removeVisitsByFilter(filter, {
+        handleError: function Delete_handleError() {
+          cb(new Error("Error deleting history entries"));
+        },
+        handleResult: function Delete_handleResult() {
+          cb();
+        },
+        handleCompletion: function Delete_handleCompletion() {
+          // Nothing to do
+        }
+      });
     }
     else {
       Logger.AssertTrue(false, "invalid entry in delete history");
     }
   },
 };
--- a/toolkit/components/places/nsIBrowserHistory.idl
+++ b/toolkit/components/places/nsIBrowserHistory.idl
@@ -74,16 +74,18 @@ interface nsIBrowserHistory : nsISupport
      * Any pages that becomes unvisited as a result will also be deleted.
      *
      * @param aBeginTime
      *        Microseconds from epoch, representing the initial time.
      * @param aEndTime
      *        Microseconds from epoch, representing the final time.
      *
      * @note The removal happens in a batch.
+     *
+     * @deprecated Please use PlacesUtils.history.removeVisitsByFilter instead
      */
     void removeVisitsByTimeframe(in PRTime aBeginTime,
                                  in PRTime aEndTime);
 
     /**
      * Removes all existing pages from global history.
      * Visits are removed synchronously, but pages are expired asynchronously
      * off the main-thread.
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -2708,16 +2708,18 @@ nsNavHistory::RemovePagesByTimeframe(PRT
  * @param aBeginTime
  *        The start of the timeframe, inclusive
  * @param aEndTime
  *        The end of the timeframe, inclusive
  */
 NS_IMETHODIMP
 nsNavHistory::RemoveVisitsByTimeframe(PRTime aBeginTime, PRTime aEndTime)
 {
+  PLACES_WARN_DEPRECATED();
+
   NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
 
   nsresult rv;
 
   // Build a list of place IDs whose visits fall entirely within the timespan.
   // These places will be deleted by the call to CleanupPlacesOnVisitsDelete
   // below.
   nsCString deletePlaceIdsQueryString;
new file mode 100644
--- /dev/null
+++ b/toolkit/components/places/tests/unit/test_removeVisits.js
@@ -0,0 +1,332 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et: */
+/* 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/. */
+
+const NOW = Date.now() * 1000;
+const TEST_URI = uri("http://example.com/");
+const PLACE_URI = uri("place:queryType=0&sort=8&maxResults=10");
+
+function* cleanup() {
+  yield PlacesTestUtils.clearHistory();
+  yield PlacesUtils.bookmarks.eraseEverything();
+  // This is needed to remove place: entries.
+  DBConn().executeSimpleSQL("DELETE FROM moz_places");
+}
+
+add_task(function remove_visits_outside_unbookmarked_uri() {
+  do_print("*** TEST: Remove some visits outside valid timeframe from an unbookmarked URI");
+
+  do_print("Add 10 visits for the URI from way in the past.");
+  let visits = [];
+  for (let i = 0; i < 10; i++) {
+    visits.push({ uri: TEST_URI, visitDate: NOW - 1000 - i });
+  }
+  yield PlacesTestUtils.addVisits(visits);
+
+  do_print("Remove visits using timerange outside the URI's visits.");
+  PlacesUtils.history.removeVisitsByTimeframe(NOW - 10, NOW);
+  yield PlacesTestUtils.promiseAsyncUpdates();
+
+  do_print("URI should still exist in moz_places.");
+  do_check_true(page_in_database(TEST_URI.spec));
+
+  do_print("Run a history query and check that all visits still exist.");
+  let query = PlacesUtils.history.getNewQuery();
+  let opts = PlacesUtils.history.getNewQueryOptions();
+  opts.resultType = opts.RESULTS_AS_VISIT;
+  opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
+  let root = PlacesUtils.history.executeQuery(query, opts).root;
+  root.containerOpen = true;
+  do_check_eq(root.childCount, 10);
+  for (let i = 0; i < root.childCount; i++) {
+    let visitTime = root.getChild(i).time;
+    do_check_eq(visitTime, NOW - 1000 - i);
+  }
+  root.containerOpen = false;
+
+  do_print("asyncHistory.isURIVisited should return true.");
+  do_check_true(yield promiseIsURIVisited(TEST_URI));
+
+  yield PlacesTestUtils.promiseAsyncUpdates();
+  do_print("Frecency should be positive.")
+  do_check_true(frecencyForUrl(TEST_URI) > 0);
+
+  yield cleanup();
+});
+
+add_task(function remove_visits_outside_bookmarked_uri() {
+  do_print("*** TEST: Remove some visits outside valid timeframe from a bookmarked URI");
+
+  do_print("Add 10 visits for the URI from way in the past.");
+  let visits = [];
+  for (let i = 0; i < 10; i++) {
+    visits.push({ uri: TEST_URI, visitDate: NOW - 1000 - i });
+  }
+  yield PlacesTestUtils.addVisits(visits);
+  do_print("Bookmark the URI.");
+  PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
+                                       TEST_URI,
+                                       PlacesUtils.bookmarks.DEFAULT_INDEX,
+                                       "bookmark title");
+  yield PlacesTestUtils.promiseAsyncUpdates();
+
+  do_print("Remove visits using timerange outside the URI's visits.");
+  PlacesUtils.history.removeVisitsByTimeframe(NOW - 10, NOW);
+  yield PlacesTestUtils.promiseAsyncUpdates();
+
+  do_print("URI should still exist in moz_places.");
+  do_check_true(page_in_database(TEST_URI.spec));
+
+  do_print("Run a history query and check that all visits still exist.");
+  let query = PlacesUtils.history.getNewQuery();
+  let opts = PlacesUtils.history.getNewQueryOptions();
+  opts.resultType = opts.RESULTS_AS_VISIT;
+  opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
+  let root = PlacesUtils.history.executeQuery(query, opts).root;
+  root.containerOpen = true;
+  do_check_eq(root.childCount, 10);
+  for (let i = 0; i < root.childCount; i++) {
+    let visitTime = root.getChild(i).time;
+    do_check_eq(visitTime, NOW - 1000 - i);
+  }
+  root.containerOpen = false;
+
+  do_print("asyncHistory.isURIVisited should return true.");
+  do_check_true(yield promiseIsURIVisited(TEST_URI));
+  yield PlacesTestUtils.promiseAsyncUpdates();
+
+  do_print("Frecency should be positive.")
+  do_check_true(frecencyForUrl(TEST_URI) > 0);
+
+  yield cleanup();
+});
+
+add_task(function remove_visits_unbookmarked_uri() {
+  do_print("*** TEST: Remove some visits from an unbookmarked URI");
+
+  do_print("Add 10 visits for the URI from now to 9 usecs in the past.");
+  let visits = [];
+  for (let i = 0; i < 10; i++) {
+    visits.push({ uri: TEST_URI, visitDate: NOW - i });
+  }
+  yield PlacesTestUtils.addVisits(visits);
+
+  do_print("Remove the 5 most recent visits.");
+  PlacesUtils.history.removeVisitsByTimeframe(NOW - 4, NOW);
+  yield PlacesTestUtils.promiseAsyncUpdates();
+
+  do_print("URI should still exist in moz_places.");
+  do_check_true(page_in_database(TEST_URI.spec));
+
+  do_print("Run a history query and check that only the older 5 visits still exist.");
+  let query = PlacesUtils.history.getNewQuery();
+  let opts = PlacesUtils.history.getNewQueryOptions();
+  opts.resultType = opts.RESULTS_AS_VISIT;
+  opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
+  let root = PlacesUtils.history.executeQuery(query, opts).root;
+  root.containerOpen = true;
+  do_check_eq(root.childCount, 5);
+  for (let i = 0; i < root.childCount; i++) {
+    let visitTime = root.getChild(i).time;
+    do_check_eq(visitTime, NOW - i - 5);
+  }
+  root.containerOpen = false;
+
+  do_print("asyncHistory.isURIVisited should return true.");
+  do_check_true(yield promiseIsURIVisited(TEST_URI));
+  yield PlacesTestUtils.promiseAsyncUpdates();
+
+  do_print("Frecency should be positive.")
+  do_check_true(frecencyForUrl(TEST_URI) > 0);
+
+  yield cleanup();
+});
+
+add_task(function remove_visits_bookmarked_uri() {
+  do_print("*** TEST: Remove some visits from a bookmarked URI");
+
+  do_print("Add 10 visits for the URI from now to 9 usecs in the past.");
+  let visits = [];
+  for (let i = 0; i < 10; i++) {
+    visits.push({ uri: TEST_URI, visitDate: NOW - i });
+  }
+  yield PlacesTestUtils.addVisits(visits);
+  do_print("Bookmark the URI.");
+  PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
+                                       TEST_URI,
+                                       PlacesUtils.bookmarks.DEFAULT_INDEX,
+                                       "bookmark title");
+  yield PlacesTestUtils.promiseAsyncUpdates();
+
+  do_print("Remove the 5 most recent visits.");
+  PlacesUtils.history.removeVisitsByTimeframe(NOW - 4, NOW);
+  yield PlacesTestUtils.promiseAsyncUpdates();
+
+  do_print("URI should still exist in moz_places.");
+  do_check_true(page_in_database(TEST_URI.spec));
+
+  do_print("Run a history query and check that only the older 5 visits still exist.");
+  let query = PlacesUtils.history.getNewQuery();
+  let opts = PlacesUtils.history.getNewQueryOptions();
+  opts.resultType = opts.RESULTS_AS_VISIT;
+  opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
+  let root = PlacesUtils.history.executeQuery(query, opts).root;
+  root.containerOpen = true;
+  do_check_eq(root.childCount, 5);
+  for (let i = 0; i < root.childCount; i++) {
+    let visitTime = root.getChild(i).time;
+    do_check_eq(visitTime, NOW - i - 5);
+  }
+  root.containerOpen = false;
+
+  do_print("asyncHistory.isURIVisited should return true.");
+  do_check_true(yield promiseIsURIVisited(TEST_URI));
+  yield PlacesTestUtils.promiseAsyncUpdates()
+
+  do_print("Frecency should be positive.")
+  do_check_true(frecencyForUrl(TEST_URI) > 0);
+
+  yield cleanup();
+});
+
+add_task(function remove_all_visits_unbookmarked_uri() {
+  do_print("*** TEST: Remove all visits from an unbookmarked URI");
+
+  do_print("Add some visits for the URI.");
+  let visits = [];
+  for (let i = 0; i < 10; i++) {
+    visits.push({ uri: TEST_URI, visitDate: NOW - i });
+  }
+  yield PlacesTestUtils.addVisits(visits);
+
+  do_print("Remove all visits.");
+  PlacesUtils.history.removeVisitsByTimeframe(NOW - 10, NOW);
+  yield PlacesTestUtils.promiseAsyncUpdates();
+
+  do_print("URI should no longer exist in moz_places.");
+  do_check_false(page_in_database(TEST_URI.spec));
+
+  do_print("Run a history query and check that no visits exist.");
+  let query = PlacesUtils.history.getNewQuery();
+  let opts = PlacesUtils.history.getNewQueryOptions();
+  opts.resultType = opts.RESULTS_AS_VISIT;
+  opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
+  let root = PlacesUtils.history.executeQuery(query, opts).root;
+  root.containerOpen = true;
+  do_check_eq(root.childCount, 0);
+  root.containerOpen = false;
+
+  do_print("asyncHistory.isURIVisited should return false.");
+  do_check_false(yield promiseIsURIVisited(TEST_URI));
+
+  yield cleanup();
+});
+
+add_task(function remove_all_visits_unbookmarked_place_uri() {
+  do_print("*** TEST: Remove all visits from an unbookmarked place: URI");
+  do_print("Add some visits for the URI.");
+  let visits = [];
+  for (let i = 0; i < 10; i++) {
+    visits.push({ uri: PLACE_URI, visitDate: NOW - i });
+  }
+  yield PlacesTestUtils.addVisits(visits);
+
+  do_print("Remove all visits.");
+  PlacesUtils.history.removeVisitsByTimeframe(NOW - 10, NOW);
+  yield PlacesTestUtils.promiseAsyncUpdates();
+
+  do_print("URI should still exist in moz_places.");
+  do_check_true(page_in_database(PLACE_URI.spec));
+
+  do_print("Run a history query and check that no visits exist.");
+  let query = PlacesUtils.history.getNewQuery();
+  let opts = PlacesUtils.history.getNewQueryOptions();
+  opts.resultType = opts.RESULTS_AS_VISIT;
+  opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
+  let root = PlacesUtils.history.executeQuery(query, opts).root;
+  root.containerOpen = true;
+  do_check_eq(root.childCount, 0);
+  root.containerOpen = false;
+
+  do_print("asyncHistory.isURIVisited should return false.");
+  do_check_false(yield promiseIsURIVisited(PLACE_URI));
+  yield PlacesTestUtils.promiseAsyncUpdates();
+
+  do_print("Frecency should be zero.")
+  do_check_eq(frecencyForUrl(PLACE_URI.spec), 0);
+
+  yield cleanup();
+});
+
+add_task(function remove_all_visits_bookmarked_uri() {
+  do_print("*** TEST: Remove all visits from a bookmarked URI");
+
+  do_print("Add some visits for the URI.");
+  let visits = [];
+  for (let i = 0; i < 10; i++) {
+    visits.push({ uri: TEST_URI, visitDate: NOW - i });
+  }
+  yield PlacesTestUtils.addVisits(visits);
+  do_print("Bookmark the URI.");
+  PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
+                                       TEST_URI,
+                                       PlacesUtils.bookmarks.DEFAULT_INDEX,
+                                       "bookmark title");
+  yield PlacesTestUtils.promiseAsyncUpdates();
+
+  do_print("Remove all visits.");
+  PlacesUtils.history.removeVisitsByTimeframe(NOW - 10, NOW);
+  yield PlacesTestUtils.promiseAsyncUpdates();
+
+  do_print("URI should still exist in moz_places.");
+  do_check_true(page_in_database(TEST_URI.spec));
+
+  do_print("Run a history query and check that no visits exist.");
+  let query = PlacesUtils.history.getNewQuery();
+  let opts = PlacesUtils.history.getNewQueryOptions();
+  opts.resultType = opts.RESULTS_AS_VISIT;
+  opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
+  let root = PlacesUtils.history.executeQuery(query, opts).root;
+  root.containerOpen = true;
+  do_check_eq(root.childCount, 0);
+  root.containerOpen = false;
+
+  do_print("asyncHistory.isURIVisited should return false.");
+  do_check_false(yield promiseIsURIVisited(TEST_URI));
+
+  do_print("nsINavBookmarksService.isBookmarked should return true.");
+  do_check_true(PlacesUtils.bookmarks.isBookmarked(TEST_URI));
+  yield PlacesTestUtils.promiseAsyncUpdates();
+
+  do_print("Frecency should be negative.")
+  do_check_true(frecencyForUrl(TEST_URI) < 0);
+
+  yield cleanup();
+});
+
+add_task(function remove_all_visits_bookmarked_uri() {
+  do_print("*** TEST: Remove some visits from a zero frecency URI retains zero frecency");
+
+  do_print("Add some visits for the URI.");
+  yield PlacesTestUtils.addVisits([
+    { uri: TEST_URI, transition: TRANSITION_FRAMED_LINK, visitDate: (NOW - 86400000000) },
+    { uri: TEST_URI, transition: TRANSITION_FRAMED_LINK, visitDate: NOW }
+  ]);
+
+  do_print("Remove newer visit.");
+  PlacesUtils.history.removeVisitsByTimeframe(NOW - 10, NOW);
+  yield PlacesTestUtils.promiseAsyncUpdates();
+
+  do_print("URI should still exist in moz_places.");
+  do_check_true(page_in_database(TEST_URI.spec));
+  do_print("Frecency should be zero.")
+  do_check_eq(frecencyForUrl(TEST_URI), 0);
+
+  yield cleanup();
+});
+
+function run_test() {
+  run_next_test();
+}
deleted file mode 100644
--- a/toolkit/components/places/tests/unit/test_removeVisitsByTimeframe.js
+++ /dev/null
@@ -1,332 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
-/* 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/. */
-
-const NOW = Date.now() * 1000;
-const TEST_URI = uri("http://example.com/");
-const PLACE_URI = uri("place:queryType=0&sort=8&maxResults=10");
-
-function* cleanup() {
-  yield PlacesTestUtils.clearHistory();
-  yield PlacesUtils.bookmarks.eraseEverything();
-  // This is needed to remove place: entries.
-  DBConn().executeSimpleSQL("DELETE FROM moz_places");
-}
-
-add_task(function remove_visits_outside_unbookmarked_uri() {
-  do_print("*** TEST: Remove some visits outside valid timeframe from an unbookmarked URI");
- 
-  do_print("Add 10 visits for the URI from way in the past.");
-  let visits = [];
-  for (let i = 0; i < 10; i++) {
-    visits.push({ uri: TEST_URI, visitDate: NOW - 1000 - i });
-  }
-  yield PlacesTestUtils.addVisits(visits);
-
-  do_print("Remove visits using timerange outside the URI's visits.");
-  PlacesUtils.history.removeVisitsByTimeframe(NOW - 10, NOW);
-  yield PlacesTestUtils.promiseAsyncUpdates();
-
-  do_print("URI should still exist in moz_places.");
-  do_check_true(page_in_database(TEST_URI.spec));
-
-  do_print("Run a history query and check that all visits still exist.");
-  let query = PlacesUtils.history.getNewQuery();
-  let opts = PlacesUtils.history.getNewQueryOptions();
-  opts.resultType = opts.RESULTS_AS_VISIT;
-  opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
-  let root = PlacesUtils.history.executeQuery(query, opts).root;
-  root.containerOpen = true;
-  do_check_eq(root.childCount, 10);
-  for (let i = 0; i < root.childCount; i++) {
-    let visitTime = root.getChild(i).time;
-    do_check_eq(visitTime, NOW - 1000 - i);
-  }
-  root.containerOpen = false;
-
-  do_print("asyncHistory.isURIVisited should return true.");
-  do_check_true(yield promiseIsURIVisited(TEST_URI));
-
-  yield PlacesTestUtils.promiseAsyncUpdates();
-  do_print("Frecency should be positive.")
-  do_check_true(frecencyForUrl(TEST_URI) > 0);
-
-  yield cleanup();
-});
-
-add_task(function remove_visits_outside_bookmarked_uri() {
-  do_print("*** TEST: Remove some visits outside valid timeframe from a bookmarked URI");
-
-  do_print("Add 10 visits for the URI from way in the past.");
-  let visits = [];
-  for (let i = 0; i < 10; i++) {
-    visits.push({ uri: TEST_URI, visitDate: NOW - 1000 - i });
-  }
-  yield PlacesTestUtils.addVisits(visits);
-  do_print("Bookmark the URI.");
-  PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
-                                       TEST_URI,
-                                       PlacesUtils.bookmarks.DEFAULT_INDEX,
-                                       "bookmark title");
-  yield PlacesTestUtils.promiseAsyncUpdates();
-
-  do_print("Remove visits using timerange outside the URI's visits.");
-  PlacesUtils.history.removeVisitsByTimeframe(NOW - 10, NOW);
-  yield PlacesTestUtils.promiseAsyncUpdates();
-
-  do_print("URI should still exist in moz_places.");
-  do_check_true(page_in_database(TEST_URI.spec));
-
-  do_print("Run a history query and check that all visits still exist.");
-  let query = PlacesUtils.history.getNewQuery();
-  let opts = PlacesUtils.history.getNewQueryOptions();
-  opts.resultType = opts.RESULTS_AS_VISIT;
-  opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
-  let root = PlacesUtils.history.executeQuery(query, opts).root;
-  root.containerOpen = true;
-  do_check_eq(root.childCount, 10);
-  for (let i = 0; i < root.childCount; i++) {
-    let visitTime = root.getChild(i).time;
-    do_check_eq(visitTime, NOW - 1000 - i);
-  }
-  root.containerOpen = false;
-
-  do_print("asyncHistory.isURIVisited should return true.");
-  do_check_true(yield promiseIsURIVisited(TEST_URI));
-  yield PlacesTestUtils.promiseAsyncUpdates();
-
-  do_print("Frecency should be positive.")
-  do_check_true(frecencyForUrl(TEST_URI) > 0);
-
-  yield cleanup();
-});
-
-add_task(function remove_visits_unbookmarked_uri() {
-  do_print("*** TEST: Remove some visits from an unbookmarked URI");
-
-  do_print("Add 10 visits for the URI from now to 9 usecs in the past.");
-  let visits = [];
-  for (let i = 0; i < 10; i++) {
-    visits.push({ uri: TEST_URI, visitDate: NOW - i });
-  }
-  yield PlacesTestUtils.addVisits(visits);
-
-  do_print("Remove the 5 most recent visits.");
-  PlacesUtils.history.removeVisitsByTimeframe(NOW - 4, NOW);
-  yield PlacesTestUtils.promiseAsyncUpdates();
-
-  do_print("URI should still exist in moz_places.");
-  do_check_true(page_in_database(TEST_URI.spec));
-
-  do_print("Run a history query and check that only the older 5 visits still exist.");
-  let query = PlacesUtils.history.getNewQuery();
-  let opts = PlacesUtils.history.getNewQueryOptions();
-  opts.resultType = opts.RESULTS_AS_VISIT;
-  opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
-  let root = PlacesUtils.history.executeQuery(query, opts).root;
-  root.containerOpen = true;
-  do_check_eq(root.childCount, 5);
-  for (let i = 0; i < root.childCount; i++) {
-    let visitTime = root.getChild(i).time;
-    do_check_eq(visitTime, NOW - i - 5);
-  }
-  root.containerOpen = false;
-
-  do_print("asyncHistory.isURIVisited should return true.");
-  do_check_true(yield promiseIsURIVisited(TEST_URI));
-  yield PlacesTestUtils.promiseAsyncUpdates();
-
-  do_print("Frecency should be positive.")
-  do_check_true(frecencyForUrl(TEST_URI) > 0);
-
-  yield cleanup();
-});
-
-add_task(function remove_visits_bookmarked_uri() {
-  do_print("*** TEST: Remove some visits from a bookmarked URI");
-
-  do_print("Add 10 visits for the URI from now to 9 usecs in the past.");
-  let visits = [];
-  for (let i = 0; i < 10; i++) {
-    visits.push({ uri: TEST_URI, visitDate: NOW - i });
-  }
-  yield PlacesTestUtils.addVisits(visits);
-  do_print("Bookmark the URI.");
-  PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
-                                       TEST_URI,
-                                       PlacesUtils.bookmarks.DEFAULT_INDEX,
-                                       "bookmark title");
-  yield PlacesTestUtils.promiseAsyncUpdates();
-
-  do_print("Remove the 5 most recent visits.");
-  PlacesUtils.history.removeVisitsByTimeframe(NOW - 4, NOW);
-  yield PlacesTestUtils.promiseAsyncUpdates();
-
-  do_print("URI should still exist in moz_places.");
-  do_check_true(page_in_database(TEST_URI.spec));
-
-  do_print("Run a history query and check that only the older 5 visits still exist.");
-  let query = PlacesUtils.history.getNewQuery();
-  let opts = PlacesUtils.history.getNewQueryOptions();
-  opts.resultType = opts.RESULTS_AS_VISIT;
-  opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
-  let root = PlacesUtils.history.executeQuery(query, opts).root;
-  root.containerOpen = true;
-  do_check_eq(root.childCount, 5);
-  for (let i = 0; i < root.childCount; i++) {
-    let visitTime = root.getChild(i).time;
-    do_check_eq(visitTime, NOW - i - 5);
-  }
-  root.containerOpen = false;
-
-  do_print("asyncHistory.isURIVisited should return true.");
-  do_check_true(yield promiseIsURIVisited(TEST_URI));
-  yield PlacesTestUtils.promiseAsyncUpdates()
-
-  do_print("Frecency should be positive.")
-  do_check_true(frecencyForUrl(TEST_URI) > 0);
-
-  yield cleanup();
-});
-
-add_task(function remove_all_visits_unbookmarked_uri() {
-  do_print("*** TEST: Remove all visits from an unbookmarked URI");
-
-  do_print("Add some visits for the URI.");
-  let visits = [];
-  for (let i = 0; i < 10; i++) {
-    visits.push({ uri: TEST_URI, visitDate: NOW - i });
-  }
-  yield PlacesTestUtils.addVisits(visits);
-
-  do_print("Remove all visits.");
-  PlacesUtils.history.removeVisitsByTimeframe(NOW - 10, NOW);
-  yield PlacesTestUtils.promiseAsyncUpdates();
-
-  do_print("URI should no longer exist in moz_places.");
-  do_check_false(page_in_database(TEST_URI.spec));
-
-  do_print("Run a history query and check that no visits exist.");
-  let query = PlacesUtils.history.getNewQuery();
-  let opts = PlacesUtils.history.getNewQueryOptions();
-  opts.resultType = opts.RESULTS_AS_VISIT;
-  opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
-  let root = PlacesUtils.history.executeQuery(query, opts).root;
-  root.containerOpen = true;
-  do_check_eq(root.childCount, 0);
-  root.containerOpen = false;
-
-  do_print("asyncHistory.isURIVisited should return false.");
-  do_check_false(yield promiseIsURIVisited(TEST_URI));
-
-  yield cleanup();
-});
-
-add_task(function remove_all_visits_unbookmarked_place_uri() {
-  do_print("*** TEST: Remove all visits from an unbookmarked place: URI");
-  do_print("Add some visits for the URI.");
-  let visits = [];
-  for (let i = 0; i < 10; i++) {
-    visits.push({ uri: PLACE_URI, visitDate: NOW - i });
-  }
-  yield PlacesTestUtils.addVisits(visits);
-
-  do_print("Remove all visits.");
-  PlacesUtils.history.removeVisitsByTimeframe(NOW - 10, NOW);
-  yield PlacesTestUtils.promiseAsyncUpdates();
-
-  do_print("URI should still exist in moz_places.");
-  do_check_true(page_in_database(PLACE_URI.spec));
-
-  do_print("Run a history query and check that no visits exist.");
-  let query = PlacesUtils.history.getNewQuery();
-  let opts = PlacesUtils.history.getNewQueryOptions();
-  opts.resultType = opts.RESULTS_AS_VISIT;
-  opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
-  let root = PlacesUtils.history.executeQuery(query, opts).root;
-  root.containerOpen = true;
-  do_check_eq(root.childCount, 0);
-  root.containerOpen = false;
-
-  do_print("asyncHistory.isURIVisited should return false.");
-  do_check_false(yield promiseIsURIVisited(PLACE_URI));
-  yield PlacesTestUtils.promiseAsyncUpdates();
-
-  do_print("Frecency should be zero.")
-  do_check_eq(frecencyForUrl(PLACE_URI.spec), 0);
-
-  yield cleanup();
-});
-
-add_task(function remove_all_visits_bookmarked_uri() {
-  do_print("*** TEST: Remove all visits from a bookmarked URI");
-
-  do_print("Add some visits for the URI.");
-  let visits = [];
-  for (let i = 0; i < 10; i++) {
-    visits.push({ uri: TEST_URI, visitDate: NOW - i });
-  }
-  yield PlacesTestUtils.addVisits(visits);
-  do_print("Bookmark the URI.");
-  PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
-                                       TEST_URI,
-                                       PlacesUtils.bookmarks.DEFAULT_INDEX,
-                                       "bookmark title");
-  yield PlacesTestUtils.promiseAsyncUpdates();
-
-  do_print("Remove all visits.");
-  PlacesUtils.history.removeVisitsByTimeframe(NOW - 10, NOW);
-  yield PlacesTestUtils.promiseAsyncUpdates();
-
-  do_print("URI should still exist in moz_places.");
-  do_check_true(page_in_database(TEST_URI.spec));
-
-  do_print("Run a history query and check that no visits exist.");
-  let query = PlacesUtils.history.getNewQuery();
-  let opts = PlacesUtils.history.getNewQueryOptions();
-  opts.resultType = opts.RESULTS_AS_VISIT;
-  opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
-  let root = PlacesUtils.history.executeQuery(query, opts).root;
-  root.containerOpen = true;
-  do_check_eq(root.childCount, 0);
-  root.containerOpen = false;
-
-  do_print("asyncHistory.isURIVisited should return false.");
-  do_check_false(yield promiseIsURIVisited(TEST_URI));
-
-  do_print("nsINavBookmarksService.isBookmarked should return true.");
-  do_check_true(PlacesUtils.bookmarks.isBookmarked(TEST_URI));
-  yield PlacesTestUtils.promiseAsyncUpdates();
-
-  do_print("Frecency should be negative.")
-  do_check_true(frecencyForUrl(TEST_URI) < 0);
-
-  yield cleanup();
-});
-
-add_task(function remove_all_visits_bookmarked_uri() {
-  do_print("*** TEST: Remove some visits from a zero frecency URI retains zero frecency");
-
-  do_print("Add some visits for the URI.");
-  yield PlacesTestUtils.addVisits([
-    { uri: TEST_URI, transition: TRANSITION_FRAMED_LINK, visitDate: (NOW - 86400000000) },
-    { uri: TEST_URI, transition: TRANSITION_FRAMED_LINK, visitDate: NOW }
-  ]);
-
-  do_print("Remove newer visit.");
-  PlacesUtils.history.removeVisitsByTimeframe(NOW - 10, NOW);
-  yield PlacesTestUtils.promiseAsyncUpdates();
-
-  do_print("URI should still exist in moz_places.");
-  do_check_true(page_in_database(TEST_URI.spec));
-  do_print("Frecency should be zero.")
-  do_check_eq(frecencyForUrl(TEST_URI), 0);
-
-  yield cleanup();
-});
-
-function run_test() {
-  run_next_test();
-}
--- a/toolkit/components/places/tests/unit/xpcshell.ini
+++ b/toolkit/components/places/tests/unit/xpcshell.ini
@@ -129,17 +129,17 @@ skip-if = true
 [test_preventive_maintenance.js]
 # Bug 676989: test hangs consistently on Android
 skip-if = os == "android"
 [test_preventive_maintenance_checkAndFixDatabase.js]
 # Bug 676989: test hangs consistently on Android
 skip-if = os == "android"
 [test_preventive_maintenance_runTasks.js]
 [test_promiseBookmarksTree.js]
-[test_removeVisitsByTimeframe.js]
+[test_removeVisits.js]
 # Bug 676989: test hangs consistently on Android
 skip-if = os == "android"
 [test_resolveNullBookmarkTitles.js]
 [test_result_sort.js]
 [test_sql_guid_functions.js]
 [test_svg_favicon.js]
 [test_tag_autocomplete_search.js]
 [test_tagging.js]