Bug 1283582 - Stop displaying the context menu in Fennec if web content did a preventDefault on the event. r=margaret, a=gchang
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 05 Jul 2016 10:09:38 -0400
changeset 339871 a5b1d40aa344f53215c8b76c03bbe9ea6b77717d
parent 339870 02e9aeb2797307e4ac68ceaed3b3c1c0644da8ec
child 339872 00e9101b9ed0353afd4e7dd956a063d7ac511c91
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, gchang
bugs1283582
milestone49.0a2
Bug 1283582 - Stop displaying the context menu in Fennec if web content did a preventDefault on the event. r=margaret, a=gchang MozReview-Commit-ID: 4JQwXNfJxip
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -2657,16 +2657,22 @@ var NativeWindow = {
      */
     show: function(event) {
       // Android Long-press / contextmenu event provides clientX/Y data. This is not provided
       // by mochitest: test_browserElement_inproc_ContextmenuEvents.html.
       if (!event.clientX || !event.clientY) {
         return;
       }
 
+      // If the event was already defaultPrevented by somebody (web content, or
+      // some other part of gecko), then don't do anything with it.
+      if (event.defaultPrevented) {
+        return;
+      }
+
       // Use the highlighted element for the context menu target. When accessibility is
       // enabled, elements may not be highlighted so use the event target instead.
       this._target = BrowserEventHandler._highlightElement || event.target;
       if (!this._target) {
         return;
       }
 
       // Try to build a list of contextmenu items. If successful, actually show the