Bug 1409363 - Fix moving bookmarks to a top-level folder via the move bookmarks dialog - use concreteItemGuid to get the correct guid. r?mak
MozReview-Commit-ID: E3nTqr9SPWr
--- a/browser/components/places/content/moveBookmarks.js
+++ b/browser/components/places/content/moveBookmarks.js
@@ -42,17 +42,17 @@ var gMoveBookmarksDialog = {
let txn = new PlacesAggregatedTransaction("Move Items", transactions);
PlacesUtils.transactionManager.doTransaction(txn);
}
return;
}
// Async transactions must do the move in the caller to avoid going out of
// scope whilst the dialog is still closing.
- window.arguments[0].moveToGuid = selectedNode.bookmarkGuid;
+ window.arguments[0].moveToGuid = PlacesUtils.getConcreteItemGuid(selectedNode);
},
newFolder: function MBD_newFolder() {
// The command is disabled when the tree is not focused
this.foldersTree.focus();
goDoCommand("placesCmd_new:folder");
}
};
--- a/browser/components/places/tests/browser/browser_library_move_bookmarks.js
+++ b/browser/components/places/tests/browser/browser_library_move_bookmarks.js
@@ -3,58 +3,73 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Test enabled commands in the left pane folder of the Library.
*/
-registerCleanupFunction(async function() {
- await PlacesUtils.bookmarks.eraseEverything();
- await PlacesTestUtils.clearHistory();
-});
+var bookmarks;
+var testFolder;
+var library;
-add_task(async function test_moveBookmarks() {
+add_task(async function setup() {
let children = [{
title: "TestFolder",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
}];
for (let i = 0; i < 10; i++) {
children.push({
title: `test${i}`,
url: `http://example.com/${i}`,
});
}
- let bookmarks = await PlacesUtils.bookmarks.insertTree({
+ bookmarks = await PlacesUtils.bookmarks.insertTree({
guid: PlacesUtils.bookmarks.unfiledGuid,
children
});
- let folderId = await PlacesUtils.promiseItemId(bookmarks[0].guid);
+ testFolder = bookmarks.shift();
+
+ library = await promiseLibrary("UnfiledBookmarks");
+
+ registerCleanupFunction(async function() {
+ library.close();
+
+ await PlacesUtils.bookmarks.eraseEverything();
+ await PlacesTestUtils.clearHistory();
+ });
+});
+
+async function move_bookmarks_to(sourceFolders, folderGuid) {
+ for (let i = 0; i < sourceFolders.length; i++) {
+ sourceFolders[i] = await PlacesUtils.promiseItemId(sourceFolders[i]);
+ }
+
+ library.PlacesOrganizer.selectLeftPaneContainerByHierarchy(sourceFolders);
+
+ let folderId = await PlacesUtils.promiseItemId(folderGuid);
let itemIds = [];
let promiseMoveNotifications = [];
- for (let i = 0; i < 10; i++) {
- // + 1 due to the folder being inserted first.
- let guid = bookmarks[i + 1].guid;
+ for (let bm of bookmarks) {
+ let guid = bm.guid;
itemIds.push(await PlacesUtils.promiseItemId(guid));
promiseMoveNotifications.push(PlacesTestUtils.waitForNotification(
"onItemMoved",
(itemId, parentId, oldIndex, newParentId, newIndex, itemType, itemGuid,
oldParentGuid, newParentGuid) =>
- itemGuid == guid && newParentGuid == bookmarks[0].guid
+ itemGuid == guid && newParentGuid == folderGuid
));
}
- let library = await promiseLibrary("UnfiledBookmarks");
-
library.ContentTree.view.selectItems(itemIds);
await withBookmarksDialog(
false,
() => {
library.ContentTree.view._controller.doCommand("placesCmd_moveBookmarks");
},
async (dialogWin) => {
@@ -69,11 +84,18 @@ add_task(async function test_moveBookmar
info("Waiting for notifications of moves");
await Promise.all(promiseMoveNotifications);
Assert.ok(true, "should have completed all moves successfully");
},
null,
"chrome://browser/content/places/moveBookmarks.xul",
true
);
+}
- library.close();
+add_task(async function test_moveBookmarks_to_subfolder() {
+ await move_bookmarks_to([PlacesUtils.bookmarks.unfiledGuid], testFolder.guid);
});
+
+add_task(async function test_moveBookmarks_to_other_top_level() {
+ await move_bookmarks_to([PlacesUtils.bookmarks.unfiledGuid, testFolder.guid],
+ PlacesUtils.bookmarks.toolbarGuid);
+});