mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 10:33:33 +00:00
Bug 555547 - A command of placesContextMenu is carried out for a wrong bookmark item.
r=mak a=blocking
This commit is contained in:
parent
f63c4881d3
commit
f8fb06fad3
@ -57,6 +57,8 @@ PlacesViewBase.prototype = {
|
||||
_viewElt: null,
|
||||
get viewElt() this._viewElt,
|
||||
|
||||
get controllers() this._viewElt.controllers,
|
||||
|
||||
// The xul element that represents the root container.
|
||||
_rootElt: null,
|
||||
|
||||
|
@ -1584,20 +1584,22 @@ function goUpdatePlacesCommands() {
|
||||
|
||||
function doGetPlacesControllerForCommand(aCommand)
|
||||
{
|
||||
// A context menu may be built for non-focusable views. Thus, we first try
|
||||
// to look for a view associated with document.popupNode
|
||||
let popupNode = document.popupNode;
|
||||
if (popupNode) {
|
||||
let view = PlacesUIUtils.getViewForNode(popupNode);
|
||||
if (view && view._contextMenuShown)
|
||||
return view.controllers.getControllerForCommand(aCommand);
|
||||
}
|
||||
|
||||
// When we're not building a context menu, only focusable views
|
||||
// are possible. Thus, we can safely use the command dispatcher.
|
||||
let controller = top.document.commandDispatcher
|
||||
.getControllerForCommand(aCommand);
|
||||
if (controller)
|
||||
return controller;
|
||||
|
||||
// If building commands for a context menu, look for an element in the
|
||||
// current popup.
|
||||
let element = document.popupNode;
|
||||
if (element) {
|
||||
let view = PlacesUIUtils.getViewForNode(element);
|
||||
if (view && view._contextMenuShown)
|
||||
return view.viewElt.controllers.getControllerForCommand(aCommand);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -665,15 +665,19 @@
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<field name="_contextMenuShown">false</field>
|
||||
|
||||
<method name="buildContextMenu">
|
||||
<parameter name="aPopup"/>
|
||||
<body><![CDATA[
|
||||
this._contextMenuShown = true;
|
||||
return this.controller.buildContextMenu(aPopup);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="destroyContextMenu">
|
||||
<parameter name="aPopup"/>
|
||||
this._contextMenuShown = false;
|
||||
<body/>
|
||||
</method>
|
||||
</implementation>
|
||||
|
@ -72,6 +72,7 @@ _BROWSER_TEST_FILES = \
|
||||
frameRight.html \
|
||||
browser_toolbar_migration.js \
|
||||
browser_library_batch_delete.js \
|
||||
browser_555547.js \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_BROWSER_TEST_FILES)
|
||||
|
59
browser/components/places/tests/browser/browser_555547.js
Normal file
59
browser/components/places/tests/browser/browser_555547.js
Normal file
@ -0,0 +1,59 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
let sidebarBox = document.getElementById("sidebar-box");
|
||||
is(sidebarBox.hidden, true, "The sidebar should be hidden");
|
||||
|
||||
// Uncollapse the personal toolbar if needed.
|
||||
let toolbar = document.getElementById("PersonalToolbar");
|
||||
let wasCollapsed = toolbar.collapsed;
|
||||
if (wasCollapsed)
|
||||
setToolbarVisibility(toolbar, true);
|
||||
|
||||
let sidebar = document.getElementById("sidebar");
|
||||
sidebar.addEventListener("load", function() {
|
||||
sidebar.removeEventListener("load", arguments.callee, true);
|
||||
let tree = sidebar.contentDocument.getElementById("bookmarks-view");
|
||||
|
||||
// The Places view is build on load, so we enqueue our test.
|
||||
executeSoon(function() {
|
||||
// Focus the tree and check if its controller is returned.
|
||||
tree.focus();
|
||||
|
||||
let controller = doGetPlacesControllerForCommand("placesCmd_copy");
|
||||
let treeController = tree.controllers
|
||||
.getControllerForCommand("placesCmd_copy");
|
||||
ok(controller == treeController, "tree controller was returned");
|
||||
|
||||
// Open the context menu for a toolbar item, and check if the toolbar's
|
||||
// controller is returned.
|
||||
let toolbarItems = document.getElementById("PlacesToolbarItems");
|
||||
EventUtils.synthesizeMouse(toolbarItems.childNodes[0],
|
||||
4, 4, { type: "contextmenu", button: 2 },
|
||||
window);
|
||||
controller = doGetPlacesControllerForCommand("placesCmd_copy");
|
||||
let toolbarController = document.getElementById("PlacesToolbar")
|
||||
.controllers
|
||||
.getControllerForCommand("placesCmd_copy");
|
||||
ok(controller == toolbarController, "the toolbar controller was returned");
|
||||
|
||||
document.getElementById("placesContext").hidePopup();
|
||||
|
||||
// Now that the context menu is closed, try to get the tree controller again.
|
||||
tree.focus();
|
||||
controller = doGetPlacesControllerForCommand("placesCmd_copy");
|
||||
ok(controller == treeController, "tree controller was returned");
|
||||
|
||||
toggleSidebar();
|
||||
if (wasCollapsed)
|
||||
setToolbarVisibility(toolbar, false);
|
||||
|
||||
finish();
|
||||
});
|
||||
}, true);
|
||||
toggleSidebar("viewBookmarksSidebar", true);
|
||||
}
|
Loading…
Reference in New Issue
Block a user