Porting Chrome Web extension to Firefox and script issues

Talk about add-ons and extension development.
Post Reply
tom-giga
Posts: 6
Joined: September 14th, 2015, 2:51 pm

Porting Chrome Web extension to Firefox and script issues

Post by tom-giga »

Hello, I have previously (over a year ago) ported Chrome extensions to Firefox without issues. However, my new extension seems to have quite a few issues with scripts. In fact none of my background scripts will load. I get the following errors in the debug developers tool.

Loading failed for the <script> with source “moz-extension://72d5d094-adf3-4cf8-a26d-cd30f3120da9/js/background.js”. _generated_background_page.html:12
Loading failed for the <script> with source “moz-extension://72d5d094-adf3-4cf8-a26d-cd30f3120da9/js/jquery.js”. _generated_background_page.html:5
Loading failed for the <script> with source “moz-extension://72d5d094-adf3-4cf8-a26d-cd30f3120da9/js/aes.js”. _generated_background_page.html:6
Loading failed for the <script> with source “moz-extension://72d5d094-adf3-4cf8-a26d-cd30f3120da9/js/jsHash.js”. _generated_background_page.html:7
Loading failed for the <script> with source “moz-extension://72d5d094-adf3-4cf8-a26d-cd30f3120da9/js/cryptoHelpers.js”. _generated_background_page.html:8
Loading failed for the <script> with source “moz-extension://72d5d094-adf3-4cf8-a26d-cd30f3120da9/js/vars.js”. _generated_background_page.html:9
Loading failed for the <script> with source “moz-extension://72d5d094-adf3-4cf8-a26d-cd30f3120da9/js/login.js”. _generated_background_page.html:10

I have read many articles on the web, and tried many ways to load these scripts, but seem like I get the same errors no matter what.

I also have an HTML page that sends a message to the background that seems not to load a local script either.

<head>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</head>

So it looks like the extension is totally broken.

I could use a little help and advise on how to get this extension going. It seems like I have read a bunch of contradictory information all over the web about how to use the CSP entry in the manifest file.

Is there an example extension on how to properly load scripts?

Any help would be appreciated.

Thanks,
Tom
tom-giga
Posts: 6
Joined: September 14th, 2015, 2:51 pm

Re: Porting Chrome Web extension to Firefox and script issue

Post by tom-giga »

Oddly, I unloaded my extension and restarted Firefox and then reloaded my extension and everything started working. That seemed to fix all the problems that I was experiencing. Plus I had to add the following line to my manifest.

"content_security_policy": "default-src 'self'"

All seems to be working fine now. If I had to take a guess, I would say that the reload button is not loading the complete extension. :-k
Brummelchen
Posts: 4480
Joined: March 19th, 2005, 10:51 am

Re: Porting Chrome Web extension to Firefox and script issue

Post by Brummelchen »

thats normal when testing extensions, it happens (also here)

reloading extension? dont you pack it as XPI and drag&drop it in firefox addons?

btw my first guess was that you did not list them in manifest, that is sometimes needed for proper working.

Ps looks like a formfiller and/or keepass - if so you should really have a look on AMO - that was already invented ;)
Post Reply