Bug 1453545 - Properties option disabled when right-clicking a bookmarks folder. r=standard8

MozReview-Commit-ID: 30JmVhO7sh9

--HG--
extra : rebase_source : d7e46a4b5a3cbe631305e909dca7edf3ab54e5ce
This commit is contained in:
Marco Bonardo 2018-04-19 00:16:48 +02:00
Родитель 8db8e3157e
Коммит dc7cbba002
4 изменённых файлов: 66 добавлений и 2 удалений

Просмотреть файл

@ -176,7 +176,9 @@ PlacesController.prototype = {
case "placesCmd_show:info": {
let selectedNode = this._view.selectedNode;
return selectedNode && (PlacesUtils.nodeIsTagQuery(selectedNode) ||
PlacesUtils.nodeIsBookmark(selectedNode));
PlacesUtils.nodeIsBookmark(selectedNode) ||
(PlacesUtils.nodeIsFolder(selectedNode) &&
!PlacesUtils.isQueryGeneratedFolder(selectedNode)));
}
case "placesCmd_reload": {
// Livemark containers

Просмотреть файл

@ -1789,7 +1789,7 @@ PlacesTreeView.prototype = {
// have no reason to disallow renaming a shortcut to the Bookmarks Toolbar,
// except for the one under All Bookmarks.
if (PlacesUtils.nodeIsSeparator(node) || PlacesUtils.isRootItem(itemGuid) ||
PlacesUtils.isQueryGeneratedFolder(itemGuid))
PlacesUtils.isQueryGeneratedFolder(node))
return false;
return true;

Просмотреть файл

@ -30,6 +30,7 @@ support-files =
[browser_bookmarkProperties_addLivemark.js]
[browser_bookmarkProperties_bookmarkAllTabs.js]
[browser_bookmarkProperties_cancel.js]
[browser_bookmarkProperties_editFolder.js]
[browser_bookmarkProperties_editTagContainer.js]
[browser_bookmarkProperties_no_user_actions.js]
[browser_bookmarkProperties_readOnlyRoot.js]

Просмотреть файл

@ -0,0 +1,61 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Tests the Properties dialog on a folder.
add_task(async function() {
info("Bug 479348 - Properties on a root should be read-only.");
let bm = await PlacesUtils.bookmarks.insert({
title: "folder",
type: PlacesUtils.bookmarks.TYPE_FOLDER,
parentGuid: PlacesUtils.bookmarks.unfiledGuid
});
registerCleanupFunction(async function() {
await PlacesUtils.bookmarks.remove(bm);
});
await withSidebarTree("bookmarks", async function(tree) {
// Select the new bookmark in the sidebar.
tree.selectItems([bm.guid]);
let folder = tree.selectedNode;
Assert.equal(folder.title, "folder", "Folder title is correct");
Assert.ok(tree.controller.isCommandEnabled("placesCmd_show:info"),
"'placesCmd_show:info' on folder is enabled");
let promiseTitleResetNotification = PlacesTestUtils.waitForNotification(
"onItemChanged", (id, prop, anno, val) => prop == "title" && val == "folder");
await withBookmarksDialog(
true,
function openDialog() {
tree.controller.doCommand("placesCmd_show:info");
},
async function test(dialogWin) {
// Check that the dialog is not read-only.
Assert.ok(!dialogWin.gEditItemOverlay.readOnly, "Dialog should not be read-only");
// Check that name picker is not read only
let namepicker = dialogWin.document.getElementById("editBMPanel_namePicker");
Assert.ok(!namepicker.readOnly, "Name field should not be read-only");
Assert.equal(namepicker.value, "folder", "Node title is correct");
let promiseTitleChangeNotification = PlacesTestUtils.waitForNotification(
"onItemChanged", (id, prop, anno, val) => prop == "title" && val == "newname");
fillBookmarkTextField("editBMPanel_namePicker", "newname", dialogWin);
await promiseTitleChangeNotification;
Assert.equal(namepicker.value, "newname", "The title field has been changed");
Assert.equal(tree.selectedNode.title, "newname", "The node has the correct title");
// Ensure that the edit is finished before we hit cancel.
await PlacesTestUtils.promiseAsyncUpdates();
}
);
await promiseTitleResetNotification;
});
});