Bug 1486808 - Remove nsINavBookmarksService::unfiledBookmarksFolder and PlacesUtils.unfiledBookmarksFolderId. r=mak
authorMark Banner <standard8@mozilla.com>
Thu, 30 Aug 2018 08:47:46 +0000
changeset 434037 9de4c7559795
parent 434036 bc21091cba69
child 434038 964610ef7e3f
push id34536
push usernbeleuzu@mozilla.com
push dateThu, 30 Aug 2018 16:57:50 +0000
treeherdermozilla-central@91dc93fd9245 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1486808
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1486808 - Remove nsINavBookmarksService::unfiledBookmarksFolder and PlacesUtils.unfiledBookmarksFolderId. r=mak Differential Revision: https://phabricator.services.mozilla.com/D4456
browser/components/places/tests/browser/browser_controller_onDrop_tagFolder.js
toolkit/components/places/PlacesDBUtils.jsm
toolkit/components/places/PlacesUtils.jsm
toolkit/components/places/nsINavBookmarksService.idl
toolkit/components/places/nsNavBookmarks.cpp
toolkit/components/places/tests/bookmarks/test_bookmarks_notifications.js
toolkit/components/places/tests/bookmarks/test_bookmarkstree_cache.js
toolkit/components/places/tests/bookmarks/test_nsINavBookmarkObserver.js
toolkit/components/places/tests/head_common.js
toolkit/components/places/tests/legacy/test_bookmarks.js
toolkit/components/places/tests/maintenance/test_preventive_maintenance.js
toolkit/components/places/tests/sync/test_bookmark_kinds.js
toolkit/components/places/tests/sync/test_bookmark_structure_changes.js
toolkit/components/places/tests/sync/test_bookmark_value_changes.js
toolkit/components/places/tests/unit/test_mozIAsyncLivemarks.js
--- a/browser/components/places/tests/browser/browser_controller_onDrop_tagFolder.js
+++ b/browser/components/places/tests/browser/browser_controller_onDrop_tagFolder.js
@@ -60,17 +60,16 @@ async function run_drag_test(startBookma
       isTag: true,
       tagName: TAG_NAME,
       orientation: Ci.nsITreeView.DROP_ON,
     });
 
     let bookmarkWithId = JSON.stringify(Object.assign({
       id: bookmarkId,
       itemGuid: dragBookmark.guid,
-      parent: PlacesUtils.unfiledBookmarksFolderId,
       uri: dragBookmark.url,
     }, dragBookmark));
 
     let dt = {
       dropEffect: "move",
       mozCursor: "auto",
       mozItemCount: 1,
       types: [ PlacesUtils.TYPE_X_MOZ_PLACE ],
--- a/toolkit/components/places/PlacesDBUtils.jsm
+++ b/toolkit/components/places/PlacesDBUtils.jsm
@@ -450,26 +450,25 @@ var PlacesDBUtils = {
           unfiledGuid: PlacesUtils.bookmarks.unfiledGuid,
           tagsGuid: PlacesUtils.bookmarks.tagsGuid,
         },
       },
 
       // D.4 move orphan items to unsorted folder
       { query:
         `UPDATE moz_bookmarks SET
-          parent = :unsorted_folder
+          parent = (SELECT id FROM moz_bookmarks WHERE guid = :unfiledGuid)
         WHERE guid NOT IN (
           :rootGuid, :menuGuid, :toolbarGuid, :unfiledGuid, :tagsGuid  /* skip roots */
         ) AND id IN (
           SELECT b.id FROM moz_bookmarks b
           WHERE NOT EXISTS
             (SELECT id FROM moz_bookmarks WHERE id = b.parent LIMIT 1)
         )`,
         params: {
-          unsorted_folder: PlacesUtils.unfiledBookmarksFolderId,
           rootGuid: PlacesUtils.bookmarks.rootGuid,
           menuGuid: PlacesUtils.bookmarks.menuGuid,
           toolbarGuid: PlacesUtils.bookmarks.toolbarGuid,
           unfiledGuid: PlacesUtils.bookmarks.unfiledGuid,
           tagsGuid: PlacesUtils.bookmarks.tagsGuid,
         },
       },
 
@@ -525,28 +524,27 @@ var PlacesDBUtils = {
         },
       },
 
       // D.9 fix wrong parents
       // Items cannot have separators or other bookmarks
       // as parent, if they have bad parent move them to unsorted bookmarks.
       { query:
         `UPDATE moz_bookmarks SET
-          parent = :unsorted_folder
+          parent = (SELECT id FROM moz_bookmarks WHERE guid = :unfiledGuid)
         WHERE guid NOT IN (
           :rootGuid, :menuGuid, :toolbarGuid, :unfiledGuid, :tagsGuid  /* skip roots */
         ) AND id IN (
           SELECT id FROM moz_bookmarks b
           WHERE EXISTS
             (SELECT id FROM moz_bookmarks WHERE id = b.parent
               AND type IN (:bookmark_type, :separator_type)
               LIMIT 1)
         )`,
         params: {
-          unsorted_folder: PlacesUtils.unfiledBookmarksFolderId,
           bookmark_type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
           separator_type: PlacesUtils.bookmarks.TYPE_SEPARATOR,
           rootGuid: PlacesUtils.bookmarks.rootGuid,
           menuGuid: PlacesUtils.bookmarks.menuGuid,
           toolbarGuid: PlacesUtils.bookmarks.toolbarGuid,
           unfiledGuid: PlacesUtils.bookmarks.unfiledGuid,
           tagsGuid: PlacesUtils.bookmarks.tagsGuid,
         },
--- a/toolkit/components/places/PlacesUtils.jsm
+++ b/toolkit/components/places/PlacesUtils.jsm
@@ -1273,21 +1273,16 @@ var PlacesUtils = {
     return this.toolbarFolderId = this.bookmarks.toolbarFolder;
   },
 
   get tagsFolderId() {
     delete this.tagsFolderId;
     return this.tagsFolderId = this.bookmarks.tagsFolder;
   },
 
-  get unfiledBookmarksFolderId() {
-    delete this.unfiledBookmarksFolderId;
-    return this.unfiledBookmarksFolderId = this.bookmarks.unfiledBookmarksFolder;
-  },
-
   /**
    * Checks if item is a root.
    *
    * @param {String} guid The guid of the item to look for.
    * @returns {Boolean} true if guid is a root, false otherwise.
    */
   isRootItem(guid) {
     return guid == PlacesUtils.bookmarks.menuGuid ||
--- a/toolkit/components/places/nsINavBookmarksService.idl
+++ b/toolkit/components/places/nsINavBookmarksService.idl
@@ -281,21 +281,16 @@ interface nsINavBookmarksService : nsISu
    */
   readonly attribute long long bookmarksMenuFolder;
 
   /**
    * The item ID of the top-level folder that contain the tag "folders".
    */
   readonly attribute long long tagsFolder;
 
- /**
-  * The item ID of the unfiled-bookmarks folder.
-  */
-  readonly attribute long long unfiledBookmarksFolder;
-
   /**
    * The item ID of the personal toolbar folder.
    */
   readonly attribute long long toolbarFolder;
 
   /**
    * The total number of Sync changes (inserts, updates, deletes, merges, and
    * uploads) recorded since Places startup for all bookmarks.
--- a/toolkit/components/places/nsNavBookmarks.cpp
+++ b/toolkit/components/places/nsNavBookmarks.cpp
@@ -336,26 +336,16 @@ nsNavBookmarks::GetTagsFolder(int64_t* a
   int64_t id = mDB->GetTagsFolderId();
   NS_ENSURE_TRUE(id > 0, NS_ERROR_UNEXPECTED);
   *aRoot = id;
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
-nsNavBookmarks::GetUnfiledBookmarksFolder(int64_t* aRoot)
-{
-  int64_t id = mDB->GetUnfiledFolderId();
-  NS_ENSURE_TRUE(id > 0, NS_ERROR_UNEXPECTED);
-  *aRoot = id;
-  return NS_OK;
-}
-
-
-NS_IMETHODIMP
 nsNavBookmarks::GetTotalSyncChanges(int64_t* aTotalSyncChanges)
 {
   *aTotalSyncChanges = sTotalSyncChanges;
   return NS_OK;
 }
 
 
 nsresult
--- a/toolkit/components/places/tests/bookmarks/test_bookmarks_notifications.js
+++ b/toolkit/components/places/tests/bookmarks/test_bookmarks_notifications.js
@@ -214,17 +214,17 @@ add_task(async function update_move_same
 
 add_task(async function update_move_different_folder() {
   let bm = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
                                                 parentGuid: PlacesUtils.bookmarks.unfiledGuid,
                                                 url: new URL("http://move.example.com/") });
   let folder = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_FOLDER,
                                                     parentGuid: PlacesUtils.bookmarks.unfiledGuid });
   let bmItemId = await PlacesUtils.promiseItemId(bm.guid);
-  let bmOldParentId = PlacesUtils.unfiledBookmarksFolderId;
+  let bmOldParentId = await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid);
   let bmOldIndex = bm.index;
 
   let observer = expectNotifications();
   bm = await PlacesUtils.bookmarks.update({ guid: bm.guid,
                                             parentGuid: folder.guid,
                                             index: PlacesUtils.bookmarks.DEFAULT_INDEX });
   Assert.equal(bm.index, 0);
   let bmNewParentId = await PlacesUtils.promiseItemId(folder.guid);
@@ -507,24 +507,26 @@ add_task(async function reorder_notifica
   // Randomly reorder the array.
   sorted.sort(() => 0.5 - Math.random());
 
   let observer = expectNotifications();
   await PlacesUtils.bookmarks.reorder(PlacesUtils.bookmarks.unfiledGuid,
                                       sorted.map(bm => bm.guid));
 
   let expectedNotifications = [];
+  let unfiledBookmarksFolderId =
+    await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid);
   for (let i = 0; i < sorted.length; ++i) {
     let child = sorted[i];
     let childId = await PlacesUtils.promiseItemId(child.guid);
     expectedNotifications.push({ name: "onItemMoved",
                                  arguments: [ childId,
-                                              PlacesUtils.unfiledBookmarksFolderId,
+                                              unfiledBookmarksFolderId,
                                               child.index,
-                                              PlacesUtils.unfiledBookmarksFolderId,
+                                              unfiledBookmarksFolderId,
                                               i,
                                               child.type,
                                               child.guid,
                                               child.parentGuid,
                                               child.parentGuid,
                                               Ci.nsINavBookmarksService.SOURCE_DEFAULT,
                                               child.url,
                                             ] });
--- a/toolkit/components/places/tests/bookmarks/test_bookmarkstree_cache.js
+++ b/toolkit/components/places/tests/bookmarks/test_bookmarkstree_cache.js
@@ -1,19 +1,21 @@
 
 // Bug 1192692 - promiseBookmarksTree caches items without adding observers to
 // invalidate the cache.
 add_task(async function boookmarks_tree_cache() {
   // Note that for this test to be effective, it needs to use the "old" sync
   // bookmarks methods - using, eg, PlacesUtils.bookmarks.insert() doesn't
   // demonstrate the problem as it indirectly arranges for the observers to
   // be added.
-  let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
-                                                uri("http://example.com"),
-                                                PlacesUtils.bookmarks.DEFAULT_INDEX,
-                                                "A title");
+  let id = PlacesUtils.bookmarks.insertBookmark(
+    await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid),
+    uri("http://example.com"),
+    PlacesUtils.bookmarks.DEFAULT_INDEX,
+    "A title");
+
   await PlacesUtils.promiseBookmarksTree();
 
   PlacesUtils.bookmarks.removeItem(id);
 
   await Assert.rejects(PlacesUtils.promiseItemGuid(id),
     /no item found for the given itemId/);
 });
--- a/toolkit/components/places/tests/bookmarks/test_nsINavBookmarkObserver.js
+++ b/toolkit/components/places/tests/bookmarks/test_nsINavBookmarkObserver.js
@@ -1,13 +1,15 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Tests that each nsINavBookmarksObserver method gets the correct input.
 
+var gUnfiledFolderId;
+
 var gBookmarksObserver = {
   expected: [],
   setup(expected) {
     this.expected = expected;
     this.deferred = PromiseUtils.defer();
     return this.deferred.promise;
   },
   validate(aMethodName, aArguments) {
@@ -91,33 +93,35 @@ var gBookmarkSkipObserver = {
     return this.validate("onItemMoved", arguments);
   },
 
   // nsISupports
   QueryInterface: ChromeUtils.generateQI([Ci.nsINavBookmarkObserver]),
 };
 
 
-add_task(function setup() {
+add_task(async function setup() {
   PlacesUtils.bookmarks.addObserver(gBookmarksObserver);
   PlacesUtils.bookmarks.addObserver(gBookmarkSkipObserver);
+
+  gUnfiledFolderId = await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid);
 });
 
 add_task(async function onItemAdded_bookmark() {
   const title = "Bookmark 1";
   let uri = Services.io.newURI("http://1.mozilla.org/");
   let promise = Promise.all([
     gBookmarkSkipObserver.setup([
       "onItemAdded",
     ]),
     gBookmarksObserver.setup([
       { name: "onItemAdded",
         args: [
           { name: "itemId", check: v => typeof(v) == "number" && v > 0 },
-          { name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
+          { name: "parentId", check: v => v === gUnfiledFolderId },
           { name: "index", check: v => v === 0 },
           { name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
           { name: "uri", check: v => v instanceof Ci.nsIURI && v.equals(uri) },
           { name: "title", check: v => v === title },
           { name: "dateAdded", check: v => typeof(v) == "number" && v > 0 },
           { name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "parentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "source", check: v => Object.values(PlacesUtils.bookmarks.SOURCES).includes(v) },
@@ -135,17 +139,17 @@ add_task(async function onItemAdded_sepa
   let promise = Promise.all([
     gBookmarkSkipObserver.setup([
       "onItemAdded",
     ]),
     gBookmarksObserver.setup([
       { name: "onItemAdded",
         args: [
           { name: "itemId", check: v => typeof(v) == "number" && v > 0 },
-          { name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
+          { name: "parentId", check: v => v === gUnfiledFolderId },
           { name: "index", check: v => v === 1 },
           { name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_SEPARATOR },
           { name: "uri", check: v => v === null },
           { name: "title", check: v => v === "" },
           { name: "dateAdded", check: v => typeof(v) == "number" && v > 0 },
           { name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "parentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "source", check: v => Object.values(PlacesUtils.bookmarks.SOURCES).includes(v) },
@@ -163,17 +167,17 @@ add_task(async function onItemAdded_fold
   let promise = Promise.all([
     gBookmarkSkipObserver.setup([
       "onItemAdded",
     ]),
     gBookmarksObserver.setup([
       { name: "onItemAdded",
         args: [
           { name: "itemId", check: v => typeof(v) == "number" && v > 0 },
-          { name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
+          { name: "parentId", check: v => v === gUnfiledFolderId },
           { name: "index", check: v => v === 2 },
           { name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_FOLDER },
           { name: "uri", check: v => v === null },
           { name: "title", check: v => v === title },
           { name: "dateAdded", check: v => typeof(v) == "number" && v > 0 },
           { name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "parentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "source", check: v => Object.values(PlacesUtils.bookmarks.SOURCES).includes(v) },
@@ -201,17 +205,17 @@ add_task(async function onItemChanged_ti
       { name: "onItemChanged",
         args: [
           { name: "itemId", check: v => typeof(v) == "number" && v > 0 },
           { name: "property", check: v => v === "title" },
           { name: "isAnno", check: v => v === false },
           { name: "newValue", check: v => v === title },
           { name: "lastModified", check: v => typeof(v) == "number" && v > 0 },
           { name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
-          { name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
+          { name: "parentId", check: v => v === gUnfiledFolderId },
           { name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "parentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "oldValue", check: v => typeof(v) == "string" },
           { name: "source", check: v => Object.values(PlacesUtils.bookmarks.SOURCES).includes(v) },
         ] },
   ])]);
   await PlacesUtils.bookmarks.update({ guid: bm.guid, title });
   await promise;
@@ -258,17 +262,17 @@ add_task(async function onItemChanged_ta
       { name: "onItemChanged",
         args: [
           { name: "itemId", check: v => typeof(v) == "number" && v > 0 },
           { name: "property", check: v => v === "tags" },
           { name: "isAnno", check: v => v === false },
           { name: "newValue", check: v => v === "" },
           { name: "lastModified", check: v => typeof(v) == "number" && v > 0 },
           { name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
-          { name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
+          { name: "parentId", check: v => v === gUnfiledFolderId },
           { name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "parentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "oldValue", check: v => typeof(v) == "string" },
           { name: "source", check: v => Object.values(PlacesUtils.bookmarks.SOURCES).includes(v) },
         ] },
       { name: "onItemRemoved", // This is the tag.
         args: [
           { name: "itemId", check: v => typeof(v) == "number" && v > 0 },
@@ -294,17 +298,17 @@ add_task(async function onItemChanged_ta
       { name: "onItemChanged",
         args: [
           { name: "itemId", check: v => typeof(v) == "number" && v > 0 },
           { name: "property", check: v => v === "tags" },
           { name: "isAnno", check: v => v === false },
           { name: "newValue", check: v => v === "" },
           { name: "lastModified", check: v => typeof(v) == "number" && v > 0 },
           { name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
-          { name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
+          { name: "parentId", check: v => v === gUnfiledFolderId },
           { name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "parentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "oldValue", check: v => typeof(v) == "string" },
           { name: "source", check: v => Object.values(PlacesUtils.bookmarks.SOURCES).includes(v) },
         ] },
   ])]);
   PlacesUtils.tagging.tagURI(uri, [TAG]);
   PlacesUtils.tagging.untagURI(uri, [TAG]);
@@ -319,33 +323,33 @@ add_task(async function onItemMoved_book
   let promise = Promise.all([
     gBookmarkSkipObserver.setup([
       "onItemMoved", "onItemMoved",
     ]),
     gBookmarksObserver.setup([
       { name: "onItemMoved",
         args: [
           { name: "itemId", check: v => typeof(v) == "number" && v > 0 },
-          { name: "oldParentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
+          { name: "oldParentId", check: v => v === gUnfiledFolderId },
           { name: "oldIndex", check: v => v === 0 },
           { name: "newParentId", check: v => v === PlacesUtils.toolbarFolderId },
           { name: "newIndex", check: v => v === 0 },
           { name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
           { name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "oldParentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "newParentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "source", check: v => Object.values(PlacesUtils.bookmarks.SOURCES).includes(v) },
           { name: "url", check: v => typeof(v) == "string" },
         ] },
       { name: "onItemMoved",
         args: [
           { name: "itemId", check: v => typeof(v) == "number" && v > 0 },
           { name: "oldParentId", check: v => v === PlacesUtils.toolbarFolderId },
           { name: "oldIndex", check: v => v === 0 },
-          { name: "newParentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
+          { name: "newParentId", check: v => v === gUnfiledFolderId },
           { name: "newIndex", check: v => v === 0 },
           { name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
           { name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "oldParentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "newParentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "source", check: v => Object.values(PlacesUtils.bookmarks.SOURCES).includes(v) },
           { name: "url", check: v => typeof(v) == "string" },
         ] },
@@ -376,17 +380,17 @@ add_task(async function onItemMoved_book
     gBookmarksObserver.setup([
       { name: "onItemVisited",
         args: [
           { name: "itemId", check: v => typeof(v) == "number" && v > 0 },
           { name: "visitId", check: v => typeof(v) == "number" && v > 0 },
           { name: "time", check: v => typeof(v) == "number" && v > 0 },
           { name: "transitionType", check: v => v === PlacesUtils.history.TRANSITION_TYPED },
           { name: "uri", check: v => v instanceof Ci.nsIURI && v.equals(uri) },
-          { name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
+          { name: "parentId", check: v => v === gUnfiledFolderId },
           { name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "parentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
         ] },
   ])]);
   await PlacesTestUtils.addVisits({ uri, transition: TRANSITION_TYPED });
   await promise;
 });
 
@@ -399,17 +403,17 @@ add_task(async function onItemRemoved_bo
   let promise = Promise.all([
     gBookmarkSkipObserver.setup([
       "onItemRemoved",
     ]),
     gBookmarksObserver.setup([
       { name: "onItemRemoved",
         args: [
           { name: "itemId", check: v => typeof(v) == "number" && v > 0 },
-          { name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
+          { name: "parentId", check: v => v === gUnfiledFolderId },
           { name: "index", check: v => v === 0 },
           { name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
           { name: "uri", check: v => v instanceof Ci.nsIURI && v.equals(uri) },
           { name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "parentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "source", check: v => Object.values(PlacesUtils.bookmarks.SOURCES).includes(v) },
         ] },
   ])]);
@@ -477,17 +481,17 @@ add_task(async function onItemRemoved_fo
     gBookmarkSkipObserver.setup([
       "onItemAdded", "onItemAdded", "onItemAdded", "onItemAdded",
       "onItemRemoved",
     ]),
     gBookmarksObserver.setup([
       { name: "onItemAdded",
         args: [
           { name: "itemId", check: v => typeof(v) == "number" && v > 0 },
-          { name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
+          { name: "parentId", check: v => v === gUnfiledFolderId },
           { name: "index", check: v => v === 0 },
           { name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_FOLDER },
           { name: "uri", check: v => v === null },
           { name: "title", check: v => v === title },
           { name: "dateAdded", check: v => typeof(v) == "number" && v > 0 },
           { name: "guid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "parentGuid", check: v => typeof(v) == "string" && PlacesUtils.isValidGuid(v) },
           { name: "source", check: v => Object.values(PlacesUtils.bookmarks.SOURCES).includes(v) },
--- a/toolkit/components/places/tests/head_common.js
+++ b/toolkit/components/places/tests/head_common.js
@@ -322,36 +322,16 @@ function visits_in_database(aURI) {
       return 0;
     return stmt.getInt64(0);
   } finally {
     stmt.finalize();
   }
 }
 
 /**
- * Checks that we don't have any bookmark
- */
-function check_no_bookmarks() {
-  let query = PlacesUtils.history.getNewQuery();
-  let folders = [
-    PlacesUtils.bookmarks.toolbarFolder,
-    PlacesUtils.bookmarks.bookmarksMenuFolder,
-    PlacesUtils.bookmarks.unfiledBookmarksFolder,
-  ];
-  query.setFolders(folders, 3);
-  let options = PlacesUtils.history.getNewQueryOptions();
-  options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
-  let root = PlacesUtils.history.executeQuery(query, options).root;
-  root.containerOpen = true;
-  if (root.childCount != 0)
-    do_throw("Unable to remove all bookmarks");
-  root.containerOpen = false;
-}
-
-/**
  * Allows waiting for an observer notification once.
  *
  * @param aTopic
  *        Notification topic to observe.
  *
  * @return {Promise}
  * @resolves The array [aSubject, aData] from the observed notification.
  * @rejects Never.
--- a/toolkit/components/places/tests/legacy/test_bookmarks.js
+++ b/toolkit/components/places/tests/legacy/test_bookmarks.js
@@ -78,17 +78,16 @@ var bmStartIndex = 0;
 add_task(async function test_bookmarks() {
   bs.addObserver(bookmarksObserver);
 
   // test special folders
   Assert.ok(bs.placesRoot > 0);
   Assert.ok(bs.bookmarksMenuFolder > 0);
   Assert.ok(bs.tagsFolder > 0);
   Assert.ok(bs.toolbarFolder > 0);
-  Assert.ok(bs.unfiledBookmarksFolder > 0);
 
   // test getFolderIdForItem() with bogus item id will throw
   try {
     bs.getFolderIdForItem(0);
     do_throw("getFolderIdForItem accepted bad input");
   } catch (ex) {}
 
   // test getFolderIdForItem() with bogus item id will throw
@@ -96,17 +95,16 @@ add_task(async function test_bookmarks()
     bs.getFolderIdForItem(-1);
     do_throw("getFolderIdForItem accepted bad input");
   } catch (ex) {}
 
   // test root parentage
   Assert.equal(bs.getFolderIdForItem(bs.bookmarksMenuFolder), bs.placesRoot);
   Assert.equal(bs.getFolderIdForItem(bs.tagsFolder), bs.placesRoot);
   Assert.equal(bs.getFolderIdForItem(bs.toolbarFolder), bs.placesRoot);
-  Assert.equal(bs.getFolderIdForItem(bs.unfiledBookmarksFolder), bs.placesRoot);
 
   // create a folder to hold all the tests
   // this makes the tests more tolerant of changes to default_places.html
   let testRoot = bs.createFolder(root, "places bookmarks xpcshell tests",
                                  bs.DEFAULT_INDEX);
   let testRootGuid = await PlacesUtils.promiseItemGuid(testRoot);
   Assert.equal(bookmarksObserver._itemAddedId, testRoot);
   Assert.equal(bookmarksObserver._itemAddedParent, root);
--- a/toolkit/components/places/tests/maintenance/test_preventive_maintenance.js
+++ b/toolkit/components/places/tests/maintenance/test_preventive_maintenance.js
@@ -13,17 +13,17 @@
 // Get services and database connection
 var hs = PlacesUtils.history;
 var bs = PlacesUtils.bookmarks;
 var ts = PlacesUtils.tagging;
 var as = PlacesUtils.annotations;
 var fs = PlacesUtils.favicons;
 
 var mDBConn = hs.DBConnection;
-
+var gUnfiledFolderId;
 // ------------------------------------------------------------------------------
 // Helpers
 
 var defaultBookmarksMaxId = 0;
 async function cleanDatabase() {
   // First clear any bookmarks the "proper way" to ensure caches like GuidHelper
   // are properly cleared.
   await PlacesUtils.bookmarks.eraseEverything();
@@ -82,17 +82,17 @@ function addBookmark(aPlaceId, aType, aP
                      aSyncChangeCounter = 0) {
   let stmt = mDBConn.createStatement(
     `INSERT INTO moz_bookmarks (fk, type, parent, keyword_id, folder_type,
                                 title, guid, syncStatus, syncChangeCounter)
      VALUES (:place_id, :type, :parent, :keyword_id, :folder_type, :title,
              :guid, :sync_status, :change_counter)`);
   stmt.params.place_id = aPlaceId || null;
   stmt.params.type = aType || bs.TYPE_BOOKMARK;
-  stmt.params.parent = aParent || bs.unfiledBookmarksFolder;
+  stmt.params.parent = aParent || gUnfiledFolderId;
   stmt.params.keyword_id = aKeywordId || null;
   stmt.params.folder_type = aFolderType || null;
   stmt.params.title = typeof(aTitle) == "string" ? aTitle : null;
   stmt.params.guid = aGuid;
   stmt.params.sync_status = aSyncStatus;
   stmt.params.change_counter = aSyncChangeCounter;
   stmt.execute();
   stmt.finalize();
@@ -553,32 +553,32 @@ tests.push({
     // Create a child of the last created folder
     this._bookmarkId = addBookmark(this._placeId, bs.TYPE_BOOKMARK, this._orphanFolderId);
   },
 
   async check() {
     // Check that bookmarks are now children of a real folder (unfiled)
     let expectedInfos = [{
       id: this._orphanBookmarkId,
-      parent: bs.unfiledBookmarksFolder,
+      parent: gUnfiledFolderId,
       syncChangeCounter: 1,
     }, {
       id: this._orphanSeparatorId,
-      parent: bs.unfiledBookmarksFolder,
+      parent: gUnfiledFolderId,
       syncChangeCounter: 1,
     }, {
       id: this._orphanFolderId,
-      parent: bs.unfiledBookmarksFolder,
+      parent: gUnfiledFolderId,
       syncChangeCounter: 1,
     }, {
       id: this._bookmarkId,
       parent: this._orphanFolderId,
       syncChangeCounter: 0,
     }, {
-      id: bs.unfiledBookmarksFolder,
+      id: gUnfiledFolderId,
       parent: bs.placesRoot,
       syncChangeCounter: 3,
     }];
     let db = await PlacesUtils.promiseDBConnection();
     for (let { id, parent, syncChangeCounter } of expectedInfos) {
       let rows = await db.executeCached(`
         SELECT id, syncChangeCounter
         FROM moz_bookmarks
@@ -687,24 +687,24 @@ tests.push({
     this._bookmarkId1 = addBookmark(this._placeId, bs.TYPE_BOOKMARK, this._bookmarkId);
     this._bookmarkId2 = addBookmark(this._placeId, bs.TYPE_BOOKMARK, this._separatorId);
   },
 
   async check() {
     // Check that bookmarks are now children of a real folder (unfiled)
     let expectedInfos = [{
       id: this._bookmarkId1,
-      parent: bs.unfiledBookmarksFolder,
+      parent: gUnfiledFolderId,
       syncChangeCounter: 1,
     }, {
       id: this._bookmarkId2,
-      parent: bs.unfiledBookmarksFolder,
+      parent: gUnfiledFolderId,
       syncChangeCounter: 1,
     }, {
-      id: bs.unfiledBookmarksFolder,
+      id: gUnfiledFolderId,
       parent: bs.placesRoot,
       syncChangeCounter: 2,
     }];
     let db = await PlacesUtils.promiseDBConnection();
     for (let { id, parent, syncChangeCounter } of expectedInfos) {
       let rows = await db.executeCached(`
         SELECT id, syncChangeCounter
         FROM moz_bookmarks
@@ -744,89 +744,92 @@ tests.push({
       source: PlacesUtils.bookmarks.SOURCES.SYNC,
     });
     await PlacesUtils.bookmarks.insertTree({
       guid: PlacesUtils.bookmarks.toolbarGuid,
       children,
       source: PlacesUtils.bookmarks.SOURCES.SYNC,
     });
 
-    function randomize_positions(aParent, aResultArray) {
+    async function randomize_positions(aParent, aResultArray) {
+      let parentId = await PlacesUtils.promiseItemId(aParent);
       let stmt = mDBConn.createStatement(
         `UPDATE moz_bookmarks SET position = :rand
          WHERE id IN (
            SELECT id FROM moz_bookmarks WHERE parent = :parent
            ORDER BY RANDOM() LIMIT 1
          )`
       );
       for (let i = 0; i < (NUM_BOOKMARKS / 2); i++) {
-        stmt.params.parent = aParent;
+        stmt.params.parent = parentId;
         stmt.params.rand = Math.round(Math.random() * (NUM_BOOKMARKS - 1));
         stmt.execute();
         stmt.reset();
       }
       stmt.finalize();
 
       // Build the expected ordered list of bookmarks.
       stmt = mDBConn.createStatement(
         `SELECT id, position
          FROM moz_bookmarks WHERE parent = :parent
          ORDER BY position ASC, ROWID ASC`
       );
-      stmt.params.parent = aParent;
+      stmt.params.parent = parentId;
       while (stmt.executeStep()) {
         aResultArray.push(stmt.row.id);
         print(stmt.row.id + "\t" + stmt.row.position + "\t" +
               (aResultArray.length - 1));
       }
       stmt.finalize();
     }
 
     // Set random positions for the added bookmarks.
-    randomize_positions(PlacesUtils.unfiledBookmarksFolderId,
-                        this._unfiledBookmarks);
-    randomize_positions(PlacesUtils.toolbarFolderId, this._toolbarBookmarks);
+    await randomize_positions(PlacesUtils.bookmarks.unfiledGuid,
+      this._unfiledBookmarks);
+    await randomize_positions(PlacesUtils.bookmarks.toolbarGuid,
+      this._toolbarBookmarks);
 
     let syncInfos = await PlacesTestUtils.fetchBookmarkSyncFields(
       PlacesUtils.bookmarks.unfiledGuid, PlacesUtils.bookmarks.toolbarGuid);
     Assert.ok(syncInfos.every(info => info.syncChangeCounter === 0));
   },
 
   async check() {
     let db = await PlacesUtils.promiseDBConnection();
 
     async function check_order(aParent, aResultArray) {
+      let parentId = await PlacesUtils.promiseItemId(aParent);
       // Build the expected ordered list of bookmarks.
       let childRows = await db.executeCached(
         `SELECT id, position, syncChangeCounter FROM moz_bookmarks
          WHERE parent = :parent
          ORDER BY position ASC`,
-        { parent: aParent }
+        { parent: parentId }
       );
       for (let row of childRows) {
         let id = row.getResultByName("id");
         let position = row.getResultByName("position");
         if (aResultArray.indexOf(id) != position) {
           dump_table("moz_bookmarks");
           do_throw("Unexpected unfiled bookmarks order.");
         }
       }
 
       let parentRows = await db.executeCached(
         `SELECT syncChangeCounter FROM moz_bookmarks
          WHERE id = :parent`,
-        { parent: aParent });
+        { parent: parentId });
       for (let row of parentRows) {
         let actualChangeCounter = row.getResultByName("syncChangeCounter");
         Assert.ok(actualChangeCounter > 0);
       }
     }
 
-    await check_order(PlacesUtils.unfiledBookmarksFolderId, this._unfiledBookmarks);
-    await check_order(PlacesUtils.toolbarFolderId, this._toolbarBookmarks);
+    await check_order(PlacesUtils.bookmarks.unfiledGuid, this._unfiledBookmarks);
+    await check_order(PlacesUtils.bookmarks.toolbarGuid, this._toolbarBookmarks);
   },
 });
 
 // ------------------------------------------------------------------------------
 
 tests.push({
   name: "D.12",
   desc: "Fix empty-named tags",
@@ -1856,35 +1859,35 @@ tests.push({
       guid: "bookmarkBBBB",
       placeId: null,
       parentId: bs.bookmarksMenuFolder,
       dateAdded: PlacesUtils.toPRTime(new Date(2017, 9, 2)),
       lastModified: null,
     }, {
       guid: "bookmarkCCCC",
       placeId: null,
-      parentId: bs.unfiledBookmarksFolder,
+      parentId: gUnfiledFolderId,
       dateAdded: null,
       lastModified: null,
     }, {
       guid: "bookmarkDDDD",
       placeId: placeIdWithVisits,
       parentId: bs.mobileFolder,
       dateAdded: null,
       lastModified: null,
     }, {
       guid: "bookmarkEEEE",
       placeId: placeIdWithVisits,
-      parentId: bs.unfiledBookmarksFolder,
+      parentId: gUnfiledFolderId,
       dateAdded: PlacesUtils.toPRTime(new Date(2017, 9, 3)),
       lastModified: PlacesUtils.toPRTime(new Date(2017, 9, 6)),
     }, {
       guid: "bookmarkFFFF",
       placeId: placeIdWithZeroVisit,
-      parentId: bs.unfiledBookmarksFolder,
+      parentId: gUnfiledFolderId,
       dateAdded: 0,
       lastModified: 0,
     });
 
     await PlacesUtils.withConnectionWrapper(
       "S.3: Insert bookmarks and visits",
       db => db.executeTransaction(async () => {
         await db.execute(`
@@ -1989,17 +1992,17 @@ tests.push({
 tests.push({
   name: "S.4",
   desc: "reset added dates that are ahead of last modified dates",
   _bookmarksWithDates: [],
 
   async setup() {
     this._bookmarksWithDates.push({
       guid: "bookmarkGGGG",
-      parentId: bs.unfiledBookmarksFolder,
+      parentId: gUnfiledFolderId,
       dateAdded: PlacesUtils.toPRTime(new Date(2017, 9, 6)),
       lastModified: PlacesUtils.toPRTime(new Date(2017, 9, 3)),
     });
 
     await PlacesUtils.withConnectionWrapper(
       "S.4: Insert bookmarks and visits",
       db => db.executeTransaction(async () => {
         await db.execute(`
@@ -2186,16 +2189,19 @@ tests.push({
       });
     });
   },
 });
 
 // ------------------------------------------------------------------------------
 
 add_task(async function test_preventive_maintenance() {
+  gUnfiledFolderId =
+    await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid);
+
   // Get current bookmarks max ID for cleanup
   let stmt = mDBConn.createStatement("SELECT MAX(id) FROM moz_bookmarks");
   stmt.executeStep();
   defaultBookmarksMaxId = stmt.getInt32(0);
   stmt.finalize();
   Assert.ok(defaultBookmarksMaxId > 0);
 
   for (let test of tests) {
@@ -2214,11 +2220,11 @@ add_task(async function test_preventive_
 
     await cleanDatabase();
   }
 
   // Sanity check: all roots should be intact
   Assert.equal(bs.getFolderIdForItem(bs.placesRoot), 0);
   Assert.equal(bs.getFolderIdForItem(bs.bookmarksMenuFolder), bs.placesRoot);
   Assert.equal(bs.getFolderIdForItem(bs.tagsFolder), bs.placesRoot);
-  Assert.equal(bs.getFolderIdForItem(bs.unfiledBookmarksFolder), bs.placesRoot);
+  Assert.equal(bs.getFolderIdForItem(gUnfiledFolderId), bs.placesRoot);
   Assert.equal(bs.getFolderIdForItem(bs.toolbarFolder), bs.placesRoot);
 });
--- a/toolkit/components/places/tests/sync/test_bookmark_kinds.js
+++ b/toolkit/components/places/tests/sync/test_bookmark_kinds.js
@@ -2,16 +2,19 @@
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 add_task(async function test_livemarks() {
   let { site, stopServer } = makeLivemarkServer();
 
   try {
     let buf = await openMirror("livemarks");
 
+    let unfiledFolderId =
+      await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid);
+
     info("Set up mirror");
     await PlacesUtils.bookmarks.insertTree({
       guid: PlacesUtils.bookmarks.menuGuid,
       children: [{
         guid: "livemarkAAAA",
         type: PlacesUtils.bookmarks.TYPE_FOLDER,
         title: "A",
         annos: [{
@@ -259,17 +262,17 @@ add_task(async function test_livemarks()
       params: { itemId: livemarkC.id, parentId: PlacesUtils.toolbarFolderId,
                 index: 0, type: PlacesUtils.bookmarks.TYPE_FOLDER,
                 urlHref: null, title: "C (remote)", guid: "livemarkCCCC",
                 parentGuid: PlacesUtils.bookmarks.toolbarGuid,
                 source: PlacesUtils.bookmarks.SOURCES.SYNC },
     }, {
       name: "onItemAdded",
       params: { itemId: livemarkE.id,
-                parentId: PlacesUtils.unfiledBookmarksFolderId,
+                parentId: unfiledFolderId,
                 index: 0, type: PlacesUtils.bookmarks.TYPE_FOLDER,
                 urlHref: null, title: "E", guid: "livemarkEEEE",
                 parentGuid: "unfiled_____",
                 source: PlacesUtils.bookmarks.SOURCES.SYNC },
     }, {
       name: "onItemMoved",
       params: { itemId: livemarkB.id, oldParentId: PlacesUtils.toolbarFolderId,
                 oldIndex: 0, newParentId: PlacesUtils.toolbarFolderId,
@@ -339,27 +342,27 @@ add_task(async function test_livemarks()
                 guid: "livemarkB111",
                 parentGuid: PlacesUtils.bookmarks.toolbarGuid, oldValue: "",
                 source: PlacesUtils.bookmarks.SOURCES.SYNC },
     }, {
       name: "onItemChanged",
       params: { itemId: livemarkE.id, property: PlacesUtils.LMANNO_FEEDURI,
                 isAnnoProperty: true, newValue: "",
                 type: PlacesUtils.bookmarks.TYPE_FOLDER,
-                parentId: PlacesUtils.unfiledBookmarksFolderId,
+                parentId: unfiledFolderId,
                 guid: "livemarkEEEE",
                 parentGuid: PlacesUtils.bookmarks.unfiledGuid,
                 oldValue: "",
                 source: PlacesUtils.bookmarks.SOURCES.SYNC },
     }, {
       name: "onItemChanged",
       params: { itemId: livemarkE.id, property: PlacesUtils.LMANNO_SITEURI,
                 isAnnoProperty: true, newValue: "",
                 type: PlacesUtils.bookmarks.TYPE_FOLDER,
-                parentId: PlacesUtils.unfiledBookmarksFolderId,
+                parentId: unfiledFolderId,
                 guid: "livemarkEEEE",
                 parentGuid: PlacesUtils.bookmarks.unfiledGuid,
                 oldValue: "",
                 source: PlacesUtils.bookmarks.SOURCES.SYNC },
     }]);
 
     await buf.finalize();
   } finally {
--- a/toolkit/components/places/tests/sync/test_bookmark_structure_changes.js
+++ b/toolkit/components/places/tests/sync/test_bookmark_structure_changes.js
@@ -292,17 +292,18 @@ add_task(async function test_move() {
               oldParentGuid: PlacesUtils.bookmarks.menuGuid,
               newParentGuid: PlacesUtils.bookmarks.toolbarGuid,
               source: PlacesUtils.bookmarks.SOURCES.SYNC,
               urlHref: null },
   }, {
     name: "onItemMoved",
     params: { itemId: localItemIds.get("mozFolder___"),
               oldParentId: localItemIds.get("devFolder___"),
-              oldIndex: 1, newParentId: PlacesUtils.unfiledBookmarksFolderId,
+              oldIndex: 1,
+              newParentId: await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid),
               newIndex: 0, type: PlacesUtils.bookmarks.TYPE_FOLDER,
               guid: "mozFolder___",
               oldParentGuid: "devFolder___",
               newParentGuid: PlacesUtils.bookmarks.unfiledGuid,
               source: PlacesUtils.bookmarks.SOURCES.SYNC,
               urlHref: null },
   }, {
     name: "onItemMoved",
--- a/toolkit/components/places/tests/sync/test_bookmark_value_changes.js
+++ b/toolkit/components/places/tests/sync/test_bookmark_value_changes.js
@@ -1,11 +1,18 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
+let unfiledFolderId;
+
+add_task(async function setup() {
+  unfiledFolderId =
+    await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid);
+});
+
 add_task(async function test_value_combo() {
   let buf = await openMirror("value_combo");
 
   info("Set up mirror with existing bookmark to update");
   await PlacesUtils.bookmarks.insertTree({
     guid: PlacesUtils.bookmarks.menuGuid,
     children: [{
       guid: "mozBmk______",
@@ -684,17 +691,17 @@ add_task(async function test_keywords_co
               type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
               urlHref: "http://example.com/a", title: "A (copy)",
               guid: "bookmarkAAA1",
               parentGuid: PlacesUtils.bookmarks.menuGuid,
               source: PlacesUtils.bookmarks.SOURCES.SYNC },
   }, {
     name: "onItemAdded",
     params: { itemId: localItemIds.get("bookmarkBBB1"),
-              parentId: PlacesUtils.unfiledBookmarksFolderId, index: 0,
+              parentId: unfiledFolderId, index: 0,
               type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
               urlHref: "http://example.com/b", title: "B",
               guid: "bookmarkBBB1",
               parentGuid: PlacesUtils.bookmarks.unfiledGuid,
               source: PlacesUtils.bookmarks.SOURCES.SYNC },
   }, {
     // These `onItemMoved` notifications aren't necessary: we only moved
     // (B C D E) to accomodate (A A1 B1), and Places doesn't usually fire move
@@ -1256,17 +1263,17 @@ add_task(async function test_duplicate_u
               parentId: PlacesUtils.toolbarFolderId, guid: "bookmarkBBBB",
               parentGuid: PlacesUtils.bookmarks.toolbarGuid, oldValue: "B",
               source: PlacesUtils.bookmarks.SOURCES.SYNC },
   }, {
     name: "onItemChanged",
     params: { itemId: localItemIds.get("bookmarkCCCC"), property: "title",
               isAnnoProperty: false, newValue: "C (remote)",
               type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
-              parentId: PlacesUtils.unfiledBookmarksFolderId,
+              parentId: unfiledFolderId,
               guid: "bookmarkCCCC",
               parentGuid: PlacesUtils.bookmarks.unfiledGuid, oldValue: "C",
               source: PlacesUtils.bookmarks.SOURCES.SYNC },
   }]);
 
   info("Remove duplicate URLs from Places to avoid tripping debug asserts");
   await buf.db.executeTransaction(async function() {
     for (let { guid } of placesToInsert) {
--- a/toolkit/components/places/tests/unit/test_mozIAsyncLivemarks.js
+++ b/toolkit/components/places/tests/unit/test_mozIAsyncLivemarks.js
@@ -1,18 +1,23 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Tests functionality of the mozIAsyncLivemarks interface.
 
 const FEED_URI = NetUtil.newURI("http://feed.rss/");
 const SITE_URI = NetUtil.newURI("http://site.org/");
 
+let unfiledFolderId;
+
 // This test must be the first one, since it's testing the cache.
 add_task(async function test_livemark_cache() {
+  unfiledFolderId =
+    await PlacesUtils.promiseItemId(PlacesUtils.bookmarks.unfiledGuid);
+
   // Add a livemark through other APIs.
   let folder = await PlacesUtils.bookmarks.insert({
     type: PlacesUtils.bookmarks.TYPE_FOLDER,
     title: "test",
     parentGuid: PlacesUtils.bookmarks.unfiledGuid,
   });
   let id = await PlacesUtils.promiseItemId(folder.guid);
   PlacesUtils.annotations
@@ -26,17 +31,17 @@ add_task(async function test_livemark_ca
 
   let livemark = await PlacesUtils.livemarks.getLivemark({ guid: folder.guid });
   Assert.equal(folder.guid, livemark.guid);
   Assert.equal(folder.dateAdded * 1000, livemark.dateAdded);
   Assert.equal(folder.parentGuid, livemark.parentGuid);
   Assert.equal(folder.index, livemark.index);
   Assert.equal(folder.title, livemark.title);
   Assert.equal(id, livemark.id);
-  Assert.equal(PlacesUtils.unfiledBookmarksFolderId, livemark.parentId);
+  Assert.equal(unfiledFolderId, livemark.parentId);
   Assert.equal("http://example.com/feed", livemark.feedURI.spec);
   Assert.equal("http://example.com/site", livemark.siteURI.spec);
 
   await PlacesUtils.livemarks.removeLivemark(livemark);
 });
 
 add_task(async function test_addLivemark_noArguments_throws() {
   try {
@@ -72,38 +77,38 @@ add_task(async function test_addLivemark
   } catch (ex) {
     Assert.equal(ex.result, Cr.NS_ERROR_INVALID_ARG);
   }
 });
 
 add_task(async function test_addLivemark_noIndex_throws() {
   try {
     await PlacesUtils.livemarks.addLivemark({
-      parentId: PlacesUtils.unfiledBookmarksFolderId });
+      parentId: unfiledFolderId });
     do_throw("Invoking addLivemark with no index should throw");
   } catch (ex) {
     Assert.equal(ex.result, Cr.NS_ERROR_INVALID_ARG);
   }
 });
 
 add_task(async function test_addLivemark_badIndex_throws() {
   try {
     await PlacesUtils.livemarks.addLivemark(
-      { parentId: PlacesUtils.unfiledBookmarksFolderId,
+      { parentId: unfiledFolderId,
         index: "test" });
     do_throw("Invoking addLivemark with a bad index should throw");
   } catch (ex) {
     Assert.equal(ex.result, Cr.NS_ERROR_INVALID_ARG);
   }
 });
 
 add_task(async function test_addLivemark_invalidIndex_throws() {
   try {
     await PlacesUtils.livemarks.addLivemark(
-      { parentId: PlacesUtils.unfiledBookmarksFolderId,
+      { parentId: unfiledFolderId,
         index: -2,
       });
     do_throw("Invoking addLivemark with an invalid index should throw");
   } catch (ex) {
     Assert.equal(ex.result, Cr.NS_ERROR_INVALID_ARG);
   }
 });
 
@@ -155,41 +160,41 @@ add_task(async function test_addLivemark
 add_task(async function test_addLivemark_parentId_succeeds() {
   let onItemAddedCalled = false;
   PlacesUtils.bookmarks.addObserver({
     __proto__: NavBookmarkObserver.prototype,
     onItemAdded: function onItemAdded(aItemId, aParentId, aIndex, aItemType,
                                       aURI, aTitle) {
       onItemAddedCalled = true;
       PlacesUtils.bookmarks.removeObserver(this);
-      Assert.equal(aParentId, PlacesUtils.unfiledBookmarksFolderId);
+      Assert.equal(aParentId, unfiledFolderId);
       Assert.equal(aIndex, 0);
       Assert.equal(aItemType, Ci.nsINavBookmarksService.TYPE_FOLDER);
       Assert.equal(aTitle, "test");
     },
   });
 
   await PlacesUtils.livemarks.addLivemark(
     { title: "test",
-      parentId: PlacesUtils.unfiledBookmarksFolderId,
+      parentId: unfiledFolderId,
       feedURI: FEED_URI });
   Assert.ok(onItemAddedCalled);
 });
 
 
 add_task(async function test_addLivemark_noSiteURI_succeeds() {
   let livemark = await PlacesUtils.livemarks.addLivemark(
     { title: "test",
       parentGuid: PlacesUtils.bookmarks.unfiledGuid,
       feedURI: FEED_URI,
     });
   Assert.ok(livemark.id > 0);
   do_check_valid_places_guid(livemark.guid);
   Assert.equal(livemark.title, "test");
-  Assert.equal(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
+  Assert.equal(livemark.parentId, unfiledFolderId);
   Assert.equal(livemark.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
   Assert.ok(livemark.feedURI.equals(FEED_URI));
   Assert.equal(livemark.siteURI, null);
   Assert.ok(livemark.lastModified > 0);
   Assert.equal(livemark.dateAdded, livemark.lastModified);
 
   let bookmark = await PlacesUtils.bookmarks.fetch(livemark.guid);
   Assert.equal(livemark.index, bookmark.index);
@@ -202,17 +207,17 @@ add_task(async function test_addLivemark
       parentGuid: PlacesUtils.bookmarks.unfiledGuid,
       feedURI: FEED_URI,
       siteURI: SITE_URI,
     });
 
   Assert.ok(livemark.id > 0);
   do_check_valid_places_guid(livemark.guid);
   Assert.equal(livemark.title, "test");
-  Assert.equal(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
+  Assert.equal(livemark.parentId, unfiledFolderId);
   Assert.equal(livemark.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
   Assert.ok(livemark.feedURI.equals(FEED_URI));
   Assert.ok(livemark.siteURI.equals(SITE_URI));
   Assert.ok(PlacesUtils.annotations
                        .itemHasAnnotation(livemark.id,
                                           PlacesUtils.LMANNO_FEEDURI));
   Assert.ok(PlacesUtils.annotations
                        .itemHasAnnotation(livemark.id,
@@ -400,17 +405,17 @@ add_task(async function test_getLivemark
       feedURI: FEED_URI,
       guid: "34567890ABCD" });
 
   // invalid id to check the guid wins.
   let livemark =
     await PlacesUtils.livemarks.getLivemark({ id: 789, guid: "34567890ABCD" });
 
   Assert.equal(livemark.title, "test");
-  Assert.equal(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
+  Assert.equal(livemark.parentId, unfiledFolderId);
   Assert.equal(livemark.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
   Assert.ok(livemark.feedURI.equals(FEED_URI));
   Assert.equal(livemark.siteURI, null);
   Assert.equal(livemark.guid, "34567890ABCD");
 
   let bookmark = await PlacesUtils.bookmarks.fetch("34567890ABCD");
   Assert.equal(livemark.index, bookmark.index);
 });
@@ -420,17 +425,17 @@ add_task(async function test_getLivemark
     { title: "test",
       parentGuid: PlacesUtils.bookmarks.unfiledGuid,
       feedURI: FEED_URI,
     });
 
   livemark = await PlacesUtils.livemarks.getLivemark({ id: livemark.id });
 
   Assert.equal(livemark.title, "test");
-  Assert.equal(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
+  Assert.equal(livemark.parentId, unfiledFolderId);
   Assert.equal(livemark.parentGuid, PlacesUtils.bookmarks.unfiledGuid);
   Assert.ok(livemark.feedURI.equals(FEED_URI));
   Assert.equal(livemark.siteURI, null);
   do_check_guid_for_bookmark(livemark.id, livemark.guid);
 
   let bookmark = await PlacesUtils.bookmarks.fetch(livemark.guid);
   Assert.equal(livemark.index, bookmark.index);
 });
@@ -446,17 +451,17 @@ add_task(async function test_getLivemark
     { title: "test",
       parentGuid: PlacesUtils.bookmarks.unfiledGuid,
       feedURI: FEED_URI,
     });
 
   livemark = await PlacesUtils.livemarks.getLivemark({ guid: livemark.guid });
 
   Assert.equal(livemark.title, "test");
-  Assert.equal(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
+  Assert.equal(livemark.parentId, unfiledFolderId);
   Assert.ok(livemark.feedURI.equals(FEED_URI));
   Assert.equal(livemark.siteURI, null);
   do_check_guid_for_bookmark(livemark.id, livemark.guid);
 });
 
 add_task(async function test_title_change() {
   let livemark = await PlacesUtils.livemarks.addLivemark(
     { title: "test",