Get the raw content of the current page (mission impossible?)

Hello,

I’m the developer of the Asciidoctor Add-on. The goal of this add-on is to convert AsciiDoc (text format) to HTML. So when the user browse to a local or remote text file the extension will get the text content, convert it to HTML and replace the page with the generated HTML.

The concept is pretty straightforward but somehow it’s really hard to make it work!

Recently, Chrome decided that it was unsafe/detrimental to fetch the content of the current page in the content script: https://www.chromium.org/Home/chromium-security/extension-content-script-fetches/
So I had to move all the fetch logic to the background script.
Problem solved! :tada:

But now it’s not working on Firefox, I get the following error:

Security Error: Content at moz-extension://2dfbcb1d-0326-4869-8e3b-b3eded31b2e3/_generated_background_page.html may not load or link to file:///path/to/file.adoc.

Interestingly, I can fetch content from a remote server. For instance, when I browse to file:///path/to/file.adoc, I can fetch content from https://raw.githubusercontent.com/some/repository/master/README.adoc but not from file:///path/to/file.adoc… for security reasons… right… :man_shrugging:

I found a 4 years old related bug in Bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1266960

I can’t understand why is it so hard to get the raw content of the current page and why/how is that unsafe?
I mean, my extension declares the correct permissions and the user explicitly browse to an AsciiDoc file…

Am I missing something? How can work around this security constraint?

Thanks for your help.
Guillaume