Safari extension - badgeText and title set for a tab

I am building Safari extension. In my background script I am setting badge text and title like this:

browser.action.setBadgeText({text: badgeText, tabId: tabId});
browser.action.setTitle({title: badgeText + " found images", tabId: tabId})

, where tabId is correct id of current tab.

I was expecting that in this way I am setting a different badge and title for different tabs, so that badge and title would automatically switch if I activate different tab. However this does not happen, badge and title behave as if set globaly and don't change with tabs. How is this expected to work?

I have also tried to set badge globally, and update it every time user switches a tab. I have set up listener like this:

browser.tabs.onActivated.addListener(function(actInfo) {
    console.log("switched tab to " + actInfo.tabId);
});

, however the event never fires, tab switch is never logged in console.

Am I doing something wrong here?

This is my manifest, if there was a problem with permissions or something similar.

{
    "manifest_version": 3,
    "default_locale": "en",

    "name": "Test",
    "description": "Test Extension",
    "version": "1.0",

    "icons": {
        "48": "images/icon-48.png",
        "96": "images/icon-96.png",
        "128": "images/icon-128.png",
        "256": "images/icon-256.png",
        "512": "images/icon-512.png"
    },

    "action": {
        "default_title": "a test title",
        "default_popup": "popup/hello.html",
        "default_icon": {
            "16": "images/toolbar-icon-16.png",
            "19": "images/toolbar-icon-19.png",
            "32": "images/toolbar-icon-32.png",
            "38": "images/toolbar-icon-38.png",
            "48": "images/toolbar-icon-48.png",
            "72": "images/toolbar-icon-72.png"
        }
    },


    "web_accessible_resources": [
        {
          "matches": ["*://*/*"],
          "resources": ["images/*", "css/*", "scripts/lib/*"]
        }
      ],
  
    "background": {
        "service_worker": "scripts/background.js",
        "type": "module"
      },
  
    "content_scripts":
    [
        {
            "js": [
                "scripts/content.js"
            ],
            "matches": [
                "http://*/*",
                "https://*/*"
            ],
            "css": ["css/style.css"],
            "run_at": "document_end"
        }
    ],

    "permissions": [
        "nativeMessaging", "tabs"
    ]
}

What version of Safari, OS, and platform are you seeing this behavior on? It would be helpful to know if this issue is version-specific.

It sounds like you’re doing everything correctly, so this might be a bug. Could you also attach a sample project to a feedback report via Feedback Assistant? That way, we can take a closer look.

@Frameworks Engineer OK, I have composed a minimal example project and created a new feedback here: https://feedbackassistant.apple.com/feedback/15231333

This appears to be fixed in Safari 18 and Safari Technology Preview 205 with the attached project.

Safari extension - badgeText and title set for a tab
 
 
Q