Bug 1064365 - Deprecated GetKeywordForURI. r=mak
authorAkshendra Pratap <akshendra521994@gmail.com>
Fri, 31 Oct 2014 06:35:00 +0100
changeset 213745 6a7f104d30c83cff93487d004986cef19b7de005
parent 213744 c9cf7f0d8a2127f45116bc1526660e8cea53c01a
child 213746 aa13d320bff02736996f088f1abf5169803a5c2f
push id27760
push userryanvm@gmail.com
push dateMon, 03 Nov 2014 21:48:30 +0000
treeherdermozilla-central@a458860efad7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1064365
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1064365 - Deprecated GetKeywordForURI. r=mak
toolkit/components/places/nsNavBookmarks.cpp
toolkit/components/places/tests/bookmarks/test_bookmarks.js
toolkit/components/places/tests/bookmarks/test_keywords.js
toolkit/components/places/tests/browser/browser_bug248970.js
--- 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);