Bug 1422211 - Do not try to move a tab when it is the only tab in a window, r=mixedpuppy
authorBob Silverberg <bsilverberg@mozilla.com>
Fri, 01 Dec 2017 09:03:44 -0500
changeset 394952 4a160faf5ac5f9b3561e945344e8db501b74ad45
parent 394951 0cb270dda57624ae29346c6da60292280589f728
child 394953 151826976a7d1cc0773017bdbd1eaa8554fc247e
push id97987
push usernerli@mozilla.com
push dateTue, 05 Dec 2017 13:52:50 +0000
treeherdermozilla-inbound@8842dba7396b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1422211
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
browser/components/extensions/ext-tabs.js
--- 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