diff --git a/addon-sdk/source/lib/sdk/panel/utils.js b/addon-sdk/source/lib/sdk/panel/utils.js index 4f8772c30373..b83df9f38f89 100644 --- a/addon-sdk/source/lib/sdk/panel/utils.js +++ b/addon-sdk/source/lib/sdk/panel/utils.js @@ -9,6 +9,7 @@ module.metadata = { }; const { Cc, Ci } = require("chrome"); +const { Services } = require("resource://gre/modules/Services.jsm"); const { setTimeout } = require("../timers"); const { platform } = require("../system"); const { getMostRecentBrowserWindow, getOwnerBrowserWindow, @@ -186,6 +187,13 @@ function display(panel, options, anchor) { panel.setAttribute("flip", "both"); } + panel.viewFrame = document.importNode(panel.backgroundFrame, false); + panel.appendChild(panel.viewFrame); + + let {privateBrowsingId} = getDocShell(panel.viewFrame).getOriginAttributes(); + let principal = Services.scriptSecurityManager.createNullPrincipal({privateBrowsingId}); + getDocShell(panel.viewFrame).createAboutBlankContentViewer(principal); + // Resize the iframe instead of using panel.sizeTo // because sizeTo doesn't work with arrow panels panel.firstChild.style.width = width + "px"; @@ -252,12 +260,10 @@ function make(document, options) { document = document || getMostRecentBrowserWindow().document; let panel = document.createElementNS(XUL_NS, "panel"); panel.setAttribute("type", "arrow"); - panel.setAttribute("sdkscriptenabled", "" + options.allowJavascript); + panel.setAttribute("sdkscriptenabled", options.allowJavascript); - // Note that panel is a parent of `viewFrame` who's `docShell` will be - // configured at creation time. If `panel` and there for `viewFrame` won't - // have an owner document attempt to access `docShell` will throw. There - // for we attach panel to a document. + // The panel needs to be attached to a browser window in order for us + // to copy browser styles to the content document when it loads. attach(panel, document); let frameOptions = { @@ -269,34 +275,29 @@ function make(document, options) { // history and in consequence do not dispatch "inner-window-destroyed" // notifications. browser: false, - // Note that use of this URL let's use swap frame loaders earlier - // than if we used default "about:blank". - uri: "data:text/plain;charset=utf-8," }; let backgroundFrame = createFrame(addonWindow, frameOptions); setupPanelFrame(backgroundFrame); - let viewFrame = createFrame(panel, frameOptions); - setupPanelFrame(viewFrame); + getDocShell(backgroundFrame).inheritPrivateBrowsingId = false; - function onDisplayChange({type, target}) { - // Events from child element like