Security Error When Loading Local File

In Firefox 42, I’m getting a security error when my addon attempts to load a local image file into one of its resource HTML pages. The error looks like this:

Security Error: Content at resource://jid1-aahxeyitr16k5q-at-jetpack/tabtrekker/data/tabtrekker.html may not load or link to file:///Users/gordonwong/Library/Application%20Support/Firefox/Profiles/hfs6diri.dev-edition-default/tabtrekker/images/1/0.jpg.

I wasn’t getting this error in previous Firefox versions. Is this intended behavior now?
My addon downloads those images so that it can load them faster in the future, but it looks like I can no longer do this. Any suggestions?

Try making a resource UI out of the file:/// uri you have there.

This makes a resource URI:

let res = Services.io.getProtocolHandler(“resource”).QueryInterface(Ci.nsIResProtocolHandler);
res.setSubstitution(“rawr”, Services.io.newURI(‘http://www.bing.com/’,null,null));

going to resource://rawr will load bing.com

Try putting your file uri in place of that bing.com

Please be respectful of the namespace though!
Make it something like resource://tabtrekker/content/supercoolimage.jpg

Personally I would prefer a manifest file.

Or if you are using the sdk, you can create a data folder which will automatically assign resource urls to its content. Which are handled automatically by some sdk modules. And can be retreived through the self module.

That solved the problem, thanks! I used a URI like resource://tabtrekker_image_1_0

Ah i didnt know you can put file paths in manifest file. If you didn’t know the file path ahead of time, the only way would be resource uri?

How do you do the namespace thingy for reseource uri?

do we just say: setSubs..('blah/blah/rawr'...)?

Nice @Gordon!

Wouldn’t know.
I’ve never set a resource:// dynamically.