Bug 1515265: Call stopPropagation() and preventDefault() at all places where handle contextmenu event and show the popup. r=jdescottes
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Fri, 25 Jan 2019 04:31:45 +0000
changeset 515452 635099091943c0ff81849ec224ac3e1ecc4a768e
parent 515451 e51312da073fe84994b537536d12e639e68cc59e
child 515453 319ae34add89185fc5cc96e3a8b6ac71592f9b10
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1515265
milestone66.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 1515265: Call stopPropagation() and preventDefault() at all places where handle contextmenu event and show the popup. r=jdescottes Depends on D17457 Differential Revision: https://phabricator.services.mozilla.com/D17458
devtools/client/inspector/computed/computed.js
devtools/client/shared/inplace-editor.js
devtools/client/shared/widgets/SideMenuWidget.jsm
devtools/client/shared/widgets/TreeWidget.js
--- a/devtools/client/inspector/computed/computed.js
+++ b/devtools/client/inspector/computed/computed.js
@@ -690,16 +690,20 @@ CssComputedView.prototype = {
   focusWindow: function() {
     this.styleWindow.focus();
   },
 
   /**
    * Context menu handler.
    */
   _onContextMenu: function(event) {
+    // Call stopPropagation() and preventDefault() here so that avoid to show default
+    // context menu in about:devtools-toolbox. See Bug 1515265.
+    event.stopPropagation();
+    event.preventDefault();
     this.contextMenu.show(event);
   },
 
   _onClick: function(event) {
     const target = event.target;
 
     if (target.nodeName === "a") {
       event.stopPropagation();
--- a/devtools/client/shared/inplace-editor.js
+++ b/devtools/client/shared/inplace-editor.js
@@ -1208,16 +1208,20 @@ InplaceEditor.prototype = {
 
     if (prevent) {
       event.preventDefault();
     }
   },
 
   _onContextMenu: function(event) {
     if (this.contextMenu) {
+      // Call stopPropagation() and preventDefault() here so that avoid to show default
+      // context menu in about:devtools-toolbox. See Bug 1515265.
+      event.stopPropagation();
+      event.preventDefault();
       this.contextMenu(event);
     }
   },
 
   /**
    * Open the autocomplete popup, adding a custom click handler and classname.
    *
    * @param {Number} offset
--- a/devtools/client/shared/widgets/SideMenuWidget.jsm
+++ b/devtools/client/shared/widgets/SideMenuWidget.jsm
@@ -411,16 +411,20 @@ SideMenuWidget.prototype = {
     let node = e.originalTarget;
     while (node && node !== this._list) {
       if (node.hasAttribute("contextmenu")) {
         return;
       }
       node = node.parentNode;
     }
 
+    // Call stopPropagation() and preventDefault() here so that avoid to show default
+    // context menu in about:devtools-toolbox. See Bug 1515265.
+    e.stopPropagation();
+    e.preventDefault();
     this._contextMenu.openPopupAtScreen(e.screenX, e.screenY, true);
   },
 
   window: null,
   document: null,
   _showArrows: false,
   _showItemCheckboxes: false,
   _showGroupCheckboxes: false,
--- a/devtools/client/shared/widgets/TreeWidget.js
+++ b/devtools/client/shared/widgets/TreeWidget.js
@@ -122,16 +122,20 @@ TreeWidget.prototype = {
 
   /**
    * Sets up the root container of the TreeWidget.
    */
   setupRoot: function() {
     this.root = new TreeItem(this.document);
     if (this.contextMenuId) {
       this.root.children.addEventListener("contextmenu", (event) => {
+        // Call stopPropagation() and preventDefault() here so that avoid to show default
+        // context menu in about:devtools-toolbox. See Bug 1515265.
+        event.stopPropagation();
+        event.preventDefault();
         const menu = this.document.getElementById(this.contextMenuId);
         menu.openPopupAtScreen(event.screenX, event.screenY, true);
       });
     }
 
     this._parent.appendChild(this.root.children);
 
     this.root.children.addEventListener("mousedown", e => this.onClick(e));