Bug 1422211 - Do not try to move a tab when it is the only tab in a window, r?mixedpuppy
The problem reported in this bug is that the newTab button moves to an invalid position when
there's only 1 tab in a window and you try to move it to the end of the tab strip via tabs.move.
This may be caused by a bug in tabbrowser, which is being investigated separately, but it
brought to light the fact that we're trying to move a tab when it's the only tab in a
window, and that just doesn't make sense.
This patch updates the code so we don't try to move a tab if it's the only tab in the
window.
MozReview-Commit-ID: 1oBs0OHnvxi
--- a/browser/components/extensions/ext-tabs.js
+++ b/browser/components/extensions/ext-tabs.js
@@ -612,16 +612,22 @@ this.tabs = class extends ExtensionAPI {
let lastInsertion = new Map();
let tabs = tabIds.map(tabId => tabTracker.getTab(tabId));
for (let nativeTab of tabs) {
// If the window is not specified, use the window from the tab.
let window = destinationWindow || nativeTab.ownerGlobal;
let gBrowser = window.gBrowser;
+ // If we are not moving the tab to a different window, and the window
+ // only has one tab, do nothing.
+ if (nativeTab.ownerGlobal == window && gBrowser.tabs.length === 1) {
+ continue;
+ }
+
let insertionPoint = indexMap.get(window) || moveProperties.index;
// If the index is -1 it should go to the end of the tabs.
if (insertionPoint == -1) {
insertionPoint = gBrowser.tabs.length;
}
// We can only move pinned tabs to a point within, or just after,
// the current set of pinned tabs. Unpinned tabs, likewise, can only