3 ms·
I've run into several problems porting a Chrome extension to Firefox. One of the biggest is that if your extension talks to a server (in my case, it was Fireba
by winter_blue 9y ago
I've run into several problems porting a Chrome extension to Firefox.
One of the biggest is that if your extension talks to a server (in my case, it was Firebase), and a web page specifies a CSP (Content Security Policy), Firefox applies the CSP to your extension's content scripts as well, whereas Chrome does not. This is a bug that they've acknowledged, but haven't fixed in over a year: https://bugzilla.mozilla.org/show_bug.cgi?id=1267027 https://bugzilla.mozilla.org/show_bug.cgi?id=1267027
This bug makes it very painful to develop an FF extension, as you now need to create both a background script and a content script, talk to the server in the background script, and then have the background script relay information back to the content script. It's ridiculous.
The other problem I had, had to do with using libraries. In Chrome, you can just list the library before the script, and it just works. For example, you could have:
content_scripts: ['Rx.min.js', 'your_content_script.js']
Above, with Rx.min.js, I was able to refer to Rx without any trouble inside my content script in Chrome. In Firefox, it didn't work. Rx was an undefined variable. The Rx.min.js script was something that you could include in a page with a script tag, so it should have set that variable. Oh well... I ended up having to use webpack to be able to use Rx inside the content script on Firefox.
And that isn't the end of my problems. I also had some trouble getting the communication between content page(s) and the background page working. The examples listed in the MDN documentation simply do not work, even when copied verbatim into a new web-ext project...
With the upcoming deprecation of add-ons in Firefox 57, and the really buggy state of WebExtensions in Firefox, it's going to be a pandemonium when add-ons support is dropped. WebExtension developers are going to have quite the experience porting their extensions from Chrome to Firefox.