Closed
Bug 1400456
Opened 8 years ago
Closed 3 years ago
browser.tabs.move() has unexpected behavior when moving multiple tabs between windows
Categories
(WebExtensions :: General, enhancement, P5)
WebExtensions
General
Tracking
(Not tracked)
RESOLVED
DUPLICATE
of bug 1809364
People
(Reporter: u462496, Unassigned)
Details
When moving tabs between windows:
If the _tPos's of the tabs to be moved are lesser than the index being moved to in the other window, the tabs appear in reverse order of how they appeared in the original window - expected behavior (I think).
If the _tPos's of the tabs to be moved are greater than the index being moved to in the other window, the tabs appear in the same of how they appeared in the original window - not expected behavior (I think).
If some _tPos's are greater and some lesser, some of the tabs appear the same, some reversed from how they appeared in the original window.
Reference:
http://searchfox.org/mozilla-central/source/browser/components/extensions/ext-tabs.js#599-604
I am wondering that when moving tabs to another window, what the _tPos of the tabs in the original window has to do with the new window move? It seems we should be ignoring the original _tPos's in that case.
Naively, ignoring tabs moved from another window in the referenced code seems to work:
if (nativeTab.ownerGlobal == window &&
lastInsertion.has(window) &&
lastInsertion.get(window) === insertionPoint &&
nativeTab._tPos > insertionPoint) {
insertionPoint++;
indexMap.set(window, insertionPoint);
}
I think I stated the expected behavior in the reverse. From the documentation, the expected behavior would be:
"If you include [windowId], and tabIds contains more than one tab, then the first tab in tabIds will be moved to index, and the other tabs will follow it in the order given in tabIds". I take this to mean that the moved tabs will appear in the tabs bar in the order of tabIds, which certainly seems intuitive to me.
In that case, incrementation of insertionPoint should actually occur every time for tabs moved from another window, in which case this code seems to work:
if ((nativeTab.ownerGlobal != window) ||
lastInsertion.has(window) &&
lastInsertion.get(window) === insertionPoint &&
nativeTab._tPos > insertionPoint)) {
insertionPoint++;
indexMap.set(window, insertionPoint);
}
Andy, do you care to comment on this?
In any case, again, _tPos's of tabs moved from another window should be irrelevant, since that relationship only has to do with the fact that when moving tabs within the same window, each tab moved from before the insertion point affects the _tPos of all tabs preceding the insertion point.
Flags: needinfo?(amckay)
Comment 2•8 years ago
|
||
Ah right, good call. That makes sense to me.
Updated•7 years ago
|
Product: Toolkit → WebExtensions
Comment 3•7 years ago
|
||
Bulk move of bugs per https://bugzilla.mozilla.org/show_bug.cgi?id=1483958
status-firefox57:
fix-optional → ---
Component: Untriaged → General
Updated•3 years ago
|
Severity: normal → S3
Comment 4•3 years ago
|
||
This seems the same as what I fixed in bug 1809364.
You need to log in
before you can comment on or make changes to this bug.
Description
•