browser.sessions.setTabValue extension data lost when tab is adopted in another window
Categories
(WebExtensions :: General, defect)
Tracking
(firefox148 fixed)
| Tracking | Status | |
|---|---|---|
| firefox148 | --- | fixed |
People
(Reporter: thibautguenedal, Assigned: robwu)
References
Details
(Whiteboard: [addons-jira])
Attachments
(1 file)
Steps to reproduce:
- Store extension data on a tab using
browser.sessions.setTabValue() - Move the tab to a different window
- Check data using
browser.sessions.getTabValue()
// permissions: ["tabs", "windows", "sessions"]
tab = await browser.tabs.create({ url: 'https://example.com' })
await browser.sessions.setTabValue(tab.id, 'key', 'value')
console.log('key', await browser.sessions.getTabValue(tab.id, 'key'))
await browser.windows.create({ tabId: tab.id })
console.log('key', await browser.sessions.getTabValue(tab.id, 'key'))
Actual results:
All extension data (tab values) is lost after moving the tab to a new window. I confirmed this by inspecting sessionstore.json > tab.extData before and after the move.
Expected results:
This data persists on a tab through reload, navigation, moving, grouping, pinning, closing and reopening, restarting the browser, etc. so I don't understand why it gets destroyed when moving between windows.
Comment 1•2 months ago
|
||
The Bugbug bot thinks this bug should belong to the 'WebExtensions::Untriaged' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
I can confirm this issue.
Using a minimal MV2 extension, tab session data set with browser.sessions.setTabValue() is lost after detaching the tab to a new window.
Tested on Firefox 142.0.2, macOS Sequoia 15.7.1.
Comment 3•1 month ago
|
||
The severity field is not set for this bug.
:robwu, could you have a look please?
For more information, please visit BugBot documentation.
| Assignee | ||
Comment 4•1 month ago
|
||
The logic for assigning the custom state is at https://searchfox.org/firefox-main/rev/04cf27582307a9c351e991c740828d54cf786b76/browser/components/sessionstore/SessionStore.sys.mjs#4925-4938
The issue happens because adopting a tab in Firefox is implemented as creating a new tab in the new window based on the original tab, and then swapping the <browser> that holds the tab's content. Extensions do not notice the difference because we do some bookkeeping to preserve the tabId after tab adoption, in tabTracker's adopt handler (called on TabOpen/TabClose).
I believe that the issue will be resolved if we copy over the state when a tab is adopted in a new window, e.g. in SessionStore.sys.mjs's TabClose handler when adoptedBy is set, or in the callee (SessionStoreInternal.onMoveToNewWindow, provided that the caller passes the tab instead of the <browser>).
Thibaut, are you interested in contributing a patch to Firefox to fix this issue? If you are, there is a quick guide to getting started at https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html
Comment 5•1 month ago
|
||
The severity field is not set for this bug.
:willdurand, could you have a look please?
For more information, please visit BugBot documentation.
| Assignee | ||
Updated•1 month ago
|
Updated•1 month ago
|
| Assignee | ||
Comment 6•1 month ago
|
||
Verified FIXED.
On Firefox 148 (macOS), extension data set via browser.sessions.setTabValue() is preserved after tab adoption into a new window using browser.windows.create({ tabId }).
sessions.getTabValue() returns the expected value both before and after adoption.
Description
•