Bug 1293853 - Part 2: Include separators in results from bookmarks.search, r=standard8

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

--HG--
extra : rebase_source : c5e816900cb0288f1cdba86ec07f6565a1c79880
This commit is contained in:
Bob Silverberg 2017-08-29 13:19:05 -04:00
Родитель f8c2cd5f82
Коммит 8268904c53
2 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

@ -1086,6 +1086,8 @@ var Bookmarks = Object.freeze({
* 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
@ -1548,11 +1550,9 @@ async function handleBookmarkItemSpecialData(itemId, item) {
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) {

Просмотреть файл

@ -221,7 +221,7 @@ add_task(async function search_folder() {
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" });
@ -234,8 +234,8 @@ add_task(async function search_excludes_separators() {
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();
});