зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1404999, force command updating to be enabled when a menu is opened, r=mconley
This commit is contained in:
Родитель
b5c9bf0e08
Коммит
8c937c2917
|
@ -128,3 +128,36 @@ add_task(async function clickWithPrefSet() {
|
|||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
// Open a tab, then quickly open the context menu to ensure that the command
|
||||
// enabled state of the menuitems is updated properly.
|
||||
add_task(async function quickContextMenu() {
|
||||
await SpecialPowers.pushPrefEnv({set: [
|
||||
[PREF_LOAD_BOOKMARKS_IN_TABS, true]
|
||||
]});
|
||||
|
||||
let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, TEST_PAGES[0]);
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(gBookmarkElements[0], {
|
||||
button: 0
|
||||
});
|
||||
let newTab = await tabPromise;
|
||||
|
||||
let placesContext = document.getElementById("placesContext");
|
||||
let promise = BrowserTestUtils.waitForEvent(placesContext, "popupshown");
|
||||
EventUtils.synthesizeMouseAtCenter(gBookmarkElements[1], {
|
||||
button: 2,
|
||||
type: "contextmenu"
|
||||
});
|
||||
await promise;
|
||||
|
||||
Assert.ok(!document.getElementById("placesContext_open").disabled,
|
||||
"Commands in context menu are enabled");
|
||||
|
||||
promise = BrowserTestUtils.waitForEvent(placesContext, "popuphidden");
|
||||
placesContext.hidePopup();
|
||||
await promise;
|
||||
await BrowserTestUtils.removeTab(newTab);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "nsXULElement.h"
|
||||
#include "nsIDOMXULMenuListElement.h"
|
||||
#include "nsIXULDocument.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDOMXULCommandDispatcher.h"
|
||||
#include "nsIXULTemplateBuilder.h"
|
||||
#include "nsCSSFrameConstructor.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
|
@ -1974,6 +1976,16 @@ nsXULPopupManager::UpdateMenuItems(nsIContent* aPopup)
|
|||
return;
|
||||
}
|
||||
|
||||
// When a menu is opened, make sure that command updating is unlocked first.
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDoc = do_QueryInterface(document);
|
||||
if (xulDoc) {
|
||||
nsCOMPtr<nsIDOMXULCommandDispatcher> xulCommandDispatcher;
|
||||
xulDoc->GetCommandDispatcher(getter_AddRefs(xulCommandDispatcher));
|
||||
if (xulCommandDispatcher) {
|
||||
xulCommandDispatcher->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
for (nsCOMPtr<nsIContent> grandChild = aPopup->GetFirstChild();
|
||||
grandChild;
|
||||
grandChild = grandChild->GetNextSibling()) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче