tabs.create() fails when it is called with "openerTabId" for a discarded tab
Categories
(WebExtensions :: Compatibility, defect, P3)
Tracking
(firefox148 fixed)
| Tracking | Status | |
|---|---|---|
| firefox148 | --- | fixed |
People
(Reporter: yuki, Assigned: yuki)
Details
Attachments
(2 files)
browser.tabs.create() throws an error unexpectedly when openerTabId is an ID of a discarded tab.
Original report: https://github.com/piroor/treestyletab/issues/3099
Steps to reproduce
- Open two or more tabs.
- Discard one of tabs.
- Call
browser.tabs.create({ openerTabId: <the ID of a discarded tab> }).
Expected result
A new tab is opened successfully.
Actual result
No tab is created. If you catch errors of the API call, you get an error with a message "Error: An unexpected error occurred".
Environment
- Windows 10 21H2
- Nightly 100.0a1 build ID: 20220329204247
- Firefox 98.0.2 build ID: 20220322144853
| Assignee | ||
Comment 1•4 years ago
|
||
Here is a testcase addon. You can confirm that the result is different between Firefox and Google Chrome.
On Firefox:
- Go to
about:debugging. - Click "This Firefox" (or "This Nightly").
- Click "Load Temporary Add-on...".
- Choose the testcase XPI.
- Expected result:
- Two tabs
https://example.com/?parentandhttps://example.com/?childare opened.
- Two tabs
- Actual result:
- Only one tab
https://example.com/?parentis opened. - If you open the debugger for the testcase addon, an error "Error: An unexpected error occurred" is reported.
- Only one tab
- Expected result:
On Google Chrome (I've used Chrome 99.0.4844.84):
- Go to
chrome://extensions/. - Activate developer mode.
- Click "Load unpacked extension".
- Choose the directory extracted the testcase XPI.
- Result:
- Two tabs
https://example.com/?parentandhttps://example.com/?childare opened.
- Two tabs
- Result:
| Assignee | ||
Comment 2•4 years ago
|
||
Firefox gets tracked tabs based on the given openerTabId with:
https://searchfox.org/mozilla-central/rev/766773ca7e3495a3f1ba365f47dffefdea29e3ee/browser/components/extensions/parent/ext-tabs.js#732
https://searchfox.org/mozilla-central/rev/766773ca7e3495a3f1ba365f47dffefdea29e3ee/browser/components/extensions/parent/ext-tabs.js#898
Something further operation looks to raise the "Error: An unexpected error occurred" error, but I've not found which code does that yet.
| Assignee | ||
Comment 3•4 years ago
|
||
I've got that the error comes from https://searchfox.org/mozilla-central/rev/625c3d0c8ae46502aed83f33bd530cb93e926e9f/browser/base/content/tabbrowser.js#2837 , the raw error is: CanonicalBrowsingContext.setCrossGroupOpener: Argument 1 is not an object.
| Assignee | ||
Comment 4•4 years ago
|
||
Just skipping CanonicalBrowsingContext.setCrossGroupOpener() for null openerBrowser.browsingContext looks reasonable for me, because the only one code using the returned value of GetCrossGroupOpenerId() looks to be here and the function is designed to do nothing when the opener tab is already discarded. Is it a correct approach?
Comment 5•4 years ago
|
||
Skipping that call if the opener browser is not available seems very reasonable, yes.
| Assignee | ||
Comment 6•4 years ago
|
||
Updated•4 years ago
|
| Assignee | ||
Comment 7•4 years ago
|
||
Thanks!
Updated•4 years ago
|
| Assignee | ||
Comment 8•4 months ago
|
||
I apologize my long silence about the patch. I've rewrite it based on the latest mozilla-central, with fixes commented by the reviewer.
Comment 9•4 months ago
|
||
Thanks for the patch, Piro!
I just wanted to note that this bug seems to cause a data loss issue with Tab Session Manager, when used with Tree Style Tab / Sidebery support. When restoring a session, in some conditions a tab will fail to open, without user notification, causing subtle corruption of the session:
I tried the above testcase xpi with Developer Edition 147, and the console error message is the same as with Tab Session Manager:
DOMException: CanonicalBrowsingContext.crossGroupOpener setter: Can't set crossGroupOpener to null
| Assignee | ||
Comment 10•4 months ago
|
||
The patch has been reviewed and accepted. I have no authority so could anyone check-in it?
Comment 11•4 months ago
|
||
Comment 12•4 months ago
|
||
| bugherder | ||
Description
•