browserAction.setBadgeText() not working in FF for Android?

I have an add-on that sets a short badge text indicating the status of my add-on. This badge text should be shown across the icon of the add-on.

It works fine for the desktop version of Firefox, but on Android it seems like this call is not doing anything.

Here’s the documention for this call that I found: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserAction/setBadgeText

Based on the documentation it should work in Firefox for Android, version >= 79.

I’m using the latest nightly build. Is this a regression or a known problem?

I just threw a minimal test case and it worked as expected on my end. If you’re still experiencing issues, it might be best if you can share a link to a paste or repo containing your extension’s source.

manifest.json

{
  "manifest_version": 2,
  "name": "My Extension",
  "version": "1.0",
  "browser_action": {},
  "background": {
    "scripts": ["background.js"],
    "persistent": false
  }
}

background.js

browser.browserAction.onClicked.addListener(() => {
  browser.browserAction.setBadgeText({
    text: Math.floor(Math.random() * 1000).toString()
  });
});

Hi @dotproto, I figured out what the problem was: My default_title string under browser_action was too long, so the badge got pushed too far to the right and I couldn’t see it. I shortened the default_title, now it’s working.

Thanks for your help!

Oh, interesting. Thanks for sharing. Ideally the browser would trim strings that are too long to display. I’ll pass this along.

I just created a bug report for this issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1874003