Reputation: 11
I have been attempting to port an existing Chrome extension to Firefox.
The extension uses a content script to add an element to a page and proceeds to bootstrap the angular app from that element.
This part works as expected, but individual directives that use templateUrl are blocked. Stepping through the code provides error messages like Access to restricted URI denied
and NS_ERROR_DOM_BAD_URI
.
In Chrome this problem is solved with the 'web_accessible_resources' whitelist.
This previous question seems to indicate that there is no analogous way to access extension resources in Firefox. This would be rather unfortunate, because, although I can inline all of the relevant templates, the extension also includes a number of images which are programmatically inserted on the page.
Is there any way to get at extension resources in an SDK extension?
If not, is it reasonably easy to do so with a legacy extension (as implied here)?
Upvotes: 1
Views: 842
Reputation: 1268
You can use the self
module in the SDK to get a resolvable resource URI for files in the data
directory. If you have your angular file in ./data/
, you can retrieve it via:
const self = require('sdk/self');
console.log(self.data.url('angular.js'));
// Prints the url of `./data/angular.js`
Upvotes: 1