Bug 433274 - Allow popups from context menu events, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 12 Feb 2019 12:02:07 +0000
changeset 458738 05ec02aaa6bb
parent 458737 99ec4f94c2fe
child 458739 9a69e1fea9be
push id35548
push useropoprus@mozilla.com
push dateWed, 13 Feb 2019 09:48:26 +0000
treeherdermozilla-central@93e37c529818 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs433274
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 433274 - Allow popups from context menu events, r=smaug Differential Revision: https://phabricator.services.mozilla.com/D19476
dom/base/PopupBlocker.cpp
modules/libpref/init/all.js
--- a/dom/base/PopupBlocker.cpp
+++ b/dom/base/PopupBlocker.cpp
@@ -282,46 +282,59 @@ PopupBlocker::PopupControlState PopupBlo
             }
             break;
           default:
             break;
         }
       }
       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;
     case ePointerEventClass:
       if (aEvent->IsTrusted() &&
           aEvent->AsPointerEvent()->button == WidgetMouseEvent::eLeftButton) {
         switch (aEvent->mMessage) {
           case ePointerUp:
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1286,17 +1286,17 @@ pref("dom.disable_window_open_feature.mi
 pref("dom.disable_window_open_feature.status",      true);
 pref("dom.disable_window_showModalDialog",          true);
 
 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);
 
 pref("dom.storage.enabled", true);
 // Whether or not LSNG (Next Generation Local Storage) is enabled.
 // See bug 1510410 for enabling this on Nightly.
 #ifdef NIGHTLY_BUILD