Adding content to the Addon SDK

I am developing an addon using the Firefox Addon SDK (v.1.11). My extension dynamically creates an iframe on each website, and then uploads an html file that includes other resources such as images, font files, etc. From adding to the local directory.

Problem

When loading any of these local resources (for example, "resource: //"), the iframe cannot display them and a message is displayed:

Security bug. Content at http://www.XXX may not load or link to Resource: // XXX

This is a security measure introduced in Firefox 3 . When developing without Addon SDK, the path around it declares a directory with "contentaccessible = yes", which makes the contents of the directory accessible to everyone, including my addition. However, I could not find similar functionality using the Addon SDK. Is there a better way to use local data in an iframe that my addon creates and inserts into a page?

+4
source share
2 answers

I don't think you can directly load an iFrame that points to a resource inside your url. The browser complains because it either violates the same origin policy or uses the same script. I can’t remember which one right now.

if this is the html content that you want to download, you can always enter it in the DOM and then send a message to the document object using the event API to display your custom html. I have done this in the past and it works.

so from main.js send a message to the content script, which then inserts your iframe html into the DOM, and then you can send a message to the document object to display it.

Hope this helps.

0
source

Not sure if that was the case when you posted the question, but it looks like "resource: //" should no longer be used with the Addon SDK.

If you use the resource inside the HTML file in the extension, you can link to it locally, otherwise you must use data.url ('whatever.jpg') and pass this value as necessary.

Full details here: http://blog.mozilla.org/addons/2012/01/11/sdk-1-4-known-issue-with-hard-coding-resource-uris/

-1
source

Source: https://habr.com/ru/post/1444202/


All Articles