Bug 524219 - Renaming a tag in the Library doesn't show its new name until the Library gets reopened. r=mak.

This commit is contained in:
Asaf Romano 2009-10-28 15:34:09 +02:00
parent e910159d1a
commit bbc370f4a7
2 changed files with 36 additions and 14 deletions

View File

@ -3060,11 +3060,19 @@ nsNavHistoryQueryResultNode::OnItemChanged(PRInt64 aItemId,
// For example, when a title of a bookmark changes, we want that to refresh.
if (mLiveUpdate == QUERYUPDATE_COMPLEX_WITH_BOOKMARKS) {
// Make sure it's not a folder or a separator.
if (aItemType != nsINavBookmarksService::TYPE_BOOKMARK)
return NS_OK;
(void)Refresh();
switch (aItemType) {
case nsINavBookmarksService::TYPE_SEPARATOR:
// No separators in queries.
return NS_OK;
case nsINavBookmarksService::TYPE_FOLDER:
// Queries never result as "folders", but the tags-query results as
// special "tag" containers, which should follow their corresponding
// folders titles.
if (mOptions->ResultType() != nsINavHistoryQueryOptions::RESULTS_AS_TAG_QUERY)
return NS_OK;
default:
(void)Refresh();
}
}
else {
NS_WARNING("history observers should not get OnItemChanged, but should get the corresponding history notifications instead");

View File

@ -91,30 +91,44 @@ function run_test() {
// change bookmark 1 title
bmsvc.setItemTitle(bookmark1id, "new title 1");
// check that tag container contains new title
// Query the tag.
options = histsvc.getNewQueryOptions();
options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
options.resultType = options.RESULTS_AS_TAG_CONTENTS;
options.resultType = options.RESULTS_AS_TAG_QUERY;
query = histsvc.getNewQuery();
query.setFolders([tagItemId], 1);
result = histsvc.executeQuery(query, options);
var root = result.root;
root.containerOpen = true;
var cc = root.childCount;
do_check_eq(cc, 1);
var node = root.getChild(0);
do_check_eq(root.childCount, 1);
var theTag = root.getChild(0)
.QueryInterface(Ci.nsINavHistoryContainerResultNode);
// Bug 524219: Check that renaming the tag shows up in the result.
do_check_eq(theTag.title, "foo")
bmsvc.setItemTitle(tagItemId, "bar");
// Check that the item has been replaced
do_check_neq(theTag, root.getChild(0));
var theTag = root.getChild(0)
.QueryInterface(Ci.nsINavHistoryContainerResultNode);
do_check_eq(theTag.title, "bar");
// Check that tag container contains new title
theTag.containerOpen = true;
do_check_eq(theTag.childCount, 1);
var node = theTag.getChild(0);
do_check_eq(node.title, "new title 1");
root.containerOpen = false;
// change bookmark 2 title
// Change bookmark 2 title.
bmsvc.setItemTitle(bookmark2id, "new title 2");
// Workaround VM timers issues.
var bookmark1LastMod = bmsvc.getItemLastModified(bookmark1id);
bmsvc.setItemLastModified(bookmark2id, bookmark1LastMod + 1);
// check that tag container contains new title
// Check that tag container contains new title
options = histsvc.getNewQueryOptions();
options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
options.resultType = options.RESULTS_AS_TAG_CONTENTS;