views:

347

answers:

1

I'm trying to add hidden browser element dynamically from Firefox extension but, although it adds successfully, it gives me Error: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIWebNavigation.sessionHistory]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://global/content/bindings/browser.xml :: :: line 641" data: no] Source File: chrome://global/content/bindings/browser.xml Line: 647

Code looks like this:

let parent = document.querySelector("#browser");
let browser = document.createElement("browser");
browser.style.visibility = "hidden";
parent.appendChild(browser);

What I'm doing wrong here?

A: 

<browser/> without type="content" or content-primary doesn't work very well and shouldn't be used anyway for not trusted. Didn't test the hidden case, but just putting <browser/> in the XUL results in an error message that you get and adding the type attribute fixes the problem. So try adding:

browser.setAttribute("type", "content");

before the appendChild line.

Nickolay
Unfortunately, canvas.getImageData() doesn't work when called from chrome code if canvas resides in sandboxed document.
vava
Please create a testcase showing this and post somewhere or file a bug. I don't see why it shouldn't work.
Nickolay