mirror of
https://github.com/zen-browser/desktop.git
synced 2025-09-05 19:08:18 +00:00
Add initial test for basic workspace change and refactor empty tab initialization
This commit is contained in:
@@ -36,6 +36,10 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||
this._resolveInitialized = resolve;
|
||||
});
|
||||
|
||||
promiseEmptyTabInitialized = new Promise((resolve) => {
|
||||
this._resolveEmptyTabInitialized = resolve;
|
||||
});
|
||||
|
||||
workspaceIndicatorXUL = `
|
||||
<hbox class="zen-current-workspace-indicator-icon"></hbox>
|
||||
<hbox class="zen-current-workspace-indicator-name"></hbox>
|
||||
@@ -603,16 +607,19 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||
} catch (e) {
|
||||
console.error('ZenWorkspaces: Error initializing theme picker', e);
|
||||
}
|
||||
this._selectStartPage();
|
||||
await this._selectStartPage();
|
||||
this._fixTabPositions();
|
||||
this._resolveInitialized();
|
||||
this._clearAnyZombieTabs(); // Dont call with await
|
||||
}
|
||||
}
|
||||
|
||||
_selectStartPage() {
|
||||
async _selectStartPage() {
|
||||
const currentTab = gBrowser.selectedTab;
|
||||
let showed = false;
|
||||
await this.promiseEmptyTabInitialized;
|
||||
this._resolveEmptyTabInitialized = null;
|
||||
this.promiseEmptyTabInitialized = null;
|
||||
if (currentTab.pinned) {
|
||||
this.selectEmptyTab();
|
||||
try {
|
||||
|
2
src/browser/base/zen-components/tests/browser.toml
Normal file
2
src/browser/base/zen-components/tests/browser.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
["basic-workspace-change.js"]
|
||||
|
@@ -0,0 +1,8 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
https://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function test_TODO() {
|
||||
ok(true, "TODO: implement the test");
|
||||
});
|
@@ -1,5 +1,5 @@
|
||||
diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
|
||||
index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af66b0495e 100644
|
||||
index fa96568d366fd3608f9bd583fa793150bd815c8b..89a3d8d63a045433f15fae37c8f5df2a84f01452 100644
|
||||
--- a/browser/components/tabbrowser/content/tabs.js
|
||||
+++ b/browser/components/tabbrowser/content/tabs.js
|
||||
@@ -94,7 +94,7 @@
|
||||
@@ -11,15 +11,16 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -135,6 +135,7 @@
|
||||
@@ -135,6 +135,8 @@
|
||||
this.previewPanel = null;
|
||||
|
||||
this.allTabs[0].label = this.emptyTabTitle;
|
||||
+ this.allTabs[0]._possibleEmptyTab = true;
|
||||
+ ZenWorkspaces._resolveEmptyTabInitialized();
|
||||
|
||||
// Hide the secondary text for locales where it is unsupported due to size constraints.
|
||||
const language = Services.locale.appLocaleAsBCP47;
|
||||
@@ -339,7 +340,7 @@
|
||||
@@ -339,7 +341,7 @@
|
||||
// and we're not hitting the scroll buttons.
|
||||
if (
|
||||
event.button != 0 ||
|
||||
@@ -28,7 +29,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
event.composedTarget.localName == "toolbarbutton"
|
||||
) {
|
||||
return;
|
||||
@@ -388,6 +389,7 @@
|
||||
@@ -388,6 +390,7 @@
|
||||
// Reset the "ignored click" flag
|
||||
target._ignoredCloseButtonClicks = false;
|
||||
}
|
||||
@@ -36,7 +37,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
}
|
||||
|
||||
/* Protects from close-tab-button errant doubleclick:
|
||||
@@ -683,7 +685,7 @@
|
||||
@@ -683,7 +686,7 @@
|
||||
if (this.#isContainerVerticalPinnedExpanded(tab)) {
|
||||
// In expanded vertical mode, the max number of pinned tabs per row is dynamic
|
||||
// Set this before adjusting dragged tab's position
|
||||
@@ -45,7 +46,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
let tabsPerRow = 0;
|
||||
let position = 0;
|
||||
for (let pinnedTab of pinnedTabs) {
|
||||
@@ -883,6 +885,10 @@
|
||||
@@ -883,6 +886,10 @@
|
||||
}
|
||||
|
||||
let draggedTab = event.dataTransfer.mozGetDataAt(TAB_DROP_TYPE, 0);
|
||||
@@ -56,7 +57,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
if (
|
||||
(effects == "move" || effects == "copy") &&
|
||||
this == draggedTab.container &&
|
||||
@@ -996,6 +1002,18 @@
|
||||
@@ -996,6 +1003,18 @@
|
||||
|
||||
this._tabDropIndicator.hidden = true;
|
||||
event.stopPropagation();
|
||||
@@ -75,7 +76,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
if (draggedTab && dropEffect == "copy") {
|
||||
// copy the dropped tab (wherever it's from)
|
||||
let newIndex = this._getDropIndex(event);
|
||||
@@ -1034,10 +1052,11 @@
|
||||
@@ -1034,10 +1053,11 @@
|
||||
}
|
||||
} else {
|
||||
let pinned = draggedTab.pinned;
|
||||
@@ -91,7 +92,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
);
|
||||
let size = this.verticalMode ? "height" : "width";
|
||||
let screenAxis = this.verticalMode ? "screenY" : "screenX";
|
||||
@@ -1114,7 +1133,7 @@
|
||||
@@ -1114,7 +1134,7 @@
|
||||
let postTransitionCleanup = () => {
|
||||
tab.removeAttribute("tabdrop-samewindow");
|
||||
|
||||
@@ -100,7 +101,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
if (dropIndex !== false) {
|
||||
gBrowser.moveTabTo(tab, dropIndex);
|
||||
if (!directionForward) {
|
||||
@@ -1122,7 +1141,7 @@
|
||||
@@ -1122,7 +1142,7 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -109,7 +110,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
postTransitionCleanup();
|
||||
} else {
|
||||
let onTransitionEnd = transitionendEvent => {
|
||||
@@ -1249,7 +1268,7 @@
|
||||
@@ -1249,7 +1269,7 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -118,7 +119,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
gBrowser.loadTabs(urls, {
|
||||
inBackground,
|
||||
replace,
|
||||
@@ -1279,13 +1298,23 @@
|
||||
@@ -1279,13 +1299,23 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -144,7 +145,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
) {
|
||||
delete draggedTab._dragData;
|
||||
return;
|
||||
@@ -1517,7 +1546,7 @@
|
||||
@@ -1517,7 +1547,7 @@
|
||||
}
|
||||
|
||||
get newTabButton() {
|
||||
@@ -153,7 +154,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
}
|
||||
|
||||
get verticalMode() {
|
||||
@@ -1537,28 +1566,40 @@
|
||||
@@ -1537,28 +1567,40 @@
|
||||
if (this.#allTabs) {
|
||||
return this.#allTabs;
|
||||
}
|
||||
@@ -202,7 +203,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
return children.filter(node => node.tagName == "tab-group");
|
||||
}
|
||||
|
||||
@@ -1579,7 +1620,7 @@
|
||||
@@ -1579,7 +1621,7 @@
|
||||
*/
|
||||
get visibleTabs() {
|
||||
if (!this.#visibleTabs) {
|
||||
@@ -211,7 +212,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
}
|
||||
return this.#visibleTabs;
|
||||
}
|
||||
@@ -1613,10 +1654,8 @@
|
||||
@@ -1613,10 +1655,8 @@
|
||||
return this.#focusableItems;
|
||||
}
|
||||
|
||||
@@ -224,7 +225,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
|
||||
let focusableItems = [];
|
||||
for (let child of children) {
|
||||
@@ -1632,6 +1671,7 @@
|
||||
@@ -1632,6 +1672,7 @@
|
||||
}
|
||||
|
||||
this.#focusableItems = [
|
||||
@@ -232,7 +233,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
...verticalPinnedTabsContainer.children,
|
||||
...focusableItems,
|
||||
];
|
||||
@@ -1642,6 +1682,7 @@
|
||||
@@ -1642,6 +1683,7 @@
|
||||
_invalidateCachedTabs() {
|
||||
this.#allTabs = null;
|
||||
this._invalidateCachedVisibleTabs();
|
||||
@@ -240,7 +241,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
}
|
||||
|
||||
_invalidateCachedVisibleTabs() {
|
||||
@@ -1656,8 +1697,8 @@
|
||||
@@ -1656,8 +1698,8 @@
|
||||
#isContainerVerticalPinnedExpanded(tab) {
|
||||
return (
|
||||
this.verticalMode &&
|
||||
@@ -251,7 +252,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1672,7 +1713,7 @@
|
||||
@@ -1672,7 +1714,7 @@
|
||||
|
||||
if (node == null) {
|
||||
// We have a container for non-tab elements at the end of the scrollbox.
|
||||
@@ -260,7 +261,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
}
|
||||
|
||||
node.before(tab);
|
||||
@@ -1772,7 +1813,7 @@
|
||||
@@ -1772,7 +1814,7 @@
|
||||
// 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);
|
||||
// Attach the long click popup to all of them.
|
||||
@@ -269,7 +270,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
const newTab2 = this.newTabButton;
|
||||
const newTabVertical = document.getElementById(
|
||||
"vertical-tabs-newtab-button"
|
||||
@@ -1855,7 +1896,7 @@
|
||||
@@ -1855,7 +1897,7 @@
|
||||
let rect = ele => {
|
||||
return window.windowUtils.getBoundsWithoutFlushing(ele);
|
||||
};
|
||||
@@ -278,7 +279,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
if (tab && rect(tab).width <= this._tabClipWidth) {
|
||||
this.setAttribute("closebuttons", "activetab");
|
||||
} else {
|
||||
@@ -1867,10 +1908,12 @@
|
||||
@@ -1867,10 +1909,12 @@
|
||||
|
||||
_handleTabSelect(aInstant) {
|
||||
let selectedTab = this.selectedItem;
|
||||
@@ -291,7 +292,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
selectedTab._notselectedsinceload = false;
|
||||
}
|
||||
|
||||
@@ -1882,7 +1925,7 @@
|
||||
@@ -1882,7 +1926,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -300,7 +301,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
if (!tabs.length) {
|
||||
return;
|
||||
}
|
||||
@@ -1918,7 +1961,7 @@
|
||||
@@ -1918,7 +1962,7 @@
|
||||
if (isEndTab && !this._hasTabTempMaxWidth) {
|
||||
return;
|
||||
}
|
||||
@@ -309,7 +310,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
// Force tabs to stay the same width, unless we're closing the last tab,
|
||||
// which case we need to let them expand just enough so that the overall
|
||||
// tabbar width is the same.
|
||||
@@ -1933,7 +1976,7 @@
|
||||
@@ -1933,7 +1977,7 @@
|
||||
let tabsToReset = [];
|
||||
for (let i = numPinned; i < tabs.length; i++) {
|
||||
let tab = tabs[i];
|
||||
@@ -318,7 +319,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
if (!isEndTab) {
|
||||
// keep tabs the same width
|
||||
tab.style.transition = "none";
|
||||
@@ -1999,16 +2042,15 @@
|
||||
@@ -1999,16 +2043,15 @@
|
||||
// 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.
|
||||
@@ -341,7 +342,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2016,9 +2058,7 @@
|
||||
@@ -2016,9 +2059,7 @@
|
||||
}
|
||||
|
||||
_resetVerticalPinnedTabs() {
|
||||
@@ -352,7 +353,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
|
||||
if (!verticalTabsContainer.children.length) {
|
||||
return;
|
||||
@@ -2031,8 +2071,8 @@
|
||||
@@ -2031,8 +2072,8 @@
|
||||
}
|
||||
|
||||
_positionPinnedTabs() {
|
||||
@@ -363,7 +364,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
let absPositionHorizontalTabs =
|
||||
this.overflowing && tabs.length > numPinned && numPinned > 0;
|
||||
|
||||
@@ -2041,7 +2081,7 @@
|
||||
@@ -2041,7 +2082,7 @@
|
||||
|
||||
if (this.verticalMode) {
|
||||
this._updateVerticalPinnedTabs();
|
||||
@@ -372,7 +373,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
let layoutData = this._pinnedTabsLayoutCache;
|
||||
let uiDensity = document.documentElement.getAttribute("uidensity");
|
||||
if (!layoutData || layoutData.uiDensity != uiDensity) {
|
||||
@@ -2113,7 +2153,7 @@
|
||||
@@ -2113,7 +2154,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -381,7 +382,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
|
||||
let directionX = screenX > dragData.animLastScreenX;
|
||||
let directionY = screenY > dragData.animLastScreenY;
|
||||
@@ -2121,7 +2161,7 @@
|
||||
@@ -2121,7 +2162,7 @@
|
||||
dragData.animLastScreenX = screenX;
|
||||
|
||||
let { width: tabWidth, height: tabHeight } =
|
||||
@@ -390,7 +391,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
let shiftSizeX = tabWidth * movingTabs.length;
|
||||
let shiftSizeY = tabHeight;
|
||||
dragData.tabWidth = tabWidth;
|
||||
@@ -2296,10 +2336,11 @@
|
||||
@@ -2296,10 +2337,11 @@
|
||||
}
|
||||
|
||||
let pinned = draggedTab.pinned;
|
||||
@@ -406,7 +407,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
);
|
||||
|
||||
if (this.#rtlMode) {
|
||||
@@ -2348,7 +2389,11 @@
|
||||
@@ -2348,7 +2390,11 @@
|
||||
translate = Math.min(Math.max(translate, firstBound), lastBound);
|
||||
|
||||
for (let tab of movingTabs) {
|
||||
@@ -419,7 +420,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
}
|
||||
|
||||
dragData.translatePos = translate;
|
||||
@@ -2484,12 +2529,16 @@
|
||||
@@ -2484,12 +2530,16 @@
|
||||
// Shift background tabs to leave a gap where the dragged tab
|
||||
// would currently be dropped.
|
||||
for (let tab of tabs) {
|
||||
@@ -437,7 +438,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
if (tab.group?.tabs[0] == tab) {
|
||||
tab.group.style.setProperty(
|
||||
"--tabgroup-dragover-transform",
|
||||
@@ -2541,8 +2590,9 @@
|
||||
@@ -2541,8 +2591,9 @@
|
||||
);
|
||||
}
|
||||
|
||||
@@ -449,7 +450,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2553,6 +2603,7 @@
|
||||
@@ -2553,6 +2604,7 @@
|
||||
tab.style.transform = "";
|
||||
if (tab.group) {
|
||||
tab.group.style.removeProperty("--tabgroup-dragover-transform");
|
||||
@@ -457,7 +458,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
}
|
||||
tab.removeAttribute("dragover-createGroup");
|
||||
}
|
||||
@@ -2604,7 +2655,7 @@
|
||||
@@ -2604,7 +2656,7 @@
|
||||
movingTab._moveTogetherSelectedTabsData.newIndex = movingTabNewIndex;
|
||||
movingTab._moveTogetherSelectedTabsData.animate = false;
|
||||
};
|
||||
@@ -466,7 +467,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
postTransitionCleanup();
|
||||
} else {
|
||||
let onTransitionEnd = transitionendEvent => {
|
||||
@@ -2707,9 +2758,9 @@
|
||||
@@ -2707,9 +2759,9 @@
|
||||
function newIndex(aTab, index) {
|
||||
// Don't allow mixing pinned and unpinned tabs.
|
||||
if (aTab.pinned) {
|
||||
@@ -478,7 +479,7 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..a13d501f2f0f190b9dc8fe0ce4f1d7af
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2793,7 +2844,7 @@
|
||||
@@ -2793,7 +2845,7 @@
|
||||
}
|
||||
|
||||
_notifyBackgroundTab(aTab) {
|
||||
|
Reference in New Issue
Block a user