I recently (as in, this past week) ported a Chrome extension over to Firefox’s WebExtension API, and all said, it’s been a lot less painful than I had expected. Everything seemed to work, and I was looking forward to getting a beta version out to users. I uploaded the add-on to AMO, installed it from there, and… it doesn’t work.
After some digging, it looks like I’m having a really strange issue with XMLHttpRequests from background & content scripts. Essentially, I have a few configuration JSON files stored locally in my add-on which I’m trying to retrieve via a GET Ajax request - almost exactly like what’s described here, though of course in Firefox: https://developer.chrome.com/apps/xhr#extension-origin
This works exactly as expected when I load my add-on as a temporary WebExtension, and it works in Chrome, but fails with an XHR status 0 once the add-on is packaged and signed through AMO. Unfortunately, status 0 and status text “error” are all the information I get from the XHR object, and there’s no error logged to the console, and the other information fields on the object are empty.
Again, the code in both cases is exactly the same; I can download the packaged extension from AMO, unzip it, and load it as a temporary extension, and it works. Firefox must be doing something different - possibly regarding the extension origin, hence status 0 - between temporary and packaged extensions. Any thoughts on how I can work around this, or get it submitted as a bug if it is one?
Thanks!