Get current tab's container name in background script

Hi,
If a user uses Firefox Container addon, she already has the means to open or create new container tabs. I got a feature request to expose different settings to different container tabs provided by Firefox Container addon. I don’t want my addon to provide the means to create new containers etc, just wish to detect the container name of current tab and adjust settings. (or detect the list of containers, and adjust variables in background script for different containers, so to provide different experience inside different containers)

I have read the contexualidentities documentation in MDN,but I am not able to find how one extension can query the current tab’s container name. I have tried contextual identities query({}) API and as expected it returns all the container names but I don’t see how to find the current tab’s container from this list.

Can you please advice or suggest how to do this or provide example if possible?

Thanks.

The tabs.Tab page mentions a cookieStoreId property, and the contextualIdentities.get() method uses the cookieStoreId to get a contextualIdentity object. Maybe that?

Thanks for the suggestion. I think the tabs.tab returned by running tabs.query or getcurrent in background script will not return cookiestoreid.

More context: My addon deals with webrequest API in blocking mode. Webrequest details object has tabid but it doesn’t have cookiestoreid either. I wish to find find how to identify that a given webrequest Belongs to which container’s tab.

From tabs.tab object page :
“In extension background scripts, the only properties that are available are tabId and windowId”

I don’t understand what that comment refers to. When I use browser.tabs.query() in a background script, the array of tabs gives me all the properties I care about (e.g., active, audible, discarded, pinned). I do have tabs API permission, if that matters.

Oh Ok. I’ll try it out in code once and get back here and confirm.