Closed Bug 1711040 Opened 2 months ago Closed 1 month ago

Wrong content script tab ID with multiple mailTab windows


(Thunderbird :: Add-Ons: Extensions API, defect)



(thunderbird_esr78 wontfix, thunderbird90 affected)

91 Branch
Tracking Status
thunderbird_esr78 --- wontfix
thunderbird90 --- affected


(Reporter: zephyr, Assigned: TbSync)



(2 files)

Attached file reproducer


When using content script on Thunderbird the receiver get the tab of the sender as an argument. It contains the id of the tab. When opening multiple windows the tab ID received can be wrong. Let's consider the minimal reproducer add-on below.



    "manifest_version": 2,
    "name": "test tabId",
    "description": "Showcase the tabId bug",
    "version": "1.0.0",
    "author": "author",
    "applications": {
        "gecko": {
            "id": "",
            "strict_min_version": "78.4"
    "background": {
        "scripts": [
    "message_display_action": {
        "default_title": "Test"
    "permissions": [


messenger.messageDisplayScripts.register({'js': [{'file': 'content.js'}]});

messenger.runtime.onConnect.addListener((p) => {
    console.log('email tabId ',;



Expected behavior

This should log the tab ID to the console and set the tab ID as the badge text each time a message is displayed

Actual behavior

When opening a second mailTab in a new window, the badge text is updated to the new tab id as expected. But when coming back to the first mailTab, the tab ID displayed is the id of the second tab. The tab ID received is the same for the first and second tab.

Closing the second window restore the correct behavior.


The same wrong behavior appear when using messenger.runtime.sendMessage()

The wrong behavior only appear on mailTab and not on message tab.

The issue is present on all latest Thunderbird from all channels (release, beta, daily)

I have attach the reproducer

Is this a duplicate of 1716262?

Flags: needinfo?(geoff)

Hm, no.

Flags: needinfo?(geoff)

There's really only one instance of the mail tab per window. When you switch tabs it updates to look like the new tab. That'll be the cause.

I probably need one more pointer. I observed the following:

  • window A has mailtab (id 2) + message Tab
  • window B with mailTab (id 5) is opened and and also a message Tab, mailTab is active
  • window A is switched to message Tab and back to mailTab -> It thinks it is id5
  • window B is switched to message Tab
  • window A is switched to message Tab and back to mailTab -> Actor error, mailtab does not know its id

So the second window is somehow the only reference and its active mail tab info is used for all mail tabs in all windows. If it does not have an active mail tab, all other mail tabs fails to get any active mail tab info.

Any idea where to look?

Flags: needinfo?(geoff)

A messenger.messageDisplayAction.onClicked event always returns to correct id.

This line is returning the wrong id (always the same, regardless which mailtab it actually is) here:

is just "messagepane" , so the same for all windows and thus overwritten. Could we use browser.browserId which seems to be different for different windows?

But is also used in 2 more places a few lines below, change there as well?

Assignee: nobody → john
Flags: needinfo?(geoff)
Ever confirmed: true
Target Milestone: --- → 91 Branch

Pushed by
Support multiple windows with mailTabs. r=darktrojan

Closed: 1 month ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.