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
Родитель 52628b0bb3
Коммит e375813b04
2 изменённых файлов: 31 добавлений и 2 удалений

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

@ -416,3 +416,32 @@ add_task(function* test_large_popup() {
yield BrowserTestUtils.removeTab(tab); 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);
});

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

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