Bug 457681 - if ExcludeReadOnlyFolders is false, readonly dynamic containers are still excluded, r=dietrich

This commit is contained in:
Marco Bonardo 2008-10-13 17:58:36 +02:00
parent b1351fc910
commit 56441e9d6e
2 changed files with 28 additions and 10 deletions

View File

@ -1470,7 +1470,7 @@ nsNavBookmarks::RemoveFolder(PRInt64 aFolderId)
// If this is a container bookmark, try to notify its service.
if (folderType.Length() > 0) {
// There is a type associated with this folder; it's a livemark.
// There is a type associated with this folder.
nsCOMPtr<nsIDynamicContainer> bmcServ = do_GetService(folderType.get());
if (bmcServ) {
rv = bmcServ->OnContainerRemoving(aFolderId);
@ -2066,6 +2066,8 @@ nsNavBookmarks::QueryFolderChildren(PRInt64 aFolderId,
PRBool results;
nsCOMPtr<nsNavHistoryQueryOptions> options = do_QueryInterface(aOptions, &rv);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 index = -1;
while (NS_SUCCEEDED(mDBGetChildren->ExecuteStep(&results)) && results) {
@ -2093,8 +2095,7 @@ nsNavBookmarks::QueryFolderChildren(PRInt64 aFolderId,
continue;
}
} else if (itemType == TYPE_FOLDER || itemType == TYPE_DYNAMIC_CONTAINER) {
if (itemType == TYPE_DYNAMIC_CONTAINER ||
(itemType == TYPE_FOLDER && options->ExcludeReadOnlyFolders())) {
if (options->ExcludeReadOnlyFolders()) {
// see if it's read only and skip it
PRBool readOnly = PR_FALSE;
GetFolderReadonly(id, &readOnly);

View File

@ -21,6 +21,7 @@
*
* Contributor(s):
* Asaf Romano <mano@mozilla.com> (Original Author)
* Marco Bonardo <mak77@bonardo.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -36,13 +37,16 @@
*
* ***** END LICENSE BLOCK ***** */
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
var annosvc = Cc["@mozilla.org/browser/annotation-service;1"].
getService(Ci.nsIAnnotationService);
try {
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
var annosvc = Cc["@mozilla.org/browser/annotation-service;1"].
getService(Ci.nsIAnnotationService);
} catch (ex) {
do_throw("Could not get services\n");
}
// main
function run_test() {
// load our dynamic-container sample service
@ -84,4 +88,17 @@ function run_test() {
// check live update of a folder exposed within a remote container
bmsvc.insertBookmark(exposedFolder, uri("http://uri2.tld"), bmsvc.DEFAULT_INDEX, "");
do_check_eq(folder.childCount, 2);
// Bug 457681
// Make the dynamic container read-only and check that it appear in the result
bmsvc.setFolderReadonly(remoteContainer, true);
options = histsvc.getNewQueryOptions();
query = histsvc.getNewQuery();
query.setFolders([testRoot], 1);
result = histsvc.executeQuery(query, options);
rootNode = result.root;
rootNode.containerOpen = true;
do_check_eq(rootNode.childCount, 2);
do_check_eq(rootNode.getChild(1).title, "remote container sample");
rootNode.containerOpen = false;
}