Bug 1212633 - include mobile and unfiled folders in Sync's concept of 'all IDs'. r=rnewman, a=sylvestre
--- a/services/sync/modules/engines/bookmarks.js
+++ b/services/sync/modules/engines/bookmarks.js
@@ -1319,17 +1319,25 @@ BookmarksStore.prototype = {
PlacesUtils.tagging.tagURI(dummyURI, tags);
PlacesUtils.tagging.untagURI(bookmarkURI, null);
PlacesUtils.tagging.tagURI(bookmarkURI, tags);
PlacesUtils.tagging.untagURI(dummyURI, null);
},
getAllIDs: function BStore_getAllIDs() {
let items = {"menu": true,
- "toolbar": true};
+ "toolbar": true,
+ "unfiled": true,
+ };
+ // We also want "mobile" but only if a local mobile folder already exists
+ // (otherwise we'll later end up creating it, which we want to avoid until
+ // we actually need it.)
+ if (kSpecialIds.findMobileRoot(false)) {
+ items["mobile"] = true;
+ }
for each (let guid in kSpecialIds.guids) {
if (guid != "places" && guid != "tags")
this._getChildren(guid, items);
}
return items;
},
wipe: function BStore_wipe() {
--- a/services/sync/tests/unit/test_bookmark_engine.js
+++ b/services/sync/tests/unit/test_bookmark_engine.js
@@ -222,17 +222,17 @@ add_task(function test_restorePromptsReu
error = ex;
_("Got error: " + Utils.exceptionStr(ex));
}
do_check_true(!error);
_("Verify that there's only one bookmark on the server, and it's Thunderbird.");
// Of course, there's also the Bookmarks Toolbar and Bookmarks Menu...
let wbos = collection.keys(function (id) {
- return ["menu", "toolbar", "mobile", folder1_guid].indexOf(id) == -1;
+ return ["menu", "toolbar", "mobile", "unfiled", folder1_guid].indexOf(id) == -1;
});
do_check_eq(wbos.length, 1);
do_check_eq(wbos[0], bmk2_guid);
_("Now restore from a backup.");
yield BookmarkJSONUtils.importFromFile(backupFile, true);
_("Ensure we have the bookmarks we expect locally.");
@@ -252,17 +252,17 @@ add_task(function test_restorePromptsReu
newFX = guid; // Save the new GUID after restore.
found = true; // Only runs if the above check passes.
}
}
_("We found it: " + found);
do_check_true(found);
_("Have the correct number of IDs locally, too.");
- do_check_eq(count, ["menu", "toolbar", folder1_id, bmk1_id].length);
+ do_check_eq(count, ["menu", "toolbar", "mobile", "unfiled", folder1_id, bmk1_id].length);
_("Sync again. This'll wipe bookmarks from the server.");
try {
engine.sync();
} catch(ex) {
error = ex;
_("Got error: " + Utils.exceptionStr(ex));
}
@@ -272,17 +272,19 @@ add_task(function test_restorePromptsReu
// Of course, there's also the Bookmarks Toolbar and Bookmarks Menu...
let payloads = server.user("foo").collection("bookmarks").payloads();
let bookmarkWBOs = payloads.filter(function (wbo) {
return wbo.type == "bookmark";
});
let folderWBOs = payloads.filter(function (wbo) {
return ((wbo.type == "folder") &&
(wbo.id != "menu") &&
- (wbo.id != "toolbar"));
+ (wbo.id != "toolbar") &&
+ (wbo.id != "unfiled") &&
+ (wbo.id != "mobile"));
});
do_check_eq(bookmarkWBOs.length, 1);
do_check_eq(bookmarkWBOs[0].id, newFX);
do_check_eq(bookmarkWBOs[0].bmkUri, fxuri.spec);
do_check_eq(bookmarkWBOs[0].title, "Get Firefox!");
_("Our old friend Folder 1 is still in play.");
--- a/services/sync/tests/unit/test_bookmark_smart_bookmarks.js
+++ b/services/sync/tests/unit/test_bookmark_smart_bookmarks.js
@@ -107,17 +107,17 @@ add_test(function test_annotation_upload
do_check_eq(smartBookmarkCount(), startCount + 1);
_("Sync record to the server.");
let collection = server.user("foo").collection("bookmarks");
try {
engine.sync();
let wbos = collection.keys(function (id) {
- return ["menu", "toolbar", "mobile"].indexOf(id) == -1;
+ return ["menu", "toolbar", "mobile", "unfiled"].indexOf(id) == -1;
});
do_check_eq(wbos.length, 1);
_("Verify that the server WBO has the annotation.");
let serverGUID = wbos[0];
do_check_eq(serverGUID, guid);
let serverWBO = collection.wbo(serverGUID);
do_check_true(!!serverWBO);