test: Added more tests for glance, b=(no-bug), c=tests, scripts, tabs, glance, workspaces

This commit is contained in:
Mr. M 2025-05-22 16:57:27 +02:00
parent ad124c9d95
commit addc318f29
No known key found for this signature in database
GPG key ID: 6292C4C8F8652B18
11 changed files with 197 additions and 273 deletions

View file

@ -24,7 +24,8 @@
"prepare": "husky", "prepare": "husky",
"reset-ff": "surfer reset", "reset-ff": "surfer reset",
"surfer": "surfer", "surfer": "surfer",
"test": "python3 scripts/run_tests.py" "test": "python3 scripts/run_tests.py",
"test:dbg": "python3 scripts/run_tests.py --jsdebugger --debug-on-failure"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View file

@ -5,7 +5,7 @@ from pathlib import Path
def main(): def main():
project_root = Path(__file__).resolve().parent project_root = Path(__file__).resolve().parent.parent
package_json = project_root / 'package.json' package_json = project_root / 'package.json'
# Ensure script is run from project root # Ensure script is run from project root
@ -14,10 +14,11 @@ def main():
sys.exit(1) sys.exit(1)
args = sys.argv[1:] args = sys.argv[1:]
if not args:
path = "" path = ""
else: for arg in args:
path = args[0] if not arg.startswith("--"):
path = arg
break
# Collect any additional arguments # Collect any additional arguments
other_args = [arg for arg in args if arg != path] other_args = [arg for arg in args if arg != path]

View file

@ -1,15 +1,11 @@
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247ecdebcfc 100644 index d5aa64842a35c6697263c63fd3a0571b64b01344..bcae8a44593d7b3e5efdd999b4c2f5bcac221632 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js --- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js +++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -413,11 +413,45 @@ @@ -413,11 +413,41 @@
return this.tabContainer.visibleTabs; return this.tabContainer.visibleTabs;
} }
+ zenInsertTabAtIndex(...args) {
+ return this.#insertTabAtIndex(...args);
+ }
+
+ get _numVisiblePinTabsWithoutCollapsed() { + get _numVisiblePinTabsWithoutCollapsed() {
+ let i = 0; + let i = 0;
+ for (let item of this.tabContainer.ariaFocusableItems) { + for (let item of this.tabContainer.ariaFocusableItems) {
@ -50,7 +46,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
} }
return i; return i;
} }
@@ -569,6 +603,7 @@ @@ -569,6 +599,7 @@
this.tabpanels.appendChild(panel); this.tabpanels.appendChild(panel);
let tab = this.tabs[0]; let tab = this.tabs[0];
@ -58,7 +54,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
tab.linkedPanel = uniqueId; tab.linkedPanel = uniqueId;
this._selectedTab = tab; this._selectedTab = tab;
this._selectedBrowser = browser; this._selectedBrowser = browser;
@@ -834,11 +869,13 @@ @@ -834,11 +865,13 @@
} }
this.showTab(aTab); this.showTab(aTab);
@ -75,7 +71,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
this.moveTabTo(aTab, { this.moveTabTo(aTab, {
tabIndex: this.pinnedTabCount, tabIndex: this.pinnedTabCount,
forceUngrouped: true, forceUngrouped: true,
@@ -855,12 +892,15 @@ @@ -855,12 +888,15 @@
} }
if (this.tabContainer.verticalMode) { if (this.tabContainer.verticalMode) {
@ -92,7 +88,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
}); });
} else { } else {
this.moveTabTo(aTab, { this.moveTabTo(aTab, {
@@ -1044,6 +1084,8 @@ @@ -1044,6 +1080,8 @@
let LOCAL_PROTOCOLS = ["chrome:", "about:", "resource:", "data:"]; let LOCAL_PROTOCOLS = ["chrome:", "about:", "resource:", "data:"];
@ -101,7 +97,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
if ( if (
aIconURL && aIconURL &&
!aLoadingPrincipal && !aLoadingPrincipal &&
@@ -1054,6 +1096,9 @@ @@ -1054,6 +1092,9 @@
); );
return; return;
} }
@ -111,7 +107,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
let browser = this.getBrowserForTab(aTab); let browser = this.getBrowserForTab(aTab);
browser.mIconURL = aIconURL; browser.mIconURL = aIconURL;
@@ -1303,6 +1348,7 @@ @@ -1303,6 +1344,7 @@
if (!this._previewMode) { if (!this._previewMode) {
newTab.recordTimeFromUnloadToReload(); newTab.recordTimeFromUnloadToReload();
newTab.updateLastAccessed(); newTab.updateLastAccessed();
@ -119,7 +115,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
oldTab.updateLastAccessed(); oldTab.updateLastAccessed();
// if this is the foreground window, update the last-seen timestamps. // if this is the foreground window, update the last-seen timestamps.
if (this.ownerGlobal == BrowserWindowTracker.getTopWindow()) { if (this.ownerGlobal == BrowserWindowTracker.getTopWindow()) {
@@ -1455,6 +1501,9 @@ @@ -1455,6 +1497,9 @@
} }
let activeEl = document.activeElement; let activeEl = document.activeElement;
@ -129,7 +125,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
// If focus is on the old tab, move it to the new tab. // If focus is on the old tab, move it to the new tab.
if (activeEl == oldTab) { if (activeEl == oldTab) {
newTab.focus(); newTab.focus();
@@ -1778,7 +1827,8 @@ @@ -1778,7 +1823,8 @@
} }
_setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL } = {}) { _setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL } = {}) {
@ -139,7 +135,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
return false; return false;
} }
@@ -1886,7 +1936,7 @@ @@ -1886,7 +1932,7 @@
newIndex = this.selectedTab._tPos + 1; newIndex = this.selectedTab._tPos + 1;
} }
@ -148,7 +144,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
if (this.isTabGroupLabel(targetTab)) { if (this.isTabGroupLabel(targetTab)) {
throw new Error( throw new Error(
"Replacing a tab group label with a tab is not supported" "Replacing a tab group label with a tab is not supported"
@@ -2150,6 +2200,7 @@ @@ -2150,6 +2196,7 @@
uriIsAboutBlank, uriIsAboutBlank,
userContextId, userContextId,
skipLoad, skipLoad,
@ -156,7 +152,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
} = {}) { } = {}) {
let b = document.createXULElement("browser"); let b = document.createXULElement("browser");
// Use the JSM global to create the permanentKey, so that if the // Use the JSM global to create the permanentKey, so that if the
@@ -2223,8 +2274,7 @@ @@ -2223,8 +2270,7 @@
// we use a different attribute name for this? // we use a different attribute name for this?
b.setAttribute("name", name); b.setAttribute("name", name);
} }
@ -166,7 +162,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
b.setAttribute("transparent", "true"); b.setAttribute("transparent", "true");
} }
@@ -2389,7 +2439,7 @@ @@ -2389,7 +2435,7 @@
let panel = this.getPanel(browser); let panel = this.getPanel(browser);
let uniqueId = this._generateUniquePanelID(); let uniqueId = this._generateUniquePanelID();
@ -175,7 +171,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
aTab.linkedPanel = uniqueId; aTab.linkedPanel = uniqueId;
// Inject the <browser> into the DOM if necessary. // Inject the <browser> into the DOM if necessary.
@@ -2448,8 +2498,8 @@ @@ -2448,8 +2494,8 @@
// If we transitioned from one browser to two browsers, we need to set // If we transitioned from one browser to two browsers, we need to set
// hasSiblings=false on both the existing browser and the new browser. // hasSiblings=false on both the existing browser and the new browser.
if (this.tabs.length == 2) { if (this.tabs.length == 2) {
@ -186,7 +182,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
} else { } else {
aTab.linkedBrowser.browsingContext.hasSiblings = this.tabs.length > 1; aTab.linkedBrowser.browsingContext.hasSiblings = this.tabs.length > 1;
} }
@@ -2680,6 +2730,7 @@ @@ -2680,6 +2726,7 @@
schemelessInput, schemelessInput,
hasValidUserGestureActivation = false, hasValidUserGestureActivation = false,
textDirectiveUserActivation = false, textDirectiveUserActivation = false,
@ -194,7 +190,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
} = {} } = {}
) { ) {
// all callers of addTab that pass a params object need to pass // all callers of addTab that pass a params object need to pass
@@ -2690,6 +2741,12 @@ @@ -2690,6 +2737,12 @@
); );
} }
@ -207,7 +203,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
if (!UserInteraction.running("browser.tabs.opening", window)) { if (!UserInteraction.running("browser.tabs.opening", window)) {
UserInteraction.start("browser.tabs.opening", "initting", window); UserInteraction.start("browser.tabs.opening", "initting", window);
} }
@@ -2753,6 +2810,16 @@ @@ -2753,6 +2806,16 @@
noInitialLabel, noInitialLabel,
skipBackgroundNotify, skipBackgroundNotify,
}); });
@ -224,7 +220,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
if (insertTab) { if (insertTab) {
// Insert the tab into the tab container in the correct position. // Insert the tab into the tab container in the correct position.
// For now, we support `index` as an alias for `tabIndex`. // For now, we support `index` as an alias for `tabIndex`.
@@ -2783,6 +2850,7 @@ @@ -2783,6 +2846,7 @@
openWindowInfo, openWindowInfo,
skipLoad, skipLoad,
triggeringRemoteType, triggeringRemoteType,
@ -232,7 +228,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
})); }));
if (focusUrlBar) { if (focusUrlBar) {
@@ -2902,6 +2970,12 @@ @@ -2902,6 +2966,12 @@
} }
} }
@ -245,7 +241,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
// Additionally send pinned tab events // Additionally send pinned tab events
if (pinned) { if (pinned) {
this._notifyPinnedStatus(t); this._notifyPinnedStatus(t);
@@ -2990,10 +3064,10 @@ @@ -2990,10 +3060,10 @@
isAdoptingGroup = false, isAdoptingGroup = false,
isUserTriggered = false, isUserTriggered = false,
telemetryUserCreateSource = "unknown", telemetryUserCreateSource = "unknown",
@ -257,7 +253,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
} }
if (!color) { if (!color) {
@@ -3014,7 +3088,12 @@ @@ -3014,7 +3084,12 @@
label, label,
isAdoptingGroup isAdoptingGroup
); );
@ -271,7 +267,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
group, group,
insertBefore?.group ?? insertBefore insertBefore?.group ?? insertBefore
); );
@@ -3303,6 +3382,7 @@ @@ -3303,6 +3378,7 @@
openWindowInfo, openWindowInfo,
skipLoad, skipLoad,
triggeringRemoteType, triggeringRemoteType,
@ -279,7 +275,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
} }
) { ) {
// If we don't have a preferred remote type (or it is `NOT_REMOTE`), and // If we don't have a preferred remote type (or it is `NOT_REMOTE`), and
@@ -3372,6 +3452,7 @@ @@ -3372,6 +3448,7 @@
openWindowInfo, openWindowInfo,
name, name,
skipLoad, skipLoad,
@ -287,7 +283,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
}); });
} }
@@ -3560,7 +3641,7 @@ @@ -3560,7 +3637,7 @@
// Add a new tab if needed. // Add a new tab if needed.
if (!tab) { if (!tab) {
let createLazyBrowser = let createLazyBrowser =
@ -296,7 +292,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
let url = "about:blank"; let url = "about:blank";
if (tabData.entries?.length) { if (tabData.entries?.length) {
@@ -3598,7 +3679,29 @@ @@ -3598,7 +3675,29 @@
skipLoad: true, skipLoad: true,
preferredRemoteType, preferredRemoteType,
}); });
@ -326,7 +322,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
if (select) { if (select) {
tabToSelect = tab; tabToSelect = tab;
} }
@@ -3622,7 +3725,8 @@ @@ -3622,7 +3721,8 @@
// needs calling: // needs calling:
shouldUpdateForPinnedTabs = true; shouldUpdateForPinnedTabs = true;
} }
@ -336,7 +332,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
let { groupId } = tabData; let { groupId } = tabData;
const tabGroup = tabGroupWorkingData.get(groupId); const tabGroup = tabGroupWorkingData.get(groupId);
// if a tab refers to a tab group we don't know, skip any group // if a tab refers to a tab group we don't know, skip any group
@@ -3636,7 +3740,10 @@ @@ -3636,7 +3736,10 @@
tabGroup.stateData.id, tabGroup.stateData.id,
tabGroup.stateData.color, tabGroup.stateData.color,
tabGroup.stateData.collapsed, tabGroup.stateData.collapsed,
@ -348,7 +344,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
); );
tabsFragment.appendChild(tabGroup.node); tabsFragment.appendChild(tabGroup.node);
} }
@@ -3684,8 +3791,16 @@ @@ -3684,8 +3787,16 @@
// to remove the old selected tab. // to remove the old selected tab.
if (tabToSelect) { if (tabToSelect) {
let leftoverTab = this.selectedTab; let leftoverTab = this.selectedTab;
@ -367,7 +363,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
} }
if (tabs.length > 1 || !tabs[0].selected) { if (tabs.length > 1 || !tabs[0].selected) {
@@ -3881,7 +3996,7 @@ @@ -3881,7 +3992,7 @@
// Ensure we have an index if one was not provided. // Ensure we have an index if one was not provided.
if (typeof elementIndex != "number" && typeof tabIndex != "number") { if (typeof elementIndex != "number" && typeof tabIndex != "number") {
// Move the new tab after another tab if needed, to the end otherwise. // Move the new tab after another tab if needed, to the end otherwise.
@ -376,7 +372,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
if ( if (
!bulkOrderedOpen && !bulkOrderedOpen &&
((openerTab && ((openerTab &&
@@ -3904,7 +4019,7 @@ @@ -3904,7 +4015,7 @@
) { ) {
elementIndex = Infinity; elementIndex = Infinity;
} else if (previousTab.visible) { } else if (previousTab.visible) {
@ -385,7 +381,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
} else if (previousTab == FirefoxViewHandler.tab) { } else if (previousTab == FirefoxViewHandler.tab) {
elementIndex = 0; elementIndex = 0;
} }
@@ -3932,14 +4047,14 @@ @@ -3932,10 +4043,10 @@
} }
// Ensure index is within bounds. // Ensure index is within bounds.
if (tab.pinned) { if (tab.pinned) {
@ -399,12 +395,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
index = Math.min(index, allItems.length); index = Math.min(index, allItems.length);
} }
/** @type {MozTabbrowserTab|undefined} */ /** @type {MozTabbrowserTab|undefined} */
- let itemAfter = allItems.at(index); @@ -3947,7 +4058,7 @@
+ let itemAfter = allItems.filter(tab => !tab.hasAttribute("zen-glance-tab")).at(index);
// Prevent a flash of unstyled content by setting up the tab content
// and inherited attributes before appending it (see Bug 1592054):
@@ -3947,7 +4062,7 @@
this.tabContainer._invalidateCachedTabs(); this.tabContainer._invalidateCachedTabs();
@ -413,7 +404,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
if (this.isTab(itemAfter) && itemAfter.group == tabGroup) { if (this.isTab(itemAfter) && itemAfter.group == tabGroup) {
// Place at the front of, or between tabs in, the same tab group // Place at the front of, or between tabs in, the same tab group
this.tabContainer.insertBefore(tab, itemAfter); this.tabContainer.insertBefore(tab, itemAfter);
@@ -4268,6 +4383,9 @@ @@ -4268,6 +4379,9 @@
return; return;
} }
@ -423,7 +414,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
this.removeTabs(selectedTabs, { telemetrySource }); this.removeTabs(selectedTabs, { telemetrySource });
} }
@@ -4520,6 +4638,7 @@ @@ -4520,6 +4634,7 @@
telemetrySource, telemetrySource,
} = {} } = {}
) { ) {
@ -431,7 +422,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
// When 'closeWindowWithLastTab' pref is enabled, closing all tabs // When 'closeWindowWithLastTab' pref is enabled, closing all tabs
// can be considered equivalent to closing the window. // can be considered equivalent to closing the window.
if ( if (
@@ -4604,6 +4723,7 @@ @@ -4604,6 +4719,7 @@
if (lastToClose) { if (lastToClose) {
this.removeTab(lastToClose, aParams); this.removeTab(lastToClose, aParams);
} }
@ -439,7 +430,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
@@ -4641,6 +4761,12 @@ @@ -4641,6 +4757,12 @@
aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start(); aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start();
} }
@ -452,7 +443,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
// Handle requests for synchronously removing an already // Handle requests for synchronously removing an already
// asynchronously closing tab. // asynchronously closing tab.
if (!animate && aTab.closing) { if (!animate && aTab.closing) {
@@ -4655,7 +4781,9 @@ @@ -4655,7 +4777,9 @@
// frame created for it (for example, by updating the visually selected // frame created for it (for example, by updating the visually selected
// state). // state).
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width; let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
@ -463,7 +454,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
if ( if (
!this._beginRemoveTab(aTab, { !this._beginRemoveTab(aTab, {
closeWindowFastpath: true, closeWindowFastpath: true,
@@ -4821,7 +4949,7 @@ @@ -4821,7 +4945,7 @@
closeWindowWithLastTab != null closeWindowWithLastTab != null
? closeWindowWithLastTab ? closeWindowWithLastTab
: !window.toolbar.visible || : !window.toolbar.visible ||
@ -472,7 +463,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
if (closeWindow) { if (closeWindow) {
// We've already called beforeunload on all the relevant tabs if we get here, // We've already called beforeunload on all the relevant tabs if we get here,
@@ -4845,6 +4973,7 @@ @@ -4845,6 +4969,7 @@
newTab = true; newTab = true;
} }
@ -480,7 +471,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
aTab._endRemoveArgs = [closeWindow, newTab]; aTab._endRemoveArgs = [closeWindow, newTab];
// swapBrowsersAndCloseOther will take care of closing the window without animation. // swapBrowsersAndCloseOther will take care of closing the window without animation.
@@ -4885,9 +5014,7 @@ @@ -4885,9 +5010,7 @@
aTab._mouseleave(); aTab._mouseleave();
if (newTab) { if (newTab) {
@ -491,7 +482,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
} else { } else {
TabBarVisibility.update(); TabBarVisibility.update();
} }
@@ -5016,6 +5143,8 @@ @@ -5016,6 +5139,8 @@
this.tabs[i]._tPos = i; this.tabs[i]._tPos = i;
} }
@ -500,7 +491,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
if (!this._windowIsClosing) { if (!this._windowIsClosing) {
if (wasPinned) { if (wasPinned) {
this.tabContainer._positionPinnedTabs(); this.tabContainer._positionPinnedTabs();
@@ -5141,8 +5270,8 @@ @@ -5141,8 +5266,8 @@
return closedCount; return closedCount;
} }
@ -511,7 +502,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
if (unloadBlocked) { if (unloadBlocked) {
return; return;
} }
@@ -5230,6 +5359,7 @@ @@ -5230,6 +5355,7 @@
} }
let excludeTabs = new Set(aExcludeTabs); let excludeTabs = new Set(aExcludeTabs);
@ -519,7 +510,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
// If this tab has a successor, it should be selectable, since // If this tab has a successor, it should be selectable, since
// hiding or closing a tab removes that tab as a successor. // hiding or closing a tab removes that tab as a successor.
@@ -5242,13 +5372,13 @@ @@ -5242,13 +5368,13 @@
!excludeTabs.has(aTab.owner) && !excludeTabs.has(aTab.owner) &&
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose") Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
) { ) {
@ -535,7 +526,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
); );
let tab = this.tabContainer.findNextTab(aTab, { let tab = this.tabContainer.findNextTab(aTab, {
@@ -5264,7 +5394,7 @@ @@ -5264,7 +5390,7 @@
} }
if (tab) { if (tab) {
@ -544,7 +535,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
} }
// If no qualifying visible tab was found, see if there is a tab in // If no qualifying visible tab was found, see if there is a tab in
@@ -5285,7 +5415,7 @@ @@ -5285,7 +5411,7 @@
}); });
} }
@ -553,7 +544,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
} }
_blurTab(aTab) { _blurTab(aTab) {
@@ -5686,10 +5816,10 @@ @@ -5686,10 +5812,10 @@
SessionStore.deleteCustomTabValue(aTab, "hiddenBy"); SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
} }
@ -566,7 +557,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
aTab.selected || aTab.selected ||
aTab.closing || aTab.closing ||
// Tabs that are sharing the screen, microphone or camera cannot be hidden. // Tabs that are sharing the screen, microphone or camera cannot be hidden.
@@ -5986,7 +6116,7 @@ @@ -5986,7 +6112,7 @@
// Don't allow mixing pinned and unpinned tabs. // Don't allow mixing pinned and unpinned tabs.
if (this.isTab(element) && element.pinned) { if (this.isTab(element) && element.pinned) {
@ -575,13 +566,13 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
} else { } else {
tabIndex = Math.max(tabIndex, this.pinnedTabCount); tabIndex = Math.max(tabIndex, this.pinnedTabCount);
} }
@@ -6012,10 +6142,16 @@ @@ -6012,10 +6138,16 @@
this.#handleTabMove( this.#handleTabMove(
element, element,
() => { () => {
- let neighbor = this.tabs[tabIndex]; - let neighbor = this.tabs[tabIndex];
- if (forceUngrouped && neighbor?.group) { - if (forceUngrouped && neighbor?.group) {
+ let neighbor = gZenGlanceManager.getTabOrGlanceParent(this.tabs.filter(tab => !tab.hasAttribute("zen-glance-tab"))[tabIndex]); + let neighbor = gZenGlanceManager.getTabOrGlanceParent(this.tabs[tabIndex]);
+ if ((forceUngrouped && neighbor?.group) || neighbor?.group?.hasAttribute("split-view-group")) { + if ((forceUngrouped && neighbor?.group) || neighbor?.group?.hasAttribute("split-view-group")) {
neighbor = neighbor.group; neighbor = neighbor.group;
} }
@ -594,7 +585,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
if (neighbor && this.isTab(element) && tabIndex > element._tPos) { if (neighbor && this.isTab(element) && tabIndex > element._tPos) {
neighbor.after(element); neighbor.after(element);
} else { } else {
@@ -6084,7 +6220,9 @@ @@ -6084,17 +6216,26 @@
targetElement = targetElement.group; targetElement = targetElement.group;
} }
} }
@ -604,8 +595,12 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
+ } + }
// Don't allow mixing pinned and unpinned tabs. // Don't allow mixing pinned and unpinned tabs.
if (element.pinned && !targetElement?.pinned) { if (element.pinned && !targetElement?.pinned) {
targetElement = this.tabs[this.pinnedTabCount - 1]; - targetElement = this.tabs[this.pinnedTabCount - 1];
@@ -6094,7 +6232,14 @@ + targetElement = this.tabs.filter(tab => !tab.hasAttribute('zen-glance-tab'))[this.pinnedTabCount - 1];
moveBefore = false;
} else if (!element.pinned && targetElement && targetElement.pinned) {
- targetElement = this.tabs[this.pinnedTabCount];
+ targetElement = this.tabs.filter(tab => !tab.hasAttribute('zen-glance-tab'))[this.pinnedTabCount];
moveBefore = true; moveBefore = true;
} }
@ -620,7 +615,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
if (element.pinned && this.tabContainer.verticalMode) { if (element.pinned && this.tabContainer.verticalMode) {
return this.tabContainer.verticalPinnedTabsContainer; return this.tabContainer.verticalPinnedTabsContainer;
} }
@@ -6154,7 +6299,7 @@ @@ -6154,7 +6295,7 @@
if (!this.isTab(aTab)) { if (!this.isTab(aTab)) {
throw new Error("Can only move a tab into a tab group"); throw new Error("Can only move a tab into a tab group");
} }
@ -629,7 +624,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
return; return;
} }
if (aTab.group && aTab.group.id === aGroup.id) { if (aTab.group && aTab.group.id === aGroup.id) {
@@ -6248,6 +6393,10 @@ @@ -6248,6 +6389,10 @@
moveActionCallback(); moveActionCallback();
@ -640,7 +635,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
// Clear tabs cache after moving nodes because the order of tabs may have // Clear tabs cache after moving nodes because the order of tabs may have
// changed. // changed.
this.tabContainer._invalidateCachedTabs(); this.tabContainer._invalidateCachedTabs();
@@ -7145,7 +7294,7 @@ @@ -7145,7 +7290,7 @@
// preventDefault(). It will still raise the window if appropriate. // preventDefault(). It will still raise the window if appropriate.
break; break;
} }
@ -649,7 +644,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
window.focus(); window.focus();
aEvent.preventDefault(); aEvent.preventDefault();
break; break;
@@ -8044,6 +8193,7 @@ @@ -8044,6 +8189,7 @@
aWebProgress.isTopLevel aWebProgress.isTopLevel
) { ) {
this.mTab.setAttribute("busy", "true"); this.mTab.setAttribute("busy", "true");
@ -657,7 +652,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
gBrowser._tabAttrModified(this.mTab, ["busy"]); gBrowser._tabAttrModified(this.mTab, ["busy"]);
this.mTab._notselectedsinceload = !this.mTab.selected; this.mTab._notselectedsinceload = !this.mTab.selected;
} }
@@ -9009,7 +9159,7 @@ var TabContextMenu = { @@ -9009,7 +9155,7 @@ var TabContextMenu = {
); );
contextUnpinSelectedTabs.hidden = contextUnpinSelectedTabs.hidden =
!this.contextTab.pinned || !this.multiselected; !this.contextTab.pinned || !this.multiselected;
@ -666,7 +661,7 @@ index d5aa64842a35c6697263c63fd3a0571b64b01344..7e9aa77a5ea59b9002c7ce4b88432247
// Move Tab items // Move Tab items
let contextMoveTabOptions = document.getElementById( let contextMoveTabOptions = document.getElementById(
"context_moveTabOptions" "context_moveTabOptions"
@@ -9278,6 +9428,7 @@ var TabContextMenu = { @@ -9278,6 +9424,7 @@ var TabContextMenu = {
telemetrySource: gBrowser.TabMetrics.METRIC_SOURCE.TAB_STRIP, telemetrySource: gBrowser.TabMetrics.METRIC_SOURCE.TAB_STRIP,
}); });
} else { } else {

View file

@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bcdc076dfc 100644 index 84d633471c89230b981d8a07babef4e0c76c0338..1a9c56846ff27d68c16b939fb759ea9596403cef 100644
--- a/browser/components/tabbrowser/content/tabs.js --- a/browser/components/tabbrowser/content/tabs.js
+++ b/browser/components/tabbrowser/content/tabs.js +++ b/browser/components/tabbrowser/content/tabs.js
@@ -83,7 +83,7 @@ @@ -83,7 +83,7 @@
@ -33,7 +33,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
// In expanded vertical mode, the max number of pinned tabs per row is dynamic // In expanded vertical mode, the max number of pinned tabs per row is dynamic
// Set this before adjusting dragged tab's position // Set this before adjusting dragged tab's position
- let pinnedTabs = this.visibleTabs.slice(0, gBrowser.pinnedTabCount); - let pinnedTabs = this.visibleTabs.slice(0, gBrowser.pinnedTabCount);
+ let pinnedTabs = this.visibleTabs.filter(tab => !tab.hasAttribute("zen-glance-tab")).slice(0, gBrowser._numZenEssentials); + let pinnedTabs = this.ariaFocusableItems.slice(0, gBrowser._numZenEssentials);
let tabsPerRow = 0; let tabsPerRow = 0;
let position = 0; let position = 0;
for (let pinnedTab of pinnedTabs) { for (let pinnedTab of pinnedTabs) {
@ -81,12 +81,11 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
} else { } else {
let isPinned = draggedTab.pinned; let isPinned = draggedTab.pinned;
- let numPinned = gBrowser.pinnedTabCount; - let numPinned = gBrowser.pinnedTabCount;
- let tabs = this.ariaFocusableItems.slice(
- isPinned ? 0 : numPinned,
- isPinned ? numPinned : undefined
+ let numPinned = gBrowser._numVisiblePinTabsWithoutCollapsed; + let numPinned = gBrowser._numVisiblePinTabsWithoutCollapsed;
+ let essential = draggedTab.hasAttribute("zen-essential"); + let essential = draggedTab.hasAttribute("zen-essential");
+ let tabs = this.ariaFocusableItems.filter(tab => !tab.hasAttribute("zen-glance-tab")).slice( let tabs = this.ariaFocusableItems.slice(
- isPinned ? 0 : numPinned,
- isPinned ? numPinned : undefined
+ isPinned ? (essential ? 0 : gBrowser._numZenEssentials) : numPinned, + isPinned ? (essential ? 0 : gBrowser._numZenEssentials) : numPinned,
+ isPinned ? (essential ? gBrowser._numZenEssentials : numPinned) : undefined + isPinned ? (essential ? gBrowser._numZenEssentials : numPinned) : undefined
); );
@ -136,7 +135,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
} }
get verticalMode() { get verticalMode() {
@@ -1621,29 +1651,55 @@ @@ -1621,29 +1651,54 @@
if (this.#allTabs) { if (this.#allTabs) {
return this.#allTabs; return this.#allTabs;
} }
@ -174,14 +173,13 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
]; ];
+ const lastPinnedTabIdx = pinnedTabs.length - 1; + const lastPinnedTabIdx = pinnedTabs.length - 1;
+ let i = 0; + let i = 0;
+ for (const tab of allTabs) { + for (const tab of [...allTabs]) {
+ // add glance tabs (tabs inside tabs) to the list + // add glance tabs (tabs inside tabs) to the list
+ const glanceTab = tab.glanceTab; + const glanceTab = tab.glanceTab;
+ if (glanceTab) { + if (glanceTab) {
+ // insert right after the parent tab. note: it must be inserted before + // insert right after the parent tab. note: it must be inserted before
+ // the last pinned tab so it can be inserted in the correct order + // the last pinned tab so it can be inserted in the correct order
+ allTabs.splice(Math.max(i + 1, lastPinnedTabIdx), 0, glanceTab); + allTabs.splice(Math.max(i++, lastPinnedTabIdx), 0, glanceTab);
+ i++;
+ } else if (tab.classList.contains("vertical-pinned-tabs-container-separator")) { + } else if (tab.classList.contains("vertical-pinned-tabs-container-separator")) {
+ // remove the separator from the list + // remove the separator from the list
+ allTabs.splice(i, 1); + allTabs.splice(i, 1);
@ -200,16 +198,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
} }
/** /**
@@ -1663,7 +1719,7 @@ @@ -1698,23 +1753,18 @@
*/
get visibleTabs() {
if (!this.#visibleTabs) {
- this.#visibleTabs = this.openTabs.filter(tab => tab.visible);
+ this.#visibleTabs = this.openTabs.filter(tab => tab.visible && !tab.hasAttribute("zen-empty-tab"));
}
return this.#visibleTabs;
}
@@ -1698,36 +1754,40 @@
} }
let elementIndex = 0; let elementIndex = 0;
@ -237,21 +226,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
let visibleTabsInGroup = child.tabs.filter(tab => tab.visible); let visibleTabsInGroup = child.tabs.filter(tab => tab.visible);
visibleTabsInGroup.forEach(tab => { visibleTabsInGroup.forEach(tab => {
tab.elementIndex = elementIndex++; tab.elementIndex = elementIndex++;
}); @@ -1724,10 +1774,7 @@
focusableItems.push(...visibleTabsInGroup);
}
+ for (let tab of child.tabs) {
+ let glanceTab = tab.glanceTab;
+ if (isTab(glanceTab)) {
+ glanceTab.elementIndex = elementIndex - 1;
+ focusableItems.push(glanceTab);
+ }
+ }
+ }
+ let glanceTab = child.glanceTab;
+ if (isTab(child) && glanceTab) {
+ glanceTab.elementIndex = elementIndex - 1;
+ focusableItems.push(glanceTab);
} }
} }
@ -263,7 +238,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
return this.#focusableItems; return this.#focusableItems;
} }
@@ -1735,6 +1795,7 @@ @@ -1735,6 +1782,7 @@
_invalidateCachedTabs() { _invalidateCachedTabs() {
this.#allTabs = null; this.#allTabs = null;
this._invalidateCachedVisibleTabs(); this._invalidateCachedVisibleTabs();
@ -271,7 +246,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
} }
_invalidateCachedVisibleTabs() { _invalidateCachedVisibleTabs() {
@@ -1749,8 +1810,8 @@ @@ -1749,8 +1797,8 @@
#isContainerVerticalPinnedGrid(tab) { #isContainerVerticalPinnedGrid(tab) {
return ( return (
this.verticalMode && this.verticalMode &&
@ -282,7 +257,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
!this.expandOnHover !this.expandOnHover
); );
} }
@@ -1766,7 +1827,7 @@ @@ -1766,7 +1814,7 @@
if (node == null) { if (node == null) {
// We have a container for non-tab elements at the end of the scrollbox. // We have a container for non-tab elements at the end of the scrollbox.
@ -291,7 +266,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
} }
node.before(tab); node.before(tab);
@@ -1861,7 +1922,7 @@ @@ -1861,7 +1909,7 @@
// There are separate "new tab" buttons for horizontal tabs toolbar, vertical tabs and // There are separate "new tab" buttons for horizontal tabs toolbar, vertical tabs and
// for when the tab strip is overflowed (which is shared by vertical and horizontal tabs); // for when the tab strip is overflowed (which is shared by vertical and horizontal tabs);
// Attach the long click popup to all of them. // Attach the long click popup to all of them.
@ -300,7 +275,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
const newTab2 = this.newTabButton; const newTab2 = this.newTabButton;
const newTabVertical = document.getElementById( const newTabVertical = document.getElementById(
"vertical-tabs-newtab-button" "vertical-tabs-newtab-button"
@@ -1956,10 +2017,12 @@ @@ -1956,10 +2004,12 @@
_handleTabSelect(aInstant) { _handleTabSelect(aInstant) {
let selectedTab = this.selectedItem; let selectedTab = this.selectedItem;
@ -313,68 +288,24 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
selectedTab._notselectedsinceload = false; selectedTab._notselectedsinceload = false;
} }
@@ -2100,16 +2163,15 @@ @@ -2132,6 +2182,7 @@
// Move pinned tabs to another container when the tabstrip is toggled to vertical
// and when session restore code calls _positionPinnedTabs; update styling whenever
// the number of pinned tabs changes.
- let verticalTabsContainer = document.getElementById(
- "vertical-pinned-tabs-container"
- );
+ let verticalTabsContainer = this.verticalPinnedTabsContainer;
let numPinned = gBrowser.pinnedTabCount;
-
- if (gBrowser.pinnedTabCount !== verticalTabsContainer.children.length) {
- let tabs = this.visibleTabs;
+ if (!gZenWorkspaces._hasInitializedTabsStrip) return;
+ let count = gZenWorkspaces.makeSurePinTabIsInCorrectPosition();
+ if (gBrowser.pinnedTabCount !== (verticalTabsContainer.children.length - count - 1 + gZenWorkspaces.getCurrentEssentialsContainer().children.length)) {
+ let tabs = this.allTabs.filter(tab => !tab.hasAttribute("zen-glance-tab"));
for (let i = 0; i < numPinned; i++) {
tabs[i].style.marginInlineStart = "";
- verticalTabsContainer.appendChild(tabs[i]);
+ tabs[i].hasAttribute("zen-essential") ? gZenWorkspaces.getCurrentEssentialsContainer().appendChild(tabs[i].group?.hasAttribute("split-view-group") ? tabs[i].group : tabs[i]) : verticalTabsContainer.insertBefore(tabs[i].group?.hasAttribute("split-view-group") ? tabs[i].group : tabs[i], verticalTabsContainer.lastChild);
}
}
@@ -2117,9 +2179,7 @@
}
_resetVerticalPinnedTabs() {
- let verticalTabsContainer = document.getElementById(
- "vertical-pinned-tabs-container"
- );
+ let verticalTabsContainer = this.verticalPinnedTabsContainer;
if (!verticalTabsContainer.children.length) {
return;
@@ -2132,7 +2192,7 @@
} }
_positionPinnedTabs() { _positionPinnedTabs() {
- let tabs = this.visibleTabs; + if (true) return;
+ let tabs = this.visibleTabs.filter(tab => !tab.hasAttribute("zen-glance-tab")); let tabs = this.visibleTabs;
let numPinned = gBrowser.pinnedTabCount; let numPinned = gBrowser.pinnedTabCount;
let absPositionHorizontalTabs = let absPositionHorizontalTabs =
this.overflowing && tabs.length > numPinned && numPinned > 0; @@ -2206,7 +2257,7 @@
@@ -2142,7 +2202,7 @@
if (this.verticalMode) {
this._updateVerticalPinnedTabs();
- } else if (absPositionHorizontalTabs) {
+ } else if (absPositionHorizontalTabs && false) {
let layoutData = this._pinnedTabsLayoutCache;
let uiDensity = document.documentElement.getAttribute("uidensity");
if (!layoutData || layoutData.uiDensity != uiDensity) {
@@ -2206,7 +2266,7 @@
return; return;
} }
- let tabs = this.visibleTabs.slice(0, gBrowser.pinnedTabCount); - let tabs = this.visibleTabs.slice(0, gBrowser.pinnedTabCount);
+ let tabs = this.visibleTabs.filter(tab => !tab.hasAttribute("zen-glance-tab")).slice(0, gBrowser._numZenEssentials); + let tabs = this.ariaFocusableItems.slice(0, gBrowser._numZenEssentials);
let directionX = screenX > dragData.animLastScreenX; let directionX = screenX > dragData.animLastScreenX;
let directionY = screenY > dragData.animLastScreenY; let directionY = screenY > dragData.animLastScreenY;
@@ -2214,7 +2274,7 @@ @@ -2214,7 +2265,7 @@
dragData.animLastScreenX = screenX; dragData.animLastScreenX = screenX;
let { width: tabWidth, height: tabHeight } = let { width: tabWidth, height: tabHeight } =
@ -383,28 +314,18 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
let shiftSizeX = tabWidth * movingTabs.length; let shiftSizeX = tabWidth * movingTabs.length;
let shiftSizeY = tabHeight; let shiftSizeY = tabHeight;
dragData.tabWidth = tabWidth; dragData.tabWidth = tabWidth;
@@ -2277,7 +2337,7 @@ @@ -2389,12 +2440,16 @@
// * We're doing a binary search in order to reduce the amount of
// tabs we need to check.
- tabs = tabs.filter(t => !movingTabs.includes(t) || t == draggedTab);
+ tabs = tabs.filter(t => !movingTabs.includes(t) || t == draggedTab && !t.hasAttribute("zen-glance-tab"));
let firstTabCenterX = firstMovingTabScreenX + translateX + tabWidth / 2;
let lastTabCenterX = lastMovingTabScreenX + translateX + tabWidth / 2;
let tabCenterX = directionX ? lastTabCenterX : firstTabCenterX;
@@ -2389,12 +2449,16 @@
this.#clearDragOverCreateGroupTimer(); this.#clearDragOverCreateGroupTimer();
- let isPinned = draggedTab.pinned; - let isPinned = draggedTab.pinned;
- let numPinned = gBrowser.pinnedTabCount; - let numPinned = gBrowser.pinnedTabCount;
- let tabs = this.ariaFocusableItems.slice(
- isPinned ? 0 : numPinned,
- isPinned ? numPinned : undefined
+ let isPinned = draggedTab?.group ? draggedTab.group.pinned : draggedTab.pinned; + let isPinned = draggedTab?.group ? draggedTab.group.pinned : draggedTab.pinned;
+ let numPinned = gBrowser._numVisiblePinTabsWithoutCollapsed; + let numPinned = gBrowser._numVisiblePinTabsWithoutCollapsed;
+ let essential = draggedTab.hasAttribute("zen-essential"); + let essential = draggedTab.hasAttribute("zen-essential");
+ let tabs = this.ariaFocusableItems.filter(tab => !tab.hasAttribute("zen-glance-tab")).slice( let tabs = this.ariaFocusableItems.slice(
- isPinned ? 0 : numPinned,
- isPinned ? numPinned : undefined
+ isPinned ? (essential ? 0 : gBrowser._numZenEssentials) : numPinned, + isPinned ? (essential ? 0 : gBrowser._numZenEssentials) : numPinned,
+ isPinned ? (essential ? gBrowser._numZenEssentials : numPinned) : undefined + isPinned ? (essential ? gBrowser._numZenEssentials : numPinned) : undefined
); );
@ -414,7 +335,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
if (this.#rtlMode) { if (this.#rtlMode) {
tabs.reverse(); tabs.reverse();
@@ -2408,7 +2472,7 @@ @@ -2408,7 +2463,7 @@
let size = this.verticalMode ? "height" : "width"; let size = this.verticalMode ? "height" : "width";
let translateAxis = this.verticalMode ? "translateY" : "translateX"; let translateAxis = this.verticalMode ? "translateY" : "translateX";
let scrollDirection = this.verticalMode ? "scrollTop" : "scrollLeft"; let scrollDirection = this.verticalMode ? "scrollTop" : "scrollLeft";
@ -423,7 +344,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
let translateX = event.screenX - dragData.screenX; let translateX = event.screenX - dragData.screenX;
let translateY = event.screenY - dragData.screenY; let translateY = event.screenY - dragData.screenY;
@@ -2422,12 +2486,21 @@ @@ -2422,12 +2477,21 @@
let lastTab = tabs.at(-1); let lastTab = tabs.at(-1);
let lastMovingTab = movingTabs.at(-1); let lastMovingTab = movingTabs.at(-1);
let firstMovingTab = movingTabs[0]; let firstMovingTab = movingTabs[0];
@ -446,7 +367,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
translate += translate +=
this.arrowScrollbox.scrollbox[scrollDirection] - dragData.scrollPos; this.arrowScrollbox.scrollbox[scrollDirection] - dragData.scrollPos;
} else if (isPinned && this.verticalMode) { } else if (isPinned && this.verticalMode) {
@@ -2446,12 +2519,15 @@ @@ -2446,6 +2510,9 @@
// Shift the `.tab-group-label-container` to shift the label element. // Shift the `.tab-group-label-container` to shift the label element.
item = item.parentElement; item = item.parentElement;
} }
@ -456,14 +377,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
item.style.transform = `${translateAxis}(${translate}px)`; item.style.transform = `${translateAxis}(${translate}px)`;
} }
dragData.translatePos = translate; @@ -2583,6 +2650,9 @@
- tabs = tabs.filter(t => !movingTabs.includes(t) || t == draggedTab);
+ tabs = tabs.filter(t => !movingTabs.includes(t) || t == draggedTab && !t.hasAttribute("zen-glance-tab"));
/**
* When the `draggedTab` is just starting to move, the `draggedTab` is in
@@ -2583,6 +2659,9 @@
break; break;
} }
let element = tabs[mid]; let element = tabs[mid];
@ -473,20 +387,18 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
let elementForSize = isTabGroupLabel(element) let elementForSize = isTabGroupLabel(element)
? element.parentElement ? element.parentElement
: element; : element;
@@ -2603,7 +2682,11 @@ @@ -2605,6 +2675,10 @@
let dropElement = getOverlappedElement();
if (!dropElement) { if (!dropElement) {
- dropElement = this.ariaFocusableItems[oldDropElementIndex]; dropElement = this.ariaFocusableItems[oldDropElementIndex];
+ dropElement = this.ariaFocusableItems.filter(tab => !tab.hasAttribute("zen-glance-tab"))[oldDropElementIndex]; }
+ }
+ if (dropElement?.group?.hasAttribute("split-view-group")) { + if (dropElement?.group?.hasAttribute("split-view-group")) {
+ // We focus the group label element, not the group itself. + // We focus the group label element, not the group itself.
+ dropElement = dropElement.group.labelElement; + dropElement = dropElement.group.labelElement;
} + }
let newDropElementIndex = dropElement let newDropElementIndex = dropElement
? dropElement.elementIndex ? dropElement.elementIndex
@@ -2613,7 +2696,7 @@ : oldDropElementIndex;
@@ -2613,7 +2687,7 @@
let shouldCreateGroupOnDrop; let shouldCreateGroupOnDrop;
let dropBefore; let dropBefore;
if (dropElement) { if (dropElement) {
@ -495,7 +407,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
? dropElement.parentElement ? dropElement.parentElement
: dropElement; : dropElement;
@@ -2675,12 +2758,12 @@ @@ -2675,12 +2749,12 @@
} }
} }
@ -510,7 +422,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
dropElement != draggedTab && dropElement != draggedTab &&
isTab(dropElement) && isTab(dropElement) &&
!dropElement?.group && !dropElement?.group &&
@@ -2750,7 +2833,7 @@ @@ -2750,7 +2824,7 @@
// Shift background tabs to leave a gap where the dragged tab // Shift background tabs to leave a gap where the dragged tab
// would currently be dropped. // would currently be dropped.
for (let item of tabs) { for (let item of tabs) {
@ -519,7 +431,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
continue; continue;
} }
@@ -2759,6 +2842,9 @@ @@ -2759,6 +2833,9 @@
if (isTabGroupLabel(item)) { if (isTabGroupLabel(item)) {
// Shift the `.tab-group-label-container` to shift the label element. // Shift the `.tab-group-label-container` to shift the label element.
item = item.parentElement; item = item.parentElement;
@ -529,7 +441,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
} }
item.style.transform = transform; item.style.transform = transform;
} }
@@ -2811,8 +2897,9 @@ @@ -2811,8 +2888,9 @@
); );
} }
@ -541,7 +453,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
return; return;
} }
@@ -2824,6 +2911,12 @@ @@ -2824,6 +2902,12 @@
item = item.parentElement; item = item.parentElement;
} }
item.style.transform = ""; item.style.transform = "";
@ -554,7 +466,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
item.removeAttribute("dragover-createGroup"); item.removeAttribute("dragover-createGroup");
} }
this.removeAttribute("movingtab-createGroup"); this.removeAttribute("movingtab-createGroup");
@@ -2870,7 +2963,7 @@ @@ -2870,7 +2954,7 @@
let postTransitionCleanup = () => { let postTransitionCleanup = () => {
movingTab._moveTogetherSelectedTabsData.animate = false; movingTab._moveTogetherSelectedTabsData.animate = false;
}; };
@ -563,7 +475,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
postTransitionCleanup(); postTransitionCleanup();
} else { } else {
let onTransitionEnd = transitionendEvent => { let onTransitionEnd = transitionendEvent => {
@@ -3043,7 +3136,7 @@ @@ -3043,7 +3127,7 @@
} }
_notifyBackgroundTab(aTab) { _notifyBackgroundTab(aTab) {
@ -572,7 +484,7 @@ index 84d633471c89230b981d8a07babef4e0c76c0338..13d1191438daa4e213c0ffd1fffca4bc
return; return;
} }
@@ -3169,6 +3262,9 @@ @@ -3169,6 +3253,9 @@
return null; return null;
} }
} }

View file

@ -1,5 +1,5 @@
diff --git a/browser/themes/shared/tabbrowser/tabs.css b/browser/themes/shared/tabbrowser/tabs.css diff --git a/browser/themes/shared/tabbrowser/tabs.css b/browser/themes/shared/tabbrowser/tabs.css
index 5b9ad123d819c6ef068acd427416957a1d0939fe..ab4cc6b8ea05bceaed6f62ab6570f0c12214f459 100644 index 5b9ad123d819c6ef068acd427416957a1d0939fe..311caa27ee268c95215d459be02a93d20e129f8b 100644
--- a/browser/themes/shared/tabbrowser/tabs.css --- a/browser/themes/shared/tabbrowser/tabs.css
+++ b/browser/themes/shared/tabbrowser/tabs.css +++ b/browser/themes/shared/tabbrowser/tabs.css
@@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
@ -37,7 +37,7 @@ index 5b9ad123d819c6ef068acd427416957a1d0939fe..ab4cc6b8ea05bceaed6f62ab6570f0c1
&::before { &::before {
position: absolute; position: absolute;
@@ -459,6 +458,7 @@ @@ -459,14 +458,11 @@
.tab-icon-image { .tab-icon-image {
-moz-context-properties: fill, stroke; -moz-context-properties: fill, stroke;
fill: currentColor; fill: currentColor;
@ -45,7 +45,26 @@ index 5b9ad123d819c6ef068acd427416957a1d0939fe..ab4cc6b8ea05bceaed6f62ab6570f0c1
/* stylelint-disable-next-line media-query-no-invalid */ /* stylelint-disable-next-line media-query-no-invalid */
@media -moz-pref("browser.tabs.fadeOutUnloadedTabs") { @media -moz-pref("browser.tabs.fadeOutUnloadedTabs") {
@@ -559,7 +559,7 @@ &[pending] {
- filter: grayscale(100%);
- @media (prefers-color-scheme: dark) {
- filter: grayscale(100%) invert();
- }
opacity: 0.5;
/* Fade the favicon out */
transition-property: filter, opacity;
@@ -483,10 +479,6 @@
/* stylelint-disable-next-line media-query-no-invalid */
@media -moz-pref("browser.tabs.fadeOutExplicitlyUnloadedTabs") {
&[pending][discarded] {
- filter: grayscale(100%);
- @media (prefers-color-scheme: dark) {
- filter: grayscale(100%) invert();
- }
opacity: 0.5;
/* Fade the favicon out */
transition-property: filter, opacity;
@@ -559,7 +551,7 @@
z-index: 1; /* Overlay tab title */ z-index: 1; /* Overlay tab title */
#tabbrowser-tabs[orient=vertical] & { #tabbrowser-tabs[orient=vertical] & {
@ -54,7 +73,7 @@ index 5b9ad123d819c6ef068acd427416957a1d0939fe..ab4cc6b8ea05bceaed6f62ab6570f0c1
} }
&[crashed] { &[crashed] {
@@ -567,7 +567,7 @@ @@ -567,7 +559,7 @@
} }
#tabbrowser-tabs[orient="vertical"]:not([expanded]) &:not([crashed]), #tabbrowser-tabs[orient="vertical"]:not([expanded]) &:not([crashed]),
@ -63,7 +82,7 @@ index 5b9ad123d819c6ef068acd427416957a1d0939fe..ab4cc6b8ea05bceaed6f62ab6570f0c1
&[soundplaying] { &[soundplaying] {
list-style-image: url("chrome://browser/skin/tabbrowser/tab-audio-playing-small.svg"); list-style-image: url("chrome://browser/skin/tabbrowser/tab-audio-playing-small.svg");
} }
@@ -597,7 +597,7 @@ @@ -597,7 +589,7 @@
background-image: linear-gradient(var(--audio-overlay-extra-background)), background-image: linear-gradient(var(--audio-overlay-extra-background)),
linear-gradient(var(--toolbox-bgcolor)); linear-gradient(var(--toolbox-bgcolor));
-moz-context-properties: fill; -moz-context-properties: fill;
@ -72,7 +91,7 @@ index 5b9ad123d819c6ef068acd427416957a1d0939fe..ab4cc6b8ea05bceaed6f62ab6570f0c1
color-scheme: var(--tab-selected-color-scheme); color-scheme: var(--tab-selected-color-scheme);
border-radius: var(--border-radius-circle); border-radius: var(--border-radius-circle);
@@ -1365,7 +1365,7 @@ tab-group { @@ -1365,7 +1357,7 @@ tab-group {
} }
} }
@ -81,7 +100,7 @@ index 5b9ad123d819c6ef068acd427416957a1d0939fe..ab4cc6b8ea05bceaed6f62ab6570f0c1
#vertical-tabs-newtab-button { #vertical-tabs-newtab-button {
appearance: none; appearance: none;
min-height: var(--tab-min-height); min-height: var(--tab-min-height);
@@ -1376,7 +1376,7 @@ tab-group { @@ -1376,7 +1368,7 @@ tab-group {
margin-inline: var(--tab-inner-inline-margin); margin-inline: var(--tab-inner-inline-margin);
#tabbrowser-tabs[orient="vertical"]:not([expanded]) & > .toolbarbutton-text { #tabbrowser-tabs[orient="vertical"]:not([expanded]) & > .toolbarbutton-text {
@ -90,7 +109,7 @@ index 5b9ad123d819c6ef068acd427416957a1d0939fe..ab4cc6b8ea05bceaed6f62ab6570f0c1
} }
&:hover { &:hover {
@@ -1400,7 +1400,7 @@ tab-group { @@ -1400,7 +1392,7 @@ tab-group {
* flex container. #tabs-newtab-button is a child of the arrowscrollbox where * flex container. #tabs-newtab-button is a child of the arrowscrollbox where
* we don't want a gap (between tabs), so we have to add some margin. * we don't want a gap (between tabs), so we have to add some margin.
*/ */
@ -99,7 +118,7 @@ index 5b9ad123d819c6ef068acd427416957a1d0939fe..ab4cc6b8ea05bceaed6f62ab6570f0c1
margin-block: var(--tab-block-margin); margin-block: var(--tab-block-margin);
} }
@@ -1474,8 +1474,6 @@ tab-group { @@ -1474,8 +1466,6 @@ tab-group {
} }
:root:not([sidebar-expand-on-hover]) & { :root:not([sidebar-expand-on-hover]) & {
@ -108,7 +127,7 @@ index 5b9ad123d819c6ef068acd427416957a1d0939fe..ab4cc6b8ea05bceaed6f62ab6570f0c1
/* stylelint-disable-next-line media-query-no-invalid */ /* stylelint-disable-next-line media-query-no-invalid */
@media not -moz-pref("sidebar.visibility", "expand-on-hover") { @media not -moz-pref("sidebar.visibility", "expand-on-hover") {
/* We need these rules to apply at all times when the sidebar.visibility /* We need these rules to apply at all times when the sidebar.visibility
@@ -1585,7 +1583,6 @@ tab-group { @@ -1585,7 +1575,6 @@ tab-group {
&:not([expanded]) { &:not([expanded]) {
.tabbrowser-tab[pinned] { .tabbrowser-tab[pinned] {
@ -116,7 +135,7 @@ index 5b9ad123d819c6ef068acd427416957a1d0939fe..ab4cc6b8ea05bceaed6f62ab6570f0c1
} }
.tab-background { .tab-background {
@@ -1716,7 +1713,7 @@ tab-group { @@ -1716,7 +1705,7 @@ tab-group {
toolbarbutton:not(#firefox-view-button), toolbarbutton:not(#firefox-view-button),
toolbarpaletteitem:not(#wrapper-firefox-view-button) toolbarpaletteitem:not(#wrapper-firefox-view-button)
) ~ #tabbrowser-tabs { ) ~ #tabbrowser-tabs {
@ -125,7 +144,7 @@ index 5b9ad123d819c6ef068acd427416957a1d0939fe..ab4cc6b8ea05bceaed6f62ab6570f0c1
padding-inline-start: calc(var(--tab-overflow-pinned-tabs-width) + 2px); padding-inline-start: calc(var(--tab-overflow-pinned-tabs-width) + 2px);
margin-inline-start: 2px; margin-inline-start: 2px;
} }
@@ -1750,7 +1747,6 @@ toolbar:not(#TabsToolbar) #firefox-view-button { @@ -1750,7 +1739,6 @@ toolbar:not(#TabsToolbar) #firefox-view-button {
list-style-image: url(chrome://global/skin/icons/plus.svg); list-style-image: url(chrome://global/skin/icons/plus.svg);
} }

View file

@ -83,17 +83,12 @@
} }
} }
getTabPosition(tab) {
return tab._tPos;
}
createBrowserElement(url, currentTab, existingTab = null) { createBrowserElement(url, currentTab, existingTab = null) {
const newTabOptions = { const newTabOptions = {
userContextId: currentTab.getAttribute('usercontextid') || '', userContextId: currentTab.getAttribute('usercontextid') || '',
skipBackgroundNotify: true, skipBackgroundNotify: true,
insertTab: true, insertTab: true,
skipLoad: false, skipLoad: false,
index: this.getTabPosition(currentTab) + 1,
}; };
currentTab._selected = true; currentTab._selected = true;
const newUUID = gZenUIManager.generateUuidv4(); const newUUID = gZenUIManager.generateUuidv4();
@ -294,9 +289,7 @@
this.closingGlance = true; this.closingGlance = true;
this._animating = true; this._animating = true;
gBrowser.zenInsertTabAtIndex(this.#currentTab, { gBrowser.moveTabAfter(this.#currentTab, this.#currentParentTab);
tabIndex: this.getTabPosition(this.#currentParentTab),
});
let quikcCloseZen = false; let quikcCloseZen = false;
if (onTabClose) { if (onTabClose) {
@ -629,9 +622,7 @@
this.animatingFullOpen = true; this.animatingFullOpen = true;
this.#currentTab.setAttribute('zen-dont-split-glance', true); this.#currentTab.setAttribute('zen-dont-split-glance', true);
gBrowser.zenInsertTabAtIndex(this.#currentTab, { gBrowser.moveTabAfter(this.#currentTab, this.#currentParentTab);
tabIndex: this.getTabPosition(this.#currentTab),
});
this.#currentTab.removeAttribute('zen-glance-tab'); this.#currentTab.removeAttribute('zen-glance-tab');
this._clearContainerStyles(this.browserWrapper); this._clearContainerStyles(this.browserWrapper);

View file

@ -6,3 +6,5 @@ support-files = [
["browser_glance_basic.js"] ["browser_glance_basic.js"]
["browser_glance_expand.js"] ["browser_glance_expand.js"]
["browser_glance_close.js"] ["browser_glance_close.js"]
["browser_glance_next_tab.js"]
["browser_glance_prev_tab.js"]

View file

@ -62,8 +62,8 @@ add_task(async function test_Glance_Basic_Open() {
await openGlanceOnTab(async (glanceTab) => { await openGlanceOnTab(async (glanceTab) => {
await gZenGlanceManager.fullyOpenGlance(); await gZenGlanceManager.fullyOpenGlance();
Assert.equal( Assert.equal(
glanceTab._tPos, glanceTab,
3, gBrowser.visibleTabs.find((tab) => !tab.pinned),
'The glance tab should be the first normal tab (Ignoring empty tabs)' 'The glance tab should be the first normal tab (Ignoring empty tabs)'
); );
BrowserTestUtils.removeTab(glanceTab); BrowserTestUtils.removeTab(glanceTab);
@ -84,13 +84,8 @@ add_task(async function test_Glance_New_From_essential() {
skipAnimation: true, skipAnimation: true,
}); });
Assert.equal( Assert.equal(
gBrowser.selectedTab._tPos, glanceTab,
1, gBrowser.visibleTabs[2],
'The new tab should be the first normal tab (Ignoring empty tabs)'
);
Assert.equal(
glanceTab._tPos,
2,
'The glance tab should be the second normal tab (Ignoring empty tabs)' 'The glance tab should be the second normal tab (Ignoring empty tabs)'
); );
await BrowserTestUtils.removeTab(gBrowser.selectedTab); await BrowserTestUtils.removeTab(gBrowser.selectedTab);

View file

@ -0,0 +1,22 @@
/* Any copyright is dedicated to the Public Domain.
https://creativecommons.org/publicdomain/zero/1.0/ */
'use strict';
add_task(async function test_Glance_Next_Tab() {
const selectedTab = gBrowser.selectedTab;
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true, {
skipAnimation: true,
});
const tabToCheck = gBrowser.selectedTab;
gBrowser.selectedTab = selectedTab;
await openGlanceOnTab(async (glanceTab) => {
const next = gBrowser.tabContainer.findNextTab(glanceTab, { direction: 1 });
Assert.equal(
next,
tabToCheck,
'The glance tab should be the second normal tab (Ignoring empty tabs)'
);
});
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});

View file

@ -0,0 +1,21 @@
/* Any copyright is dedicated to the Public Domain.
https://creativecommons.org/publicdomain/zero/1.0/ */
'use strict';
add_task(async function test_Glance_Next_Tab() {
await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/' }, async (browser) => {
const tabToCheck = gBrowser.selectedTab;
await openGlanceOnTab(async (glanceTab) => {
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true, {
skipAnimation: true,
});
const next = gBrowser.tabContainer.findNextTab(glanceTab, { direction: -1 });
Assert.equal(
next,
tabToCheck,
'The glance tab should be the second normal tab (Ignoring empty tabs)'
);
});
});
});

View file

@ -2766,41 +2766,6 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature {
} }
} }
makeSurePinTabIsInCorrectPosition() {
if (!this.pinnedTabsContainer) {
return 0; // until we initialize the pinned tabs container
}
const tabsInsidePinTab = Array.from(this.pinnedTabsContainer.parentElement.children).filter(
(child) => child.tagName === 'tab'
);
let changed = false;
for (const tab of tabsInsidePinTab) {
if (tab.getAttribute('zen-glance-tab') === 'true') {
continue;
}
if (tab.getAttribute('zen-essential') === 'true') {
const container = this.getCurrentEssentialsContainer();
container.appendChild(tab);
changed = true;
continue;
}
const workspaceId = tab.getAttribute('zen-workspace-id');
if (!workspaceId) {
continue;
}
const contaienr = this.workspaceElement(workspaceId).pinnedTabsContainer;
contaienr.insertBefore(tab, contaienr.lastChild);
changed = true;
}
if (changed) {
gBrowser.tabContainer._invalidateCachedTabs();
}
// Return the number of essentials INSIDE the pinned tabs container so we can correctly change their parent
return Array.from(this.pinnedTabsContainer.children).filter(
(child) => child.getAttribute('zen-essential') === 'true'
).length;
}
// Context menu management // Context menu management
_contextMenuId = null; _contextMenuId = null;