fix: Fixed essential tabs appearing on private mode and updated tests, b=closes #8918, c=tabs, tests, glance, workspaces

This commit is contained in:
Mr. M
2025-06-07 18:48:44 +02:00
parent 8ef4460f00
commit bb2196900b
14 changed files with 173 additions and 41 deletions

View File

@@ -12,7 +12,14 @@ add_task(async function test_Glance_Next_Tab() {
gBrowser.selectedTab = selectedTab;
await openGlanceOnTab(async (glanceTab) => {
gBrowser.tabContainer.advanceSelectedTab(1);
Assert.equal(gBrowser.selectedTab, tabToCheck, 'Next glance tab should equal');
const nextTab = gBrowser.selectedTab;
gBrowser.selectedTab = glanceTab;
await new Promise((resolve) => {
setTimeout(() => {
Assert.equal(nextTab, tabToCheck, 'Next glance tab should equal');
resolve();
});
});
});
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});

View File

@@ -11,7 +11,14 @@ add_task(async function test_Glance_Prev_Tab() {
const tabToCheck = gBrowser.selectedTab;
gBrowser.selectedTab = glanceTab;
gBrowser.tabContainer.advanceSelectedTab(-1);
Assert.equal(gBrowser.selectedTab, tabToCheck, 'Previous glance tab should equal');
const prevTab = gBrowser.selectedTab;
gBrowser.selectedTab = glanceTab;
await new Promise((resolve) => {
setTimeout(() => {
Assert.equal(prevTab, tabToCheck, 'Previous glance tab should equal');
resolve();
});
});
await BrowserTestUtils.removeTab(tabToCheck);
});
});

View File

@@ -17,17 +17,19 @@ function openGlanceOnTab(callback, close = true) {
.then(async (glanceTab) => {
await callback(glanceTab);
if (close) {
gZenGlanceManager
.closeGlance({
onTabClose: true,
})
.then(() => {
resolve();
});
setTimeout(() => {
gZenGlanceManager
.closeGlance({
onTabClose: true,
})
.then(() => {
resolve();
});
}, 500); // Give tons of time for the glance to close
} else {
resolve();
}
});
});
}, 500); // Give tons of time for the glance to open
});
}

View File

@@ -13,5 +13,8 @@
["browser_pinned_reordered.js"]
["browser_pinned_to_essential.js"]
["browser_private_mode_no_essentials.js"]
["browser_private_mode_no_ctx_menu.js"]
["browser_issue_7654.js"]
["browser_issue_8726.js"]

View File

@@ -0,0 +1,32 @@
/* Any copyright is dedicated to the Public Domain.
https://creativecommons.org/publicdomain/zero/1.0/ */
'use strict';
add_task(async function test_Private_Mode_No_Essentials() {
let privateWindow = await BrowserTestUtils.openNewBrowserWindow({
private: true,
});
await privateWindow.gZenWorkspaces.promiseInitialized;
await BrowserTestUtils.openNewForegroundTab(privateWindow.gBrowser, 'https://example.com/', true);
await new Promise((resolve) => {
privateWindow.gBrowser.selectedTab.addEventListener('popupshown', function (event) {
ok(
privateWindow.document.getElementById('context_zen-add-essentials').hidden,
'Context menu should not show Zen Essentials option in private mode'
);
ok(
privateWindow.document.getElementById('context_pinTab').hidden,
'Context menu should not show Pin Tab option in private mode'
);
});
EventUtils.synthesizeMouseAtCenter(privateWindow.gBrowser.selectedTab, {
type: 'contextmenu',
});
});
await BrowserTestUtils.closeWindow(privateWindow);
});

View File

@@ -0,0 +1,48 @@
/* Any copyright is dedicated to the Public Domain.
https://creativecommons.org/publicdomain/zero/1.0/ */
'use strict';
add_task(async function test_Private_Mode_No_Essentials() {
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
let resolvePromise;
const promise = new Promise((resolve) => {
resolvePromise = resolve;
});
const newTab = gBrowser.selectedTab;
newTab.addEventListener(
'ZenPinnedTabCreated',
async function (event) {
ok(newTab.pinned, 'The tab should be pinned after calling gBrowser.pinTab()');
const pinTabID = newTab.getAttribute('zen-pin-id');
ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned');
try {
const pins = await ZenPinnedTabsStorage.getPins();
const pinObject = pins.find((pin) => pin.uuid === pinTabID);
ok(pinObject, 'The pin object should exist in the ZenPinnedTabsStorage');
let privateWindow = await BrowserTestUtils.openNewBrowserWindow({
private: true,
});
await privateWindow.gZenWorkspaces.promiseInitialized;
ok(
!privateWindow.gBrowser.tabs.some((tab) => tab.pinned),
'Private window should not have any pinned tabs initially'
);
await BrowserTestUtils.closeWindow(privateWindow);
} catch (error) {
ok(false, 'Error while checking the pin object in ZenPinnedTabsStorage: ' + error);
}
resolvePromise();
},
{ once: true }
);
gZenPinnedTabManager.addToEssentials(newTab);
await promise;
await BrowserTestUtils.removeTab(newTab);
});

View File

@@ -7,4 +7,6 @@ support-files = [
["browser_workspace_bookmarks.js"]
["browser_double_click_newtab.js"]
["browser_overflow_scrollbox.js"]
["browser_private_mode.js"]
["browser_private_mode_startup.js"]

View File

@@ -3,7 +3,7 @@
'use strict';
add_task(async function testPrivateMode() {
add_task(async function test_Private_Mode() {
await SpecialPowers.pushPrefEnv({
set: [['privacy.userContext.enabled', true]],
});

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_Private_Mode_Startup() {
let privateWindow = await BrowserTestUtils.openNewBrowserWindow({
private: true,
});
await privateWindow.gZenWorkspaces.promiseInitialized;
await new Promise((resolve) => {
setTimeout(() => {
Assert.equal(
privateWindow.gBrowser.tabs.length,
1,
'Private window should start with one tab'
);
resolve();
}, 1000);
});
await BrowserTestUtils.closeWindow(privateWindow);
});