firefoxfirefox-addonfirefox-addon-sdkfirefox-addon-webextensionsweb-extension

"Uncaught TypeError: browser.browserAction is undefined"


Trying to create a webextension, following the example from firefox bookmark-it!. I'm developing on 132.0.2 (64-bit).

I think I have copied it almost word by word, but i get on my background.js script:

Uncaught TypeError: browser.browserAction is undefined

The only mentions of this error i've found is from people trying to use it on the content or popup context. Which is not my case, i'm using on the background context. I've already searched for all the documented requirements to have that object present and I think I have it all covered, but I am still getting the error.

I worked trying to find any difference from my extension to the example one (which works fine).

At first, mine was manifest version 3, example was 2. So i Changed mine to 2. Still got the error.

My extension had a popup on the browser action and themed icons, the example didn't, so I removed it from mine. Still got the error.

Mine had sidebar action. Removed it. Still got the error.

Mine had options page. Removed it. Still got the error.

Copied the background.js script from the example into mine, still got the error.

Used a manifest that is a copy of the example, still got the error. At this point i can't think of anything else...


Solution

  • I was using a linter that renamed browser_action to action because that is deprecated on v3... since i need to use v3 eventually i will have to figure out this api on action instead...

    The example always worked, even when i changed its manifest to v3, because i was loading it directly as-is.