Bug 433274 - Allow popups from context menu events, r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D19476

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrea Marchesini 2019-02-12 12:02:07 +00:00
Родитель ab65a14a4b
Коммит b962fd77c9
2 изменённых файлов: 44 добавлений и 31 удалений

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

@ -287,36 +287,49 @@ PopupBlocker::PopupControlState PopupBlocker::GetEventPopupControlState(
}
break;
case eMouseEventClass:
if (aEvent->IsTrusted() &&
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
abuse = PopupBlocker::openBlocked;
switch (aEvent->mMessage) {
case eMouseUp:
if (PopupAllowedForEvent("mouseup")) {
abuse = PopupBlocker::openControlled;
}
break;
case eMouseDown:
if (PopupAllowedForEvent("mousedown")) {
abuse = PopupBlocker::openControlled;
}
break;
case eMouseClick:
/* Click events get special treatment because of their
historical status as a more legitimate event handler. If
click popups are enabled in the prefs, clear the popup
status completely. */
if (PopupAllowedForEvent("click")) {
abuse = PopupBlocker::openAllowed;
}
break;
case eMouseDoubleClick:
if (PopupAllowedForEvent("dblclick")) {
abuse = PopupBlocker::openControlled;
}
break;
default:
break;
if (aEvent->IsTrusted()) {
if (aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
abuse = PopupBlocker::openBlocked;
switch (aEvent->mMessage) {
case eMouseUp:
if (PopupAllowedForEvent("mouseup")) {
abuse = PopupBlocker::openControlled;
}
break;
case eMouseDown:
if (PopupAllowedForEvent("mousedown")) {
abuse = PopupBlocker::openControlled;
}
break;
case eMouseClick:
/* Click events get special treatment because of their
historical status as a more legitimate event handler. If
click popups are enabled in the prefs, clear the popup
status completely. */
if (PopupAllowedForEvent("click")) {
abuse = PopupBlocker::openAllowed;
}
break;
case eMouseDoubleClick:
if (PopupAllowedForEvent("dblclick")) {
abuse = PopupBlocker::openControlled;
}
break;
default:
break;
}
} else if (aEvent->AsMouseEvent()->button ==
WidgetMouseEvent::eRightButton) {
abuse = PopupBlocker::openBlocked;
switch (aEvent->mMessage) {
case eContextMenu:
if (PopupAllowedForEvent("contextmenu")) {
abuse = PopupBlocker::openControlled;
}
break;
default:
break;
}
}
}
break;

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

@ -1291,7 +1291,7 @@ pref("dom.allow_scripts_to_close_windows", false);
pref("dom.require_user_interaction_for_beforeunload", true);
pref("dom.popup_maximum", 20);
pref("dom.popup_allowed_events", "change click dblclick mouseup pointerup notificationclick reset submit touchend");
pref("dom.popup_allowed_events", "change click dblclick mouseup pointerup notificationclick reset submit touchend contextmenu");
pref("dom.disable_open_click_delay", 1000);
pref("dom.serviceWorkers.disable_open_click_delay", 1000);