Skip to content

Commit 6a21a6f

Browse files
committed
chore: Added some tests for container specific essentials, b=(no-bug), c=tests, workspaces
1 parent 3e53787 commit 6a21a6f

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

src/zen/tests/browser.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
["workspaces/browser_basic_workspaces.js"]
2-
2+
["workspaces/browser_container_specific_essentials.js"]
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* Any copyright is dedicated to the Public Domain.
2+
https://creativecommons.org/publicdomain/zero/1.0/ */
3+
4+
'use strict';
5+
6+
add_setup(async function () {
7+
ZenWorkspaces.containerSpecificEssentials = true;
8+
});
9+
10+
add_task(async function test_Check_Creation() {
11+
await ZenWorkspaces.createAndSaveWorkspace('Container Profile 1', undefined, false, 1);
12+
const workspaces = await ZenWorkspaces._workspaces();
13+
ok(workspaces.workspaces.length === 2, 'Two workspaces should exist.');
14+
15+
let newTab = BrowserTestUtils.addTab(gBrowser, 'about:blank', {
16+
skipAnimation: true,
17+
userContextId: 1,
18+
});
19+
ok(newTab, 'New tab should be opened.');
20+
gZenPinnedTabManager.addToEssentials(newTab);
21+
ok(
22+
gBrowser.tabs.find((t) => t.hasAttribute('zen-essential') && t.getAttribute('usercontextid') == 1),
23+
'New tab should be marked as essential.'
24+
);
25+
const newWorkspaceUUID = ZenWorkspaces.activeWorkspace;
26+
27+
// Change to the original workspace, there should be no essential tabs
28+
await ZenWorkspaces.changeWorkspace(workspaces.workspaces[0]);
29+
ok(
30+
!gBrowser.tabs.find((t) => t.hasAttribute('zen-essential') && t.getAttribute('usercontextid') == 1),
31+
'No essential tabs should be found in the original workspace.'
32+
);
33+
34+
await ZenWorkspaces.removeWorkspace(newWorkspaceUUID);
35+
});

src/zen/workspaces/ZenWorkspaces.mjs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,12 +2437,13 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
24372437
}
24382438
}
24392439

2440-
_createWorkspaceData(name, icon, tabs, moveTabs = true) {
2440+
_createWorkspaceData(name, icon, tabs, moveTabs = true, containerTabId = 0) {
24412441
let window = {
24422442
uuid: gZenUIManager.generateUuidv4(),
24432443
icon: icon,
24442444
name: name,
24452445
theme: ZenThemePicker.getTheme([]),
2446+
containerTabId,
24462447
};
24472448
if (moveTabs) {
24482449
this._prepareNewWorkspace(window);
@@ -2454,15 +2455,19 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
24542455
return window;
24552456
}
24562457

2457-
async createAndSaveWorkspace(name = 'Space', icon = undefined, dontChange = false) {
2458+
async createAndSaveWorkspace(name = 'Space', icon = undefined, dontChange = false, containerTabId = 0) {
24582459
if (!this.workspaceEnabled) {
24592460
return;
24602461
}
24612462
// get extra tabs remaning (e.g. on new profiles) and just move them to the new workspace
24622463
const extraTabs = Array.from(gBrowser.tabContainer.arrowScrollbox.children).filter(
2463-
(child) => child.tagName === 'tab' && !child.hasAttribute('zen-workspace-id')
2464+
(child) =>
2465+
child.tagName === 'tab' &&
2466+
!child.hasAttribute('zen-workspace-id') &&
2467+
!child.hasAttribute('zen-empty-tab') &&
2468+
!child.hasAttribute('zen-essential')
24642469
);
2465-
let workspaceData = this._createWorkspaceData(name, icon, extraTabs, !dontChange);
2470+
let workspaceData = this._createWorkspaceData(name, icon, extraTabs, !dontChange, containerTabId);
24662471
await this.saveWorkspace(workspaceData, dontChange);
24672472
if (!dontChange) {
24682473
this.registerPinnedResizeObserver();

0 commit comments

Comments
 (0)