Bug 1064365 - Deprecated GetKeywordForURI. r=mak
--- a/toolkit/components/places/nsNavBookmarks.cpp
+++ b/toolkit/components/places/nsNavBookmarks.cpp
@@ -2514,16 +2514,18 @@ nsNavBookmarks::SetKeywordForBookmark(in
return NS_OK;
}
NS_IMETHODIMP
nsNavBookmarks::GetKeywordForURI(nsIURI* aURI, nsAString& aKeyword)
{
+ PLACES_WARN_DEPRECATED();
+
NS_ENSURE_ARG(aURI);
aKeyword.Truncate(0);
nsCOMPtr<mozIStorageStatement> stmt = mDB->GetStatement(
"SELECT k.keyword "
"FROM moz_places h "
"JOIN moz_bookmarks b ON b.fk = h.id "
"JOIN moz_keywords k ON k.id = b.keyword_id "
--- a/toolkit/components/places/tests/bookmarks/test_bookmarks.js
+++ b/toolkit/components/places/tests/bookmarks/test_bookmarks.js
@@ -343,20 +343,16 @@ add_task(function test_bookmarks() {
do_throw("setKeywordForBookmark: " + ex);
}
let lastModified3 = bs.getItemLastModified(kwTestItemId);
// test getKeywordForBookmark
let k = bs.getKeywordForBookmark(kwTestItemId);
do_check_eq("bar", k);
- // test getKeywordForURI
- k = bs.getKeywordForURI(uri("http://keywordtest.com/"));
- do_check_eq("bar", k);
-
// test getURIForKeyword
let u = bs.getURIForKeyword("bar");
do_check_eq("http://keywordtest.com/", u.spec);
// test removeFolderChildren
// 1) add/remove each child type (bookmark, separator, folder)
tmpFolder = bs.createFolder(testRoot, "removeFolderChildren",
bs.DEFAULT_INDEX);
--- a/toolkit/components/places/tests/bookmarks/test_keywords.js
+++ b/toolkit/components/places/tests/bookmarks/test_keywords.js
@@ -6,18 +6,26 @@ function check_bookmark_keyword(aItemId,
let keyword = aKeyword ? aKeyword.toLowerCase() : null;
do_check_eq(PlacesUtils.bookmarks.getKeywordForBookmark(aItemId),
keyword);
}
function check_uri_keyword(aURI, aKeyword)
{
let keyword = aKeyword ? aKeyword.toLowerCase() : null;
- do_check_eq(PlacesUtils.bookmarks.getKeywordForURI(aURI),
- keyword);
+
+ for (let bm of PlacesUtils.getBookmarksForURI(aURI)) {
+ let kid = PlacesUtils.bookmarks.getKeywordForBookmark(bm);
+ if (kid && !keyword) {
+ Assert.ok(false, `${aURI.spec} should not have a keyword`);
+ } else if (keyword && kid == keyword) {
+ Assert.equal(kid, keyword, "Found the keyword");
+ break;
+ }
+ }
if (aKeyword) {
// This API can't tell which uri the user wants, so it returns a random one.
let re = /http:\/\/test[0-9]\.mozilla\.org/;
let url = PlacesUtils.bookmarks.getURIForKeyword(aKeyword).spec;
do_check_true(re.test(url));
// Check case insensitivity.
url = PlacesUtils.bookmarks.getURIForKeyword(aKeyword.toUpperCase()).spec
--- a/toolkit/components/places/tests/browser/browser_bug248970.js
+++ b/toolkit/components/places/tests/browser/browser_bug248970.js
@@ -83,18 +83,16 @@ add_task(function () {
bookmarkUri,
PlacesUtils.bookmarks.DEFAULT_INDEX,
bookmarkTitle);
PlacesUtils.bookmarks.setKeywordForBookmark(id, bookmarkKeyword);
count++;
ok(PlacesUtils.bookmarks.isBookmarked(bookmarkUri),
"Bookmark should be bookmarked, data should be retrievable");
- is(bookmarkKeyword, PlacesUtils.bookmarks.getKeywordForURI(bookmarkUri),
- "Check bookmark uri keyword");
is(getPlacesItemsCount(), count,
"Check the new bookmark items count");
is(isBookmarkAltered(), false, "Check if bookmark has been visited");
}
// Test on windows.
yield testOnWindow(false);
yield testOnWindow(true);