mirror of
https://github.com/zen-browser/desktop.git
synced 2026-04-21 14:55:37 +00:00
chore: Added some tests for container specific essentials, b=(no-bug), c=tests, workspaces
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
["workspaces/browser_basic_workspaces.js"]
|
||||
|
||||
["workspaces/browser_container_specific_essentials.js"]
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
https://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
'use strict';
|
||||
|
||||
add_setup(async function () {
|
||||
ZenWorkspaces.containerSpecificEssentials = true;
|
||||
});
|
||||
|
||||
add_task(async function test_Check_Creation() {
|
||||
await ZenWorkspaces.createAndSaveWorkspace('Container Profile 1', undefined, false, 1);
|
||||
const workspaces = await ZenWorkspaces._workspaces();
|
||||
ok(workspaces.workspaces.length === 2, 'Two workspaces should exist.');
|
||||
|
||||
let newTab = BrowserTestUtils.addTab(gBrowser, 'about:blank', {
|
||||
skipAnimation: true,
|
||||
userContextId: 1,
|
||||
});
|
||||
ok(newTab, 'New tab should be opened.');
|
||||
gZenPinnedTabManager.addToEssentials(newTab);
|
||||
ok(
|
||||
gBrowser.tabs.find((t) => t.hasAttribute('zen-essential') && t.getAttribute('usercontextid') == 1),
|
||||
'New tab should be marked as essential.'
|
||||
);
|
||||
const newWorkspaceUUID = ZenWorkspaces.activeWorkspace;
|
||||
|
||||
// Change to the original workspace, there should be no essential tabs
|
||||
await ZenWorkspaces.changeWorkspace(workspaces.workspaces[0]);
|
||||
ok(
|
||||
!gBrowser.tabs.find((t) => t.hasAttribute('zen-essential') && t.getAttribute('usercontextid') == 1),
|
||||
'No essential tabs should be found in the original workspace.'
|
||||
);
|
||||
|
||||
await ZenWorkspaces.removeWorkspace(newWorkspaceUUID);
|
||||
});
|
||||
@@ -2437,12 +2437,13 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||
}
|
||||
}
|
||||
|
||||
_createWorkspaceData(name, icon, tabs, moveTabs = true) {
|
||||
_createWorkspaceData(name, icon, tabs, moveTabs = true, containerTabId = 0) {
|
||||
let window = {
|
||||
uuid: gZenUIManager.generateUuidv4(),
|
||||
icon: icon,
|
||||
name: name,
|
||||
theme: ZenThemePicker.getTheme([]),
|
||||
containerTabId,
|
||||
};
|
||||
if (moveTabs) {
|
||||
this._prepareNewWorkspace(window);
|
||||
@@ -2454,15 +2455,19 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||
return window;
|
||||
}
|
||||
|
||||
async createAndSaveWorkspace(name = 'Space', icon = undefined, dontChange = false) {
|
||||
async createAndSaveWorkspace(name = 'Space', icon = undefined, dontChange = false, containerTabId = 0) {
|
||||
if (!this.workspaceEnabled) {
|
||||
return;
|
||||
}
|
||||
// get extra tabs remaning (e.g. on new profiles) and just move them to the new workspace
|
||||
const extraTabs = Array.from(gBrowser.tabContainer.arrowScrollbox.children).filter(
|
||||
(child) => child.tagName === 'tab' && !child.hasAttribute('zen-workspace-id')
|
||||
(child) =>
|
||||
child.tagName === 'tab' &&
|
||||
!child.hasAttribute('zen-workspace-id') &&
|
||||
!child.hasAttribute('zen-empty-tab') &&
|
||||
!child.hasAttribute('zen-essential')
|
||||
);
|
||||
let workspaceData = this._createWorkspaceData(name, icon, extraTabs, !dontChange);
|
||||
let workspaceData = this._createWorkspaceData(name, icon, extraTabs, !dontChange, containerTabId);
|
||||
await this.saveWorkspace(workspaceData, dontChange);
|
||||
if (!dontChange) {
|
||||
this.registerPinnedResizeObserver();
|
||||
|
||||
Reference in New Issue
Block a user