Bug 1300587 - Workaround issues with dock/undock devtools toolbox with a devtools_panel. r=kmag
authorLuca Greco <lgreco@mozilla.com>
Fri, 07 Oct 2016 12:37:53 +0200
changeset 343297 6d4af96450ed20812649f023bd373110505fabf5
parent 343296 de8052439ef29cf0d06f836dac9dc4ad3e2ecdbc
child 343298 c96198deb0ef189af1c617da52227e5ef5c5aa30
push id31376
push userkwierso@gmail.com
push dateFri, 17 Feb 2017 01:09:40 +0000
treeherdermozilla-central@6cefe01ca774 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1300587, 1075490
milestone54.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 1300587 - Workaround issues with dock/undock devtools toolbox with a devtools_panel. r=kmag - this workaround is related to the same issue described in Bug 1075490 for the SDK "dev/panel" module. MozReview-Commit-ID: 5UYn1F88u1
browser/components/extensions/ext-devtools-panels.js
toolkit/components/extensions/ExtensionManagement.jsm
--- a/browser/components/extensions/ext-devtools-panels.js
+++ b/browser/components/extensions/ext-devtools-panels.js
@@ -1,12 +1,13 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
+Cu.import("resource://gre/modules/AppConstants.jsm");
 Cu.import("resource://gre/modules/ExtensionParent.jsm");
 Cu.import("resource://gre/modules/ExtensionUtils.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "E10SUtils",
                                   "resource:///modules/E10SUtils.jsm");
 
 const {
@@ -116,16 +117,22 @@ class ParentDevToolsPanel {
 
     const {extension} = this.context;
 
     let awaitFrameLoader = Promise.resolve();
     if (extension.remote) {
       browser.setAttribute("remote", "true");
       browser.setAttribute("remoteType", E10SUtils.EXTENSION_REMOTE_TYPE);
       awaitFrameLoader = promiseEvent(browser, "XULFrameLoaderCreated");
+    } else if (!AppConstants.RELEASE_OR_BETA) {
+      // NOTE: Using a content iframe here breaks the devtools panel
+      // switching between docked and undocked mode,
+      // because of a swapFrameLoader exception (see bug 1075490).
+      browser.setAttribute("type", "chrome");
+      browser.setAttribute("forcemessagemanager", true);
     }
 
     let hasTopLevelContext = false;
 
     // Listening to new proxy contexts.
     const unwatchExtensionProxyContextLoad = watchExtensionProxyContextLoad(this, context => {
       // Keep track of the toolbox and target associated to the context, which is
       // needed by the API methods implementation.
--- a/toolkit/components/extensions/ExtensionManagement.jsm
+++ b/toolkit/components/extensions/ExtensionManagement.jsm
@@ -278,20 +278,31 @@ function getAPILevelForWindow(window, ad
     let parentWindow = docShell.sameTypeParent.QueryInterface(Ci.nsIInterfaceRequestor)
                                .getInterface(Ci.nsIDOMWindow);
 
     // The option page iframe embedded in the about:addons tab should have
     // full API level privileges. (see Bug 1256282 for rationale)
     let parentDocument = parentWindow.document;
     let parentIsSystemPrincipal = Services.scriptSecurityManager
                                           .isSystemPrincipal(parentDocument.nodePrincipal);
+
     if (parentDocument.location.href == "about:addons" && parentIsSystemPrincipal) {
       return FULL_PRIVILEGES;
     }
 
+    // NOTE: Special handling for devtools panels using a chrome iframe here
+    // for the devtools panel, it is needed because a content iframe breaks
+    // switching between docked and undocked mode (see bug 1075490).
+    let devtoolsBrowser = parentDocument.querySelector(
+      "browser[webextension-view-type='devtools_panel']");
+    if (devtoolsBrowser && devtoolsBrowser.contentWindow === window &&
+        parentIsSystemPrincipal) {
+      return FULL_PRIVILEGES;
+    }
+
     // The addon iframes embedded in a addon page from with the same addonId
     // should have the same privileges of the sameTypeParent.
     // (see Bug 1258347 for rationale)
     let parentSameAddonPrivileges = getAPILevelForWindow(parentWindow, addonId);
     if (parentSameAddonPrivileges > NO_PRIVILEGES) {
       return parentSameAddonPrivileges;
     }