My firefox addon isn't able to use specified APIs

Hello, I’m working on a download manager extension and have been having issues getting the ‘downloads’ API to work. Basically, In my manifest file I have “permissions”: [“downloads”, “”]. However when I load my extension as a temp addon and try running the code browser.downloads.showDefaultFolder() it simply does not run, and it stops any js after that line from running. I thought this was an issue because my addon was not signed. So, I went and uploaded my addon to get it signed. Still I am having this issue. I even installed a different download manager (Turbo Download Manager 3rd Edition) and looked at their manifest file to make sure I didn’t have improper syntax. I can even use the inspect button on turbo download manager in the addon debugger and use browser.downloads.showDefaultFolder() in the console and it works perfectly. But when I inspect my extension and run the same thing in the console it says browser is not defined. The last thing I noticed is when I inspect turbo download manager in the URL it says moz-exstension whereas my extension says chrome. I know that chrome extensions use different syntax but I’m unsure why my extension say chrome on it? Any help would be much appreciated and thanks in advance

The browser namespace is not defined only on normal web-pages. All other addon contexts should have it available.

However, running code in console while debugging may probably fail as well.

Anyway, don’t release the addon to see if it helps, it wont :slight_smile:. Always make sure the addon works while loaded as temporary.

Also, it’s best to use web-ext tool for development, it creates new blank profile so it’s often “more stable” than your normal profile (especially if you have many other addons and about:config changes).

And lastly, from what context are you trying to execute the browser.downloads.showDefaultFolder? Some API may not be available in the content scripts, so maybe execute it in the background script instead.

Awesome! Thanks for the tips. I’m still really new to this and I didn’t know certain things needed to run in the background script. Executing the code there worked!

Only the content scripts are limited, all other contexts should be fine as well, including addon pages or popup.
It’s a common practice to send messages to your background script when you need to execute something from a content script.

Also, see this article for more info: