multi-account-containers icon indicating copy to clipboard operation
multi-account-containers copied to clipboard

Container tabs have inconsistent IDs

Open tanwald opened this issue 2 years ago • 1 comments

Before submitting a bug report

  • [X] I updated to the latest version of Multi-Account Container and tested if I can reproduce the issue
  • [X] I searched for existing reports to see if it hasn't already been reported

Step to reproduce

  1. Open a bookmark that is set to launch in a container in a new tab and log its ID!
browser.tabs.create({url: bookmark.url, windowId: 1, active: false})
  .then((tab) => {
      console.debug(tab.id);
  }, (error) => {
      console.error(`Could not create tab: ${error}`);
  });
  1. Log the ID of the new tab after webNavigation has completed!
browser.webNavigation.onCompleted.addListener((details) => console.debug(details.tabId));

Actual behavior

The ID of the created tab in step 1 is different than the ID of the same tab in step 2. The tab changes its identity.

Expected behavior

The ID of a tab should be immutable/consistent. Changes should be at least observable. Extensions that create tabs should be able to close them again.

tanwald avatar Oct 01 '23 16:10 tanwald

This is the expected behavior because you create the tab in the default contextualidentity since you didn't specify the cookieStoreId parameter (see: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/create). So what's currently happening is:

  1. Create tab in default context
  2. Multi-Account Container rules kick in and move the tab to a new context (it needs to close and reopen a new tab for that. This is how it's implemented in Firefox itself and we can't control that on the addon side).
  3. onCompleted listener returns the id of the container tab which is different from the first tab created

Related to: https://github.com/mozilla/multi-account-containers/issues/1029

dannycolin avatar Oct 05 '23 19:10 dannycolin