Respect the tabs.move/tabs.create API

According to MDN[1], when you create a tab that should be placed at the
end of a window, you should use the number of tabs of the window as
index.
But if you use tabs.move(), you should use an index value of -1[2].

Probably fixes https://github.com/tridactyl/tridactyl/issues/990 .

1: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/create#Parameters
2: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/move#Parameters
This commit is contained in:
glacambre 2018-09-10 07:05:47 +02:00
parent da0604f344
commit a7ddcb1b5a
No known key found for this signature in database
GPG key ID: B9625DB1767553AC
2 changed files with 2 additions and 2 deletions

View file

@ -338,7 +338,7 @@ export async function nativeopen(url: string, ...firefoxArgs: string[]) {
let index = (await activeTab()).index + 1
switch (pos) {
case "last":
index = 99999
index = -1
break
case "related":
// How do we simulate that?

View file

@ -114,7 +114,7 @@ export async function openInNewTab(
break
case "last":
// Infinity can't be serialised, apparently.
options.index = 99999
options.index = (await browserBg.tabs.query({currentWindow: true})).length
break
case "related":
if (await firefoxVersionAtLeast(57)) {