Search code examples
javascriptfirefoxfirefox-addonfirefox-addon-sdk

Firefox Addon won't open new tab with url


I tried this code:

var contextMenu = require("context-menu");
var menuItem = contextMenu.Item({
  label: "Test name",
  contentScript:  'self.on("click", function () {' + 
                  '  window.open("options.html", "_blank");' +
                  '});'
});

But when I click on the new Context menu item, I get the following error:

Security Error: Content at "le Site" may not load or link to chrome://browser/content/options.html.

Which permissions do I have to give of get?


Solution

  • It seems that the relative address is resolved incorrectly in case of a content script - as a result you are attempting to open chrome://browser/content/options.html in a window which is correctly forbidden. Simply specify the full address and things should work:

    '  window.open("http://example.com/options.html", "_blank");' +