Bug 1159301, clear the mouse capture whenever a menu is opened, r=tn

This commit is contained in:
Neil Deakin 2016-08-03 07:45:45 -04:00
parent 52628b0bb3
commit e375813b04
2 changed files with 31 additions and 2 deletions

View File

@ -416,3 +416,32 @@ add_task(function* test_large_popup() {
yield BrowserTestUtils.removeTab(tab);
});
// This test checks that a mousemove event is fired correctly at the menu and
// not at the browser, ensuring that any mouse capture has been cleared.
add_task(function* test_mousemove_correcttarget() {
const pageUrl = "data:text/html," + escape(PAGECONTENT_SMALL);
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, pageUrl);
let selectPopup = document.getElementById("ContentSelectDropdown").menupopup;
let popupShownPromise = BrowserTestUtils.waitForEvent(selectPopup, "popupshown");
yield BrowserTestUtils.synthesizeMouseAtCenter("#one", { type: "mousedown" }, gBrowser.selectedBrowser);
yield popupShownPromise;
yield new Promise(resolve => {
window.addEventListener("mousemove", function checkForMouseMove(event) {
window.removeEventListener("mousemove", checkForMouseMove, true);
is(event.target.localName.indexOf("menu"), 0, "mouse over menu");
resolve();
}, true);
EventUtils.synthesizeMouseAtCenter(selectPopup.firstChild, { type: "mousemove" });
});
yield BrowserTestUtils.synthesizeMouseAtCenter("#one", { type: "mouseup" }, gBrowser.selectedBrowser);
yield hideSelectPopup(selectPopup);
yield BrowserTestUtils.removeTab(tab);
});

View File

@ -852,8 +852,8 @@ nsMenuPopupFrame::ShowPopup(bool aIsContextMenu)
mPopupState = ePopupOpening;
mIsOpenChanged = true;
// Clear mouse capture when a context menu is opened.
if (aIsContextMenu) {
// Clear mouse capture when a popup is opened.
if (mPopupType == ePopupTypeMenu) {
nsIPresShell::SetCapturingContent(nullptr, 0);
}