Bug 1300587 - Workaround issues with dock/undock devtools toolbox with a devtools_panel.
- this workaround is related to the same issue described in
Bug 1075490
for the SDK "dev/panel" module.
MozReview-Commit-ID: 5UYn1F88u1
--- 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;
}