diff --git a/services/sync/modules/engines/bookmarks.js b/services/sync/modules/engines/bookmarks.js index e0b372f90efb..98796a874ffc 100644 --- a/services/sync/modules/engines/bookmarks.js +++ b/services/sync/modules/engines/bookmarks.js @@ -529,22 +529,27 @@ BookmarksStore.prototype = { } tags.containerOpen = true; - for (let i = 0; i < tags.childCount; i++) { - let child = tags.getChild(i); - if (child.title == tag) { - // Found the tag, so fix up the query to use the right id. - this._log.debug("Tag query folder: " + tag + " = " + child.itemId); - - this._log.trace("Replacing folders in: " + uri); - for each (let q in queriesRef.value) - q.setFolders([child.itemId], 1); - - record.bmkUri = Svc.History.queriesToQueryString(queriesRef.value, - queryCountRef.value, - optionsRef.value); - return; + try { + for (let i = 0; i < tags.childCount; i++) { + let child = tags.getChild(i); + if (child.title == tag) { + // Found the tag, so fix up the query to use the right id. + this._log.debug("Tag query folder: " + tag + " = " + child.itemId); + + this._log.trace("Replacing folders in: " + uri); + for each (let q in queriesRef.value) + q.setFolders([child.itemId], 1); + + record.bmkUri = Svc.History.queriesToQueryString(queriesRef.value, + queryCountRef.value, + optionsRef.value); + return; + } } } + finally { + tags.containerOpen = false; + } }, applyIncoming: function BStore_applyIncoming(record) { @@ -1245,12 +1250,16 @@ BookmarksStore.prototype = { !this._ls.isLivemark(node.itemId)) { node.QueryInterface(Ci.nsINavHistoryQueryResultNode); node.containerOpen = true; - - // Remember all the children GUIDs and recursively get more - for (let i = 0; i < node.childCount; i++) { - let child = node.getChild(i); - items[this.GUIDForId(child.itemId)] = true; - this._getChildren(child, items); + try { + // Remember all the children GUIDs and recursively get more + for (let i = 0; i < node.childCount; i++) { + let child = node.getChild(i); + items[this.GUIDForId(child.itemId)] = true; + this._getChildren(child, items); + } + } + finally { + node.containerOpen = false; } } diff --git a/services/sync/tests/unit/test_bookmark_places_query_rewriting.js b/services/sync/tests/unit/test_bookmark_places_query_rewriting.js index 0278d3045cd5..ca9232fa0c81 100644 --- a/services/sync/tests/unit/test_bookmark_places_query_rewriting.js +++ b/services/sync/tests/unit/test_bookmark_places_query_rewriting.js @@ -33,7 +33,8 @@ function run_test() { if (child.title == "bar") tagID = child.itemId; } - + tags.containerOpen = false; + _("Tag ID: " + tagID); do_check_eq(tagRecord.bmkUri, uri.replace("499", tagID)); diff --git a/services/sync/tests/unit/test_bookmark_tracker.js b/services/sync/tests/unit/test_bookmark_tracker.js index 63aad33633d1..1efb41b69492 100644 --- a/services/sync/tests/unit/test_bookmark_tracker.js +++ b/services/sync/tests/unit/test_bookmark_tracker.js @@ -147,13 +147,16 @@ function test_copying_places() { do_check_true(!!b1GUID); _("Make sure the destination folder is empty."); - do_check_eq(PlacesUtils.getFolderContents(f2, false, true).root.childCount, 0); + let root = PlacesUtils.getFolderContents(f2, false, true).root; + do_check_eq(root.childCount, 0); + root.containerOpen = false; - let f1Node = PlacesUtils.getFolderContents(f1, false, false); - _("Node to copy: " + f1Node.root.itemId); + let f1Node = PlacesUtils.getFolderContents(f1, false, false).root; + _("Node to copy: " + f1Node.itemId); - let serialized = PlacesUtils.wrapNode(f1Node.root, PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER); + let serialized = PlacesUtils.wrapNode(f1Node, PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER); _("Serialized to " + serialized); + f1Node.containerOpen = false; let raw = PlacesUtils.unwrapNodes(serialized, PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER).shift(); let transaction = getFolderCopyTransaction(raw, f2, Svc.Bookmark.DEFAULT_INDEX, true); @@ -162,11 +165,11 @@ function test_copying_places() { ptm.doTransaction(transaction); _("Verify that items have been copied."); - let f2Node = PlacesUtils.getFolderContents(f2, false, true); - do_check_eq(f2Node.root.childCount, 1); + let f2Node = PlacesUtils.getFolderContents(f2, false, true).root; + do_check_eq(f2Node.childCount, 1); _("Verify that the copied folder has different GUIDs."); - let c0 = f2Node.root.getChild(0); + let c0 = f2Node.getChild(0); do_check_eq(c0.title, "Folder One"); do_check_neq(c0.itemId, f1); do_check_neq(store.GUIDForId(c0.itemId), f1GUID); @@ -183,6 +186,8 @@ function test_copying_places() { do_check_neq(b0.itemId, b1); do_check_neq(store.GUIDForId(b0.itemId), b1GUID); + c0.containerOpen = false; + f2Node.containerOpen = false; } finally { tracker.clearChangedIDs(); Svc.Obs.notify("weave:engine:stop-tracking"); diff --git a/services/sync/tests/unit/test_history_store.js b/services/sync/tests/unit/test_history_store.js index 489b4a4510d9..d71ecdb19c65 100644 --- a/services/sync/tests/unit/test_history_store.js +++ b/services/sync/tests/unit/test_history_store.js @@ -15,6 +15,7 @@ function queryPlaces(uri, options) { let results = []; for (let i = 0; i < res.root.childCount; i++) results.push(res.root.getChild(i)); + res.root.containerOpen = false; return results; }