Bug 1495944: Show/Hide 'Inspect Element' item in content context menu. r=jdescottes
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Fri, 18 Jan 2019 16:21:43 +0000
changeset 511583 4674df9d14e3126a0ab6644e29b666823426bb9c
parent 511582 a93d114f9bc94b1681c08a4a496a25451b540d82
child 511584 1f135369b9f9b8f1127d62aecbffa30fd05c09d1
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1495944, 1515265
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 1495944: Show/Hide 'Inspect Element' item in content context menu. r=jdescottes This patch removes "Inspect Element" menu item from content context menu in case that about:devtools-toolbox are opening. However, we may be able to remove after fixing 1515265. Depends on D16684 Differential Revision: https://phabricator.services.mozilla.com/D16685
browser/base/content/nsContextMenu.js
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -420,22 +420,31 @@ nsContextMenu.prototype = {
     this.setItemAttr("context-sendaudio", "disabled", !this.mediaURL || mediaIsBlob);
   },
 
   initViewItems: function CM_initViewItems() {
     // View source is always OK, unless in directory listing.
     this.showItem("context-viewpartialsource-selection",
                   this.isContentSelected);
 
+    const {gBrowser} = this.browser.ownerGlobal;
+    // Hide menu that opens devtools when the window is showing `about:devtools-toolbox`.
+    // This is to avoid displaying multiple devtools at the same time. See bug 1495944.
+    const isAboutDevtoolsToolbox = gBrowser &&
+                                   gBrowser.currentURI &&
+                                   gBrowser.currentURI.scheme === "about" &&
+                                   gBrowser.currentURI.filePath === "devtools-toolbox";
+
     var shouldShow = !(this.isContentSelected ||
                        this.onImage || this.onCanvas ||
                        this.onVideo || this.onAudio ||
                        this.onLink || this.onTextInput);
 
     var showInspect = this.inTabBrowser &&
+                      !isAboutDevtoolsToolbox &&
                       Services.prefs.getBoolPref("devtools.inspector.enabled", true) &&
                       !Services.prefs.getBoolPref("devtools.policy.disabled", false);
 
     var showInspectA11Y = showInspect &&
                           // Only when accessibility service started.
                           Services.appinfo.accessibilityEnabled &&
                           this.inTabBrowser &&
                           Services.prefs.getBoolPref("devtools.enabled", true) &&