Open Bug 1687656 Opened 4 years ago

Selected tab may not be part of a multiselection

Categories

(Firefox :: Tabbed Browser, defect)

defect

Tracking

()

People

(Reporter: Oriol, Unassigned)

Details

Make sure you have 3 tabs and run this code in the browser console:

var [tab1, tab2, tab3] = gBrowser.tabs;
gBrowser.selectedTabs = [tab1, tab2];
gBrowser.lockClearMultiSelectionOnce();
gBrowser.selectedTab = tab3;
console.assert(tab1.multiselected === true, 'tab1');
console.assert(tab2.multiselected === true, 'tab2');
console.assert(tab3.multiselected === true, 'tab3'); // fails

tab3 is the selected tab, and there is a multiselection since tab1 and tab2 are multiselected. Then, the selected tab should be part of the multiselection, but it isn't!

The bug can be triggered without the console, just by using the UI:

  1. Open a window with 4 tabs
  2. Select the 4th tab, and multiselect the 1st and 2nd ones
  3. Right-click the 3rd tab (not selected nor multiselected) and choose "Close Multiple Tabs > Close Tabs to the Right".
  4. That closes the 4th tab, which was selected, so the 3rd one becomes selected.
  5. Now we still have a multiselection, but gBrowser.selectedTab.multiselected === false

In practice this doesn't seem a big deal since gBrowser.selectedTabs makes sure to include the selected tab. But having a wrong multiselected might break webextensions. And it creates inconsistencies, e.g. if you try to follow the steps above but with just 3 tabs

  1. Open a window with 3 tabs
  2. Select the 3rd tab, and multiselect the 1st one
  3. Right-click the 2nd tab (not selected nor multiselected) and choose "Close Multiple Tabs > Close Tabs to the Right".
  4. That closes the 3rd tab, which was selected, so the 2nd one becomes selected.

This time the 1st tab stops being multiselected! That's because, since it was the only multiselected tab, the multiselection is cleared.

Actually there is the test browser_multiselect_tabs_close_other_tabs.js which expects the multiselection to be cleared, even if it's due to a bug. So maybe the test is wrong, or maybe the multiselection shouldn't be locked when removing tabs.

You need to log in before you can comment on or make changes to this bug.