Bug 1442597 - Can't drag/copy the Mobile bookmarks folder shortcut. r?mak draft
authorMark Banner <standard8@mozilla.com>
Fri, 02 Mar 2018 15:42:25 +0000
changeset 762525 122d0bec912a0b1187af3d62a4aaa6bfc6e756bb
parent 762469 b2a9a4bb5c94de179ae7a3f52fde58c0e2897498
push id101193
push userbmo:standard8@mozilla.com
push dateFri, 02 Mar 2018 16:50:21 +0000
reviewersmak
bugs1442597
milestone60.0a1
Bug 1442597 - Can't drag/copy the Mobile bookmarks folder shortcut. r?mak MozReview-Commit-ID: OqKDMEqxeA
browser/components/places/tests/browser/browser_copy_query_without_tree.js
toolkit/components/places/Bookmarks.jsm
--- a/browser/components/places/tests/browser/browser_copy_query_without_tree.js
+++ b/browser/components/places/tests/browser/browser_copy_query_without_tree.js
@@ -26,17 +26,52 @@ add_task(async function copy_toolbar_sho
 
   await library.ContentTree.view.controller.paste();
 
   let toolbarCopyNode = library.ContentTree.view.view.nodeForTreeIndex(0);
   is(toolbarCopyNode.type,
      Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT,
      "copy is still a folder shortcut");
 
-  PlacesUtils.bookmarks.removeItem(toolbarCopyNode.itemId);
+  await PlacesUtils.bookmarks.remove(toolbarCopyNode.bookmarkGuid);
+  library.PlacesOrganizer.selectLeftPaneBuiltIn("BookmarksToolbar");
+  is(library.PlacesOrganizer._places.selectedNode.type,
+     Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT,
+     "original is still a folder shortcut");
+});
+
+add_task(async function copy_mobile_shortcut() {
+  SpecialPowers.pushPrefEnv({ set: [["browser.bookmarks.showMobileBookmarks", true]]});
+  await promisePlacesInitComplete();
+
+  let library = await promiseLibrary();
+
+  registerCleanupFunction(async () => {
+    library.close();
+    await PlacesUtils.bookmarks.eraseEverything();
+  });
+
+  library.PlacesOrganizer.selectLeftPaneContainerByHierarchy([
+    PlacesUIUtils.leftPaneQueries.AllBookmarks,
+    PlacesUtils.bookmarks.virtualMobileGuid,
+  ]);
+
+  await promiseClipboard(function() { library.PlacesOrganizer._places.controller.copy(); },
+                         PlacesUtils.TYPE_X_MOZ_PLACE);
+
+  library.PlacesOrganizer.selectLeftPaneBuiltIn("UnfiledBookmarks");
+
+  await library.ContentTree.view.controller.paste();
+
+  let mobileCopyNode = library.ContentTree.view.view.nodeForTreeIndex(0);
+  is(mobileCopyNode.type,
+     Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT,
+     "copy is still a folder shortcut");
+
+  await PlacesUtils.bookmarks.remove(mobileCopyNode.bookmarkGuid);
   library.PlacesOrganizer.selectLeftPaneBuiltIn("BookmarksToolbar");
   is(library.PlacesOrganizer._places.selectedNode.type,
      Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT,
      "original is still a folder shortcut");
 });
 
 add_task(async function copy_history_query() {
   let library = await promiseLibrary();
@@ -49,14 +84,14 @@ add_task(async function copy_history_que
   library.PlacesOrganizer.selectLeftPaneBuiltIn("UnfiledBookmarks");
   await library.ContentTree.view.controller.paste();
 
   let historyCopyNode = library.ContentTree.view.view.nodeForTreeIndex(0);
   is(historyCopyNode.type,
      Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY,
      "copy is still a query");
 
-  PlacesUtils.bookmarks.removeItem(historyCopyNode.itemId);
+  await PlacesUtils.bookmarks.remove(historyCopyNode.bookmarkGuid);
   library.PlacesOrganizer.selectLeftPaneBuiltIn("History");
   is(library.PlacesOrganizer._places.selectedNode.type,
      Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY,
      "original is still a query");
 });
--- a/toolkit/components/places/Bookmarks.jsm
+++ b/toolkit/components/places/Bookmarks.jsm
@@ -164,17 +164,18 @@ var Bookmarks = Object.freeze({
    * Checks if a guid is a virtual root.
    *
    * @param {String} guid The guid of the item to look for.
    * @returns {Boolean} true if guid is a virtual root, false otherwise.
    */
   isVirtualRootItem(guid) {
     return guid == PlacesUtils.bookmarks.virtualMenuGuid ||
            guid == PlacesUtils.bookmarks.virtualToolbarGuid ||
-           guid == PlacesUtils.bookmarks.virtualUnfiledGuid;
+           guid == PlacesUtils.bookmarks.virtualUnfiledGuid ||
+           guid == PlacesUtils.bookmarks.virtualMobileGuid;
   },
 
   /**
    * Returns the title to use on the UI for a bookmark item. Root folders
    * in the database don't store fully localised versions of the title. To
    * get those this function should be called.
    *
    * Hence, this function should only be called if a root folder object is