Bug 1293853 - Part 2: Include separators in results from bookmarks.search, r?mak draft
authorBob Silverberg <bsilverberg@mozilla.com>
Tue, 29 Aug 2017 13:19:05 -0400
changeset 657527 ea907a4e38848ec7bb15c2ab39046c660eb07ad9
parent 657526 b50f63d76667c8c139cd40351d458581b75640e9
child 657528 e4df313ec3911353a6f0e585ece99e9abcc38578
push id77550
push userbmo:bob.silverberg@gmail.com
push dateFri, 01 Sep 2017 16:04:30 +0000
reviewersmak
bugs1293853
milestone57.0a1
Bug 1293853 - Part 2: Include separators in results from bookmarks.search, r?mak This API is only used by WebExtensions, which previously wanted to exclude separators, but now we want the WebExtensions APIs to be able to return separators. MozReview-Commit-ID: 7PApWDwWMr1
toolkit/components/places/Bookmarks.jsm
toolkit/components/places/tests/bookmarks/test_bookmarks_search.js
--- a/toolkit/components/places/Bookmarks.jsm
+++ b/toolkit/components/places/Bookmarks.jsm
@@ -1081,16 +1081,18 @@ var Bookmarks = Object.freeze({
 
   /**
    * Searches a list of bookmark-items by a search term, url or title.
    *
    * IMPORTANT:
    * This is intended as an interim API for the web-extensions implementation.
    * It will be removed as soon as we have a new querying API.
    *
+   * Note also that this used to exclude separators but no longer does so.
+   *
    * If you just want to search bookmarks by URL, use .fetch() instead.
    *
    * @param query
    *        Either a string to use as search term, or an object
    *        containing any of these keys: query, title or url with the
    *        corresponding string to match as value.
    *        The url property can be either a string or an nsIURI.
    *
@@ -1543,21 +1545,19 @@ async function handleBookmarkItemSpecial
   }
 }
 
 // Query implementation.
 
 async function queryBookmarks(info) {
   let queryParams = {
     tags_folder: await promiseTagsFolderId(),
-    type: Bookmarks.TYPE_SEPARATOR,
   };
-  // We're searching for bookmarks, so exclude tags and separators.
-  let queryString = "WHERE b.type <> :type";
-  queryString += " AND b.parent <> :tags_folder";
+  // We're searching for bookmarks, so exclude tags.
+  let queryString = "WHERE b.parent <> :tags_folder";
   queryString += " AND p.parent <> :tags_folder";
 
   if (info.title) {
     queryString += " AND b.title = :title";
     queryParams.title = info.title;
   }
 
   if (info.url) {
--- a/toolkit/components/places/tests/bookmarks/test_bookmarks_search.js
+++ b/toolkit/components/places/tests/bookmarks/test_bookmarks_search.js
@@ -216,31 +216,31 @@ add_task(async function search_folder() 
   Assert.equal(results.length, 1);
   checkBookmarkObject(results[0]);
   Assert.deepEqual(bm, results[0]);
   Assert.equal(folder.guid, results[0].parentGuid);
 
   await PlacesUtils.bookmarks.eraseEverything();
 });
 
-add_task(async function search_excludes_separators() {
+add_task(async function search_includes_separators() {
   let bm1 = await PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
                                                  url: "http://example.com/",
                                                  title: "a bookmark" });
   let bm2 = await PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
                                                  type: PlacesUtils.bookmarks.TYPE_SEPARATOR });
 
   checkBookmarkObject(bm1);
   checkBookmarkObject(bm2);
 
   let results = await PlacesUtils.bookmarks.search({});
   Assert.ok(results.findIndex(bookmark => { return bookmark.guid == bm1.guid }) > -1,
             "The bookmark was found in the results.");
-  Assert.equal(-1, results.findIndex(bookmark => { return bookmark.guid == bm2.guid }),
-            "The separator was excluded from the results.");
+  Assert.ok(results.findIndex(bookmark => { return bookmark.guid == bm2.guid }) > -1,
+            "The separator was included in the results.");
 
   await PlacesUtils.bookmarks.eraseEverything();
 });
 
 add_task(async function search_excludes_tags() {
   let bm1 = await PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
                                                  url: "http://example.com/",
                                                  title: "a bookmark" });