Creating unsafe browser XUL element from Firefox extension gives (NS_ERROR_FAILURE) [nsIWebNavigation.sessionHistory]
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 Fil开发者_如何学Goe: 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?
<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.
精彩评论