mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 09:54:42 +00:00
Bug 1358127 - Fix bookmarks.search so it doesn't return the contents of tag folders, r=mak
Also fix bookmarks.search so it doesn't return separators. MozReview-Commit-ID: 18tkepk72f8 --HG-- extra : rebase_source : c1b713e6fb4e479df710bbc244e781a3bd4de48d
This commit is contained in:
parent
9e0ccac709
commit
0c4c482352
@ -1310,9 +1310,14 @@ function insertBookmarkTree(items, source, parent, urls, lastAddedForParent) {
|
||||
// Query implementation.
|
||||
|
||||
function queryBookmarks(info) {
|
||||
let queryParams = {tags_folder: PlacesUtils.tagsFolderId};
|
||||
// we're searching for bookmarks, so exclude tags
|
||||
let queryString = "WHERE p.parent <> :tags_folder";
|
||||
let queryParams = {
|
||||
tags_folder: PlacesUtils.tagsFolderId,
|
||||
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";
|
||||
queryString += " AND p.parent <> :tags_folder";
|
||||
|
||||
if (info.title) {
|
||||
queryString += " AND b.title = :title";
|
||||
|
@ -221,3 +221,39 @@ add_task(function* search_folder() {
|
||||
yield PlacesUtils.bookmarks.eraseEverything();
|
||||
});
|
||||
|
||||
add_task(function* search_excludes_separators() {
|
||||
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
url: "http://example.com/",
|
||||
title: "a bookmark" });
|
||||
let bm2 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
type: PlacesUtils.bookmarks.TYPE_SEPARATOR });
|
||||
|
||||
checkBookmarkObject(bm1);
|
||||
checkBookmarkObject(bm2);
|
||||
|
||||
let results = yield 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.");
|
||||
|
||||
yield PlacesUtils.bookmarks.eraseEverything();
|
||||
});
|
||||
|
||||
add_task(function* search_excludes_tags() {
|
||||
let bm1 = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
url: "http://example.com/",
|
||||
title: "a bookmark" });
|
||||
checkBookmarkObject(bm1);
|
||||
PlacesUtils.tagging.tagURI(uri(bm1.url.href), ["Test Tag"]);
|
||||
|
||||
let results = yield PlacesUtils.bookmarks.search("example.com");
|
||||
// If tags are not being excluded, this would return two results, one representing the tag.
|
||||
Assert.equal(1, results.length, "A single object was returned from search.");
|
||||
Assert.deepEqual(bm1, results[0], "The bookmark was returned.");
|
||||
|
||||
results = yield PlacesUtils.bookmarks.search("Test Tag");
|
||||
Assert.equal(0, results.length, "The tag folder was not returned.");
|
||||
|
||||
yield PlacesUtils.bookmarks.eraseEverything();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user