Bug 1966912 - Remove addTab's index alias for the tabIndex parameter. r=extension-reviewers,sessionstore-reviewers,tabbrowser-reviewers,robwu,dwalker

Differential Revision: https://phabricator.services.mozilla.com/D249783
This commit is contained in:
Dão Gottwald
2025-05-20 12:00:23 +00:00
committed by dgottwald@mozilla.com
parent 85f2a1b376
commit e0a00e5f7d
8 changed files with 26 additions and 31 deletions

View File

@@ -812,12 +812,12 @@ this.tabs = class extends ExtensionAPIPersistent {
}
}
// Simple properties
const properties = ["index", "pinned"];
for (let prop of properties) {
if (createProperties[prop] != null) {
options[prop] = createProperties[prop];
}
if (createProperties.index != null) {
options.tabIndex = createProperties.index;
}
if (createProperties.pinned != null) {
options.pinned = createProperties.pinned;
}
let active =
@@ -1209,7 +1209,7 @@ this.tabs = class extends ExtensionAPIPersistent {
},
duplicate(tabId, duplicateProperties) {
const { active, index } = duplicateProperties || {};
const { active, index: tabIndex } = duplicateProperties || {};
const inBackground = active === undefined ? false : !active;
// Schema requires tab id.
@@ -1218,7 +1218,7 @@ this.tabs = class extends ExtensionAPIPersistent {
let gBrowser = nativeTab.ownerGlobal.gBrowser;
let newTab = gBrowser.duplicateTab(nativeTab, true, {
inBackground,
index,
tabIndex,
});
tabListener.blockTabUntilRestored(newTab);

View File

@@ -3937,7 +3937,7 @@ var SessionStoreInternal = {
aTab,
aDelta = 0,
aRestoreImmediately = true,
{ inBackground, index } = {}
{ inBackground, tabIndex } = {}
) {
if (!aTab || !aTab.ownerGlobal) {
throw Components.Exception("Need a valid tab", Cr.NS_ERROR_INVALID_ARG);
@@ -3960,7 +3960,7 @@ var SessionStoreInternal = {
let tabOptions = {
userContextId,
index,
tabIndex,
...(aTab == aWindow.gBrowser.selectedTab
? { relatedToCurrent: true, ownerTab: aTab }
: {}),
@@ -4446,7 +4446,7 @@ var SessionStoreInternal = {
let tabbrowser = aTargetWindow.gBrowser;
let tab = (tabbrowser.selectedTab = tabbrowser.addTrustedTab(null, {
// Append the tab if we're opening into a different window,
index: aSource == aTargetWindow ? pos : Infinity,
tabIndex: aSource == aTargetWindow ? pos : Infinity,
pinned: state.pinned,
userContextId: state.userContextId,
skipLoad: true,

View File

@@ -1937,7 +1937,7 @@
tabGroup,
};
if (newIndex > -1) {
params.index = newIndex;
params.tabIndex = newIndex;
}
firstTabAdded = this.addTab(aURIs[0], params);
if (newIndex > -1) {
@@ -1960,7 +1960,7 @@
tabGroup,
};
if (targetTabIndex > -1) {
params.index = ++tabNum;
params.tabIndex = ++tabNum;
}
this.addTab(aURIs[i], params);
}
@@ -2597,7 +2597,7 @@
{
wrappedJSObject: new Promise(resolve => {
this.selectedTab = this.addTrustedTab(BROWSER_NEW_TAB_URL, {
index: tab._tPos + 1,
tabIndex: tab._tPos + 1,
userContextId: tab.userContextId,
tabGroup: tab.group,
focusUrlBar: true,
@@ -2652,7 +2652,6 @@
inBackground = true,
elementIndex,
tabIndex,
index,
lazyTabTitle,
name,
noInitialLabel,
@@ -2755,10 +2754,6 @@
});
if (insertTab) {
// Insert the tab into the tab container in the correct position.
// For now, we support `index` as an alias for `tabIndex`.
if (typeof index == "number") {
tabIndex = index;
}
this.#insertTabAtIndex(t, {
elementIndex,
tabIndex,
@@ -9259,7 +9254,7 @@ var TabContextMenu = {
let newTab = gBrowser.addTab(tab.linkedBrowser.currentURI.spec, {
userContextId,
pinned: tab.pinned,
index: tab._tPos + 1,
tabIndex: tab._tPos + 1,
triggeringPrincipal,
});

View File

@@ -2,7 +2,7 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
function test() {
let tab = gBrowser.addTrustedTab("about:blank", { index: 10 });
let tab = gBrowser.addTrustedTab("about:blank", { tabIndex: 10 });
is(tab._tPos, 1, "added tab index should be 1");
gBrowser.removeTab(tab);
}

View File

@@ -2303,7 +2303,7 @@ add_task(async function test_bug1957723_addTabsByIndex() {
});
let tab1 = gBrowser.addTab("https://example.com", {
index: 2,
tabIndex: 2,
triggeringPrincipal,
});
Assert.equal(
@@ -2319,7 +2319,7 @@ add_task(async function test_bug1957723_addTabsByIndex() {
gBrowser.removeTab(tab1);
let tab2 = gBrowser.addTab("https://example.com", {
index: 4,
tabIndex: 4,
triggeringPrincipal,
});
Assert.equal(
@@ -2335,7 +2335,7 @@ add_task(async function test_bug1957723_addTabsByIndex() {
gBrowser.removeTab(tab2);
let tab3 = gBrowser.addTab("https://example.com", {
index: 5,
tabIndex: 5,
triggeringPrincipal,
});
Assert.equal(
@@ -2371,7 +2371,7 @@ add_task(async function test_bug1959438_duplicateTabJustBeforeGroup() {
// If this happens next to a tab group, the resulting element index will
// point to the tab group label.
gBrowser.addTab("https://example.com", {
index: undefined,
tabIndex: undefined,
relatedToCurrent: true,
ownerTab: gBrowser.selectedTab,
triggeringPrincipal,

View File

@@ -775,7 +775,7 @@ add_task(async function test_tabInteractions() {
"Test that duplicating a tab within a group calls tab_interactions.duplicate"
);
await assertMetricEmpty("duplicate");
win.gBrowser.duplicateTab(group.tabs[0], true, { index: 2 });
win.gBrowser.duplicateTab(group.tabs[0], true, { tabIndex: 2 });
await assertOneMetricFoundFor("duplicate");
info(

View File

@@ -173,7 +173,7 @@ class TabManagerClass {
window = Services.wm.getMostRecentWindow(null),
} = options;
let index;
let tabIndex;
if (referenceTab != null) {
// If a reference tab was specified, the window should be the window
// owning the reference tab.
@@ -181,13 +181,13 @@ class TabManagerClass {
}
if (referenceTab != null) {
index = this.getTabsForWindow(window).indexOf(referenceTab) + 1;
tabIndex = this.getTabsForWindow(window).indexOf(referenceTab) + 1;
}
const tabBrowser = this.getTabBrowser(window);
const tab = await tabBrowser.addTab("about:blank", {
index,
tabIndex,
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
userContextId: lazy.UserContextManager.getInternalIdById(userContextId),
});

View File

@@ -1957,7 +1957,7 @@ export var BrowserTestUtils = {
let overflowDirection = gBrowser.tabContainer.verticalMode
? "height"
: "width";
let index = params.overflowAtStart ? 0 : undefined;
let tabIndex = params.overflowAtStart ? 0 : undefined;
let arrowScrollbox = gBrowser.tabContainer.arrowScrollbox;
if (arrowScrollbox.hasAttribute("overflowing")) {
return;
@@ -1990,7 +1990,7 @@ export var BrowserTestUtils = {
promises.push(
BrowserTestUtils.addTab(gBrowser, "about:blank", {
skipAnimation: true,
index,
tabIndex,
})
);
}