user5345663
user5345663

Reputation:

Firefox SDK: Redirect to ressource HTML denied

I'm trying to write a Firefox Addon with the Addon SDK to redirect some websites based on their URL. I have created a HTML page and put it in the data directory. I get the path with:

var data = require("sdk/self").data;
var myWebsite = data.url("myWebsite.html");

I'm using PageMod to start a script given an array of URLs:

pageMod.PageMod({
    include: ArrayOfUrls,
    contentScriptFile: "./myScript.js",
    contentScriptOptions: {"myWebsite" : myWebsite}
});

In myScript.js I'm checking if some requirements are fulfilled and if so I try to redirect to my local website with:

window.location.replace(self.options.myWebsite);

But I always get the following error message in the console:

Object
- _errorType = Error
- message = Access to 'resource://myAddon/data/myWebsite.html' from script denied

If I enter the path to the local website (resource://myAddon/...) manually in the adress bar of the browser it works. If I redirect to another website (e.g. http://example.com/) it works as well.

So I guess there's a security setting or so I need to change to make the local redirect possible, but I can't find anything in the documentation or on the web. I hope somebody here can tell me what I'm doing wrong.

Upvotes: 1

Views: 106

Answers (1)

user5345663
user5345663

Reputation:

In package.json I had to add the following line to make it work:

"permissions": {"cross-domain-content": ["resource://myAddon/data/"]}

Further documentation can be read in link Noitidart provided in his comment.

Upvotes: 2

Related Questions