mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-12 09:01:16 +00:00
Bug 590081 - keywords matching is no longer case insensitive. r=dietrich a=blocking
This commit is contained in:
parent
a6847057fb
commit
7224a0920b
@ -2773,7 +2773,7 @@ nsNavBookmarks::UpdateKeywordsHashForRemovedBookmark(PRInt64 aItemId)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNavBookmarks::SetKeywordForBookmark(PRInt64 aBookmarkId,
|
||||
const nsAString& aKeyword)
|
||||
const nsAString& aUserCasedKeyword)
|
||||
{
|
||||
NS_ENSURE_ARG_MIN(aBookmarkId, 1);
|
||||
|
||||
@ -2781,7 +2781,7 @@ nsNavBookmarks::SetKeywordForBookmark(PRInt64 aBookmarkId,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Shortcuts are always lowercased internally.
|
||||
nsAutoString keyword(aKeyword);
|
||||
nsAutoString keyword(aUserCasedKeyword);
|
||||
ToLowerCase(keyword);
|
||||
|
||||
// Check if bookmark was already associated to a keyword.
|
||||
@ -2899,21 +2899,22 @@ nsNavBookmarks::GetKeywordForBookmark(PRInt64 aBookmarkId, nsAString& aKeyword)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNavBookmarks::GetURIForKeyword(const nsAString& aKeyword, nsIURI** aURI)
|
||||
nsNavBookmarks::GetURIForKeyword(const nsAString& aUserCasedKeyword,
|
||||
nsIURI** aURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
NS_ENSURE_TRUE(!aKeyword.IsEmpty(), NS_ERROR_INVALID_ARG);
|
||||
NS_ENSURE_TRUE(!aUserCasedKeyword.IsEmpty(), NS_ERROR_INVALID_ARG);
|
||||
*aURI = nsnull;
|
||||
|
||||
// Shortcuts are always lowercased internally.
|
||||
nsAutoString keyword(aKeyword);
|
||||
nsAutoString keyword(aUserCasedKeyword);
|
||||
ToLowerCase(keyword);
|
||||
|
||||
nsresult rv = EnsureKeywordsHash();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
keywordSearchData searchData;
|
||||
searchData.keyword.Assign(aKeyword);
|
||||
searchData.keyword.Assign(keyword);
|
||||
searchData.itemId = -1;
|
||||
mBookmarkToKeywordHash.EnumerateRead(SearchBookmarkForKeyword, &searchData);
|
||||
|
||||
|
@ -40,6 +40,12 @@ let bs = PlacesUtils.bookmarks;
|
||||
let db = DBConn();
|
||||
|
||||
function check_keyword(aItemId, aExpectedBookmarkKeyword, aExpectedURIKeyword) {
|
||||
// All keywords are handled lowercased internally.
|
||||
if (aExpectedURIKeyword)
|
||||
aExpectedURIKeyword = aExpectedURIKeyword.toLowerCase();
|
||||
if (aExpectedBookmarkKeyword)
|
||||
aExpectedBookmarkKeyword = aExpectedBookmarkKeyword.toLowerCase();
|
||||
|
||||
if (aItemId) {
|
||||
print("Check keyword for bookmark");
|
||||
do_check_eq(bs.getKeywordForBookmark(aItemId), aExpectedBookmarkKeyword);
|
||||
@ -50,8 +56,11 @@ function check_keyword(aItemId, aExpectedBookmarkKeyword, aExpectedURIKeyword) {
|
||||
|
||||
print("Check uri for keyword");
|
||||
// This API can't tell which uri the user wants, so it returns a random one.
|
||||
if (aExpectedURIKeyword)
|
||||
if (aExpectedURIKeyword) {
|
||||
do_check_true(/http:\/\/test[0-9]\.mozilla\.org/.test(bs.getURIForKeyword(aExpectedURIKeyword).spec));
|
||||
// Check case insensitivity.
|
||||
do_check_true(/http:\/\/test[0-9]\.mozilla\.org/.test(bs.getURIForKeyword(aExpectedURIKeyword.toUpperCase()).spec));
|
||||
}
|
||||
}
|
||||
else {
|
||||
stmt = db.createStatement(
|
||||
@ -93,6 +102,8 @@ function run_test() {
|
||||
check_keyword(itemId1, null, null);
|
||||
bs.setKeywordForBookmark(itemId1, "keyword");
|
||||
check_keyword(itemId1, "keyword", "keyword");
|
||||
// Check case insensitivity.
|
||||
check_keyword(itemId1, "kEyWoRd", "kEyWoRd");
|
||||
|
||||
print("Add another bookmark with the same uri, should not inherit keyword.");
|
||||
let itemId1_bis = bs.insertBookmark(folderId,
|
||||
@ -101,6 +112,8 @@ function run_test() {
|
||||
"test1_bis");
|
||||
|
||||
check_keyword(itemId1_bis, null, "keyword");
|
||||
// Check case insensitivity.
|
||||
check_keyword(itemId1_bis, null, "kEyWoRd");
|
||||
|
||||
print("Set same keyword on another bookmark with a different uri.");
|
||||
let itemId2 = bs.insertBookmark(folderId,
|
||||
@ -108,7 +121,9 @@ function run_test() {
|
||||
bs.DEFAULT_INDEX,
|
||||
"test2");
|
||||
check_keyword(itemId2, null, null);
|
||||
bs.setKeywordForBookmark(itemId2, "keyword");
|
||||
bs.setKeywordForBookmark(itemId2, "kEyWoRd");
|
||||
check_keyword(itemId1, "kEyWoRd", "kEyWoRd");
|
||||
// Check case insensitivity.
|
||||
check_keyword(itemId1, "keyword", "keyword");
|
||||
check_keyword(itemId1_bis, null, "keyword");
|
||||
check_keyword(itemId2, "keyword", "keyword");
|
||||
|
Loading…
Reference in New Issue
Block a user