Closed
Bug 1766159
Opened 4 years ago
Closed 3 years ago
tabs.move() to another window unexpected order
Categories
(WebExtensions :: General, defect, P5)
WebExtensions
General
Tracking
(Not tracked)
RESOLVED
DUPLICATE
of bug 1809364
People
(Reporter: erosman, Unassigned)
References
Details
tabs.move()
If you include this, 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.
While moving pinned tabs, from one window to another, the order of original ids gets reversed. 3, 2 ,1
I tried reversing them beforehand, but then the order got mixed up. 3, 1, 2
Strange thing is that it is always the same... 3, 2, 1 or in reverse to 3, 1, 2
STR
- Open 2 windows
- Create some pinned tabs in one (or both doesn't matter)
- In the other window, open an Extension Toolbox from any extension that has "tabs" permission
- Run the following code
(async() => {
const {id} = await browser.windows.getCurrent({});
let tabs = await browser.tabs.query({currentWindow: false, pinned: true});
console.log(tabs);
console.log(tabs.map(tab => tab.index + ': ' + tab.id)); // Array(3) [ "0: 96", "1: 97", "2: 98" ]
const moved = await browser.tabs.move(tabs.map(tab => tab.id), {windowId: id, index: 0});
console.log(moved);
/*
0: Object { id: 96, index: 2, windowId: 644, … }
1: Object { id: 97, index: 1, windowId: 644, … }
2: Object { id: 98, index: 0, windowId: 644, … }
*/
tabs = await browser.tabs.query({currentWindow: true, pinned: true});
console.log(tabs.map(tab => tab.index + ': ' + tab.id)); // Array(3) [ "0: 98", "1: 97", "2: 96" ]
})();
with reverse()
(async() => {
const {id} = await browser.windows.getCurrent({});
let tabs = await browser.tabs.query({currentWindow: false, pinned: true});
console.log(tabs);
console.log(tabs.map(tab => tab.index + ': ' + tab.id).reverse()); // Array(3) [ "2: 102", "1: 100", "0: 94" ]
const moved = await browser.tabs.move(tabs.map(tab => tab.id).reverse(), {windowId: id, index: 0});
console.log(moved);
/*
0: Object { id: 102, index: 0, windowId: 644, … }
1: Object { id: 100, index: 2, windowId: 644, … }
2: Object { id: 94, index: 1, windowId: 644, … }
*/
tabs = await browser.tabs.query({currentWindow: true, pinned: true}); // Array(3) [ "0: 102", "1: 94", "2: 100" ]
console.log(tabs.map(tab => tab.index + ': ' + tab.id));
})();
Expectation
Order of the tabs to be maintained
Note
Tested on: Nightly 101.0a1 (2022-04-23) (64-bit)
Updated•4 years ago
|
Severity: -- → S4
Priority: -- → P5
| Reporter | ||
Comment 1•4 years ago
|
||
Here is a workaround, but it is not optimal.
(async() => {
const {id} = await browser.windows.getCurrent({});
let tabs = await browser.tabs.query({currentWindow: false, pinned: true});
console.log(tabs);
console.log(tabs.map(tab => tab.id + ': ' + tab.index)); // Array(4) [ "58: 0", "60: 1", "61: 2", "59: 3" ]
tabs = [tabs.shift(), ...tabs.reverse()];
console.log(tabs.map(tab => tab.id + ': ' + tab.index)); // Array(4) [ "58: 0", "59: 3", "61: 2", "60: 1" ]
let moved = await browser.tabs.move(tabs.map(tab => tab.id), {windowId: id, index: 0});
console.log(moved);
/*
0: Object { id: 58, index: 0, windowId: 374, … }
1: Object { id: 59, index: 3, windowId: 374, … }
2: Object { id: 61, index: 2, windowId: 374, … }
3: Object { id: 60, index: 1, windowId: 374, … }
*/
tabs = await browser.tabs.query({currentWindow: true, pinned: true});
console.log(tabs.map(tab => tab.id + ': ' + tab.index)); Array(4) [ "58: 0", "60: 1", "61: 2", "59: 3" ]
})();
Comment 2•3 years ago
|
||
Should be fixed by bug 1809364.
You need to log in
before you can comment on or make changes to this bug.
Description
•