It is empty due to firefox's security policy, which prevents content scripts from loading resource URLs in frames. The solution may be to install it directly from the background script, for this you will need to use a low-level sdk.
var { viewFor } = require("sdk/view/core"); var tab_utils = require("sdk/tabs/utils"); var iframe = viewFor(tab).linkedBrowser._contentWindow.document.querySelector('iframe[src="' + self.data.url("sandbox.html") + '"]') iframe.contentWindow.location.href = iframe.getAttribute("src")
therefore, fully working code will look like this:
data / appender.js
var iframeTag = document.createElement("iframe"); iframeTag.src = self.options.frameUrl; document.body.appendChild(iframeTag);
main.js
tabs = require("sdk/tabs") self = require("sdk/self") var { viewFor } = require("sdk/view/core"); tab_utils = require("sdk/tabs/utils"); tabs.on("ready", function(tab) { var worker = tab.attach({ contentScriptFile: [self.data.url("js/appender.js") ], attachTo: 'top', contentScriptOptions: { frameUrl: self.data.url("sandbox.html") } }); worker.port.on('attached', function() { reinitIframe(tab) }); function reinitIframe(tab) { var iframe = viewFor(tab).linkedBrowser._contentWindow.document.querySelector('iframe[src="' + self.data.url("sandbox.html") + '"]') iframe.contentWindow.location.href = iframe.getAttribute("src") } })
You may need a cross-process wrapper to make it work in a future version of Firefox with electrolysis
source share