Cannot load extensions with background scripts

I am trying to make an extension for my personal use. I started writing a couple lines of code and it works in google chrome, but the same extension gives me an error on firefox.

The extension needs only a background script and needs to listen for tab creation events.

I went to about:debugging and clicked on “Load temporary add-on” and selected my extension’s manifest file, it loads, but the console.log calls doesn’t work. I noticed it gives me a warning
Loading failed for the with source “moz-extension://…/background.js”. with the id of the extension.

I looked a bit on the internet and disabled all addons and started firefox in safe mode, but the warning still persists. I tried to add a background page instead of a script and just calling console.log in that but that still didn’t work.

In the end, I went to mozilla’s example extensions webpage and installed a couple of them, but none of them worked, so the problem isn’t in my code.

Is there any way i can fix this? I can’t get a more descriptive error than loading failed.

Try to use web-ext . It will run fresh Firefox with empty default profile. See if it will work there:

npm i -g web-ext
cd /my_extension_dir
web-ext run

I tried web-ext tool, and even tried building and trying to install the zip file but I couldn’t. After searching a bit, I learned that I need to download Firefox developer or nightly to install unsigned extensions.

I downloaded nightly, set xpinstall.signatures.required to false and tried to install some extensions (zipped without compression and renamed to .xpi) on nightly, and I get an error saying they are corrupt. Trying to install temporary addon through the about:debugging page still has the same effect, the extension shows as loaded, but doesn’t work.

I thought maybe my Firefox profile could be bugged, since I use it for a couple of years, so I deleted my profile folder but nothing changed.

I created a virtual machine and installed Firefox in it, and can (partially) install addons to that one. Some of the extensions from the examples doesn’t work as advertised, but my extension works.

The only other potentially different thing is I noticed when I went to options page in Firefox, I saw a message saying “Your browser is being managed by your organization”. I have recently tried to uninstall an antivirus and failed, which I assume has left ImportEnterpriseRoots policy. I deleted the registry keys and that warning is gone now.

So I guess the problem is in my computer, but outside of Firefox (or at least my profile). As far as I know I don’t have any system-wide program that can block requests in Firefox.

Where should I look next?

So few things I would mention.
You don’t need to change any settings in about:config in order to test your extensions.
When running “web-ext run”, new temporary profile is created, so even if you current profile is corrupted, it won’t affect it.
After loading extension, look for error is the Browser console, it’s not the same as Web Console. You can open it with “Ctrl + Shift + J”.

Also if you can, paste here content of your manifest.json file.

Ok, I accidentaly solved my problem, but I’ve found a bug (I think).

I created a ramdisk on my computer at drive A:\ and I was extracting the example extensions and doing my development on that drive. I copied my extension (and an example extension) to desktop and loaded them as temporary extensions and everything works normally.

I can load the same extension from any folder on C:\ and D:\ drives but not from A:\ drive.