Closed Bug 1819794 Opened 3 years ago Closed 3 years ago

browser.tabs.create discarded tabs lose cookieStoreId

Categories

(WebExtensions :: General, defect, P3)

Firefox 110
defect

Tracking

(firefox113 fixed)

RESOLVED FIXED
113 Branch
Tracking Status
firefox113 --- fixed

People

(Reporter: drive4ik, Assigned: rpl)

References

Details

(Whiteboard: [addons-jira])

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0

Steps to reproduce:

If you create tabs using the discarded = true parameter and a non-standard cookieStoreId, after restarting the browser, or restoring a closed window, those tabs lose their cookieStoreId, and become regular tabs.

Actual results:

Tabs lose their cookieStoreId after the session is restored.

Expected results:

Tabs must not lose their cookieStoreId under any circumstances.

Test addon attached.
The problem repeats on both Windows and linux

Steps to produce a problem:

  1. Enable session recovery after restarting the browser
  2. load a temporary addon
  3. click the addon button in the topbar
  4. restart the browser

Created tabs no longer have cookieStoreId set to them

Hi Gijs,
the test extension attached to this bug is basically calling the browser.tabs.create method with the discarded and cookieStoreId options and in the tabs.create implementation we basically just pass to gBrowser.addTab the options createLazyBrowser (to create an already discarded tab) and userContextId along with the url to set on the newly created discarded tab.

I confirmed that when the tab are created the expected properties are set of the tab DOM properties (pending is set to "true" and usercontextid is set to the expected container) as well as the linked browser DOM properties (usercontextid is set), but then after restart the browser to restore the session those tabs (and linked browsers) are losing the usercontextid property.

The part that surprised me the most was that even if I active the discarded tabs before quitting and restoring the session, the tab is not in the container anymore after restarting the browser.

The fact that the tab was created as discarded is what seems to make the issue to be hit, because if I manually create a container tab (without event going through an extension, by just long clicking the + icon on the tab bar and selecting a container in a nightly build) and I load an url in it, then that tab is actually restored as a container tab (even after restoring the session a second time without activating the tabs after the first session restore).

It seems we may be missing something to handle this scenario around discarded tab correctly, and I suspect that may be around SessionStore, but I haven't dig deep enough to say for sure what and where.

Do you have some ideas about what we may missing or some specific parts of SessionStore that would be worth looking more closely to determine what we may be missing?

Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(gijskruitbosch+bugs)

The first thing I'd check is what SessionStore.getTabState(tab) returns for this discarded tab after it is created. It sounds like the userContextId might be missing there? If so, that's where I would start investigating. Does that help?

Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(lgreco)
Assignee: nobody → lgreco
Status: NEW → ASSIGNED

(In reply to :Gijs (he/him) from comment #3)

The first thing I'd check is what SessionStore.getTabState(tab) returns for this discarded tab after it is created. It sounds like the userContextId might be missing there? If so, that's where I would start investigating. Does that help?

That was extremely helpful, in fact it immediately allowed to confirm what was missing and then where it should have been done right after that.
And so I ended up drafting a patch.

Thanks a lot!

Flags: needinfo?(lgreco)
Severity: -- → S3
Priority: -- → P3
Whiteboard: [addons-jira]

Not sure if this helps with detail / replication, but there's a few related issues to this on the mozilla github pages. Obviously delete this if all of this is stored in some secret place that I don't know of. :)

Here's the main one (I think):
https://github.com/mozilla/multi-account-containers/issues/1719

Here's my one:
https://github.com/mozilla/multi-account-containers/issues/2453

And here's another:
https://github.com/mozilla/multi-account-containers/issues/2037

Luca, is this ready to land?

Flags: needinfo?(lgreco)

(In reply to :Gijs (he/him) from comment #7)

Luca, is this ready to land?

Yes, thanks for the reminder, I deferred landing it to get it in m-c at the start of the cycle and let it have a bit of baking time.

I'm going to push it to autoland in a few minutes

Flags: needinfo?(lgreco)
Pushed by luca.greco@alcacoop.it: https://hg.mozilla.org/integration/autoland/rev/9db0b49bb116 Ensure userContextId is set in the session store tab state for tabs created as discarded. r=Gijs,willdurand
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 113 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: