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

This commit is contained in:
Mr. M 2025-05-22 20:22:10 +02:00
parent addc318f29
commit 15bd0b2675
No known key found for this signature in database
GPG key ID: 6292C4C8F8652B18
5 changed files with 58 additions and 25 deletions

View file

@ -80,13 +80,10 @@ add_task(async function test_Glance_New_From_essential() {
gZenPinnedTabManager.addToEssentials(selectedTab);
await openGlanceOnTab(async (glanceTab) => {
await gZenGlanceManager.fullyOpenGlance();
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true, {
skipAnimation: true,
});
Assert.equal(
glanceTab,
gBrowser.visibleTabs[2],
'The glance tab should be the second normal tab (Ignoring empty tabs)'
ok(!glanceTab.pinned, 'The glance tab should not be pinned');
ok(
!glanceTab.parentNode.hasAttribute('container'),
'The glance tab should not be in an essentials container'
);
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
BrowserTestUtils.removeTab(glanceTab);

View file

@ -12,11 +12,7 @@ add_task(async function test_Glance_Next_Tab() {
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)'
);
Assert.equal(next, tabToCheck, 'Next glance tab should equal');
});
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});

View file

@ -3,19 +3,15 @@
'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)'
);
add_task(async function test_Glance_Prev_Tab() {
await openGlanceOnTab(async (glanceTab) => {
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true, {
skipAnimation: true,
});
const tabToCheck = gBrowser.selectedTab;
gBrowser.selectedTab = glanceTab;
const next = gBrowser.tabContainer.findNextTab(glanceTab, { direction: -1 });
Assert.equal(next, tabToCheck, 'Previous glance tab should equal');
await BrowserTestUtils.removeTab(tabToCheck);
});
});

View file

@ -6,3 +6,4 @@ support-files = [
["browser_basic_workspaces.js"]
["browser_workspace_bookmarks.js"]
["browser_double_click_newtab.js"]
["browser_overflow_scrollbox.js"]

View file

@ -0,0 +1,43 @@
/* Any copyright is dedicated to the Public Domain.
https://creativecommons.org/publicdomain/zero/1.0/ */
'use strict';
add_task(async function test_Check_ScrollBox_Overflow() {
const scrollbox = gZenWorkspaces.activeScrollbox;
scrollbox.smoothScroll = false;
const tabsToRemove = [];
while (!scrollbox.overflowing) {
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
tabsToRemove.push(gBrowser.selectedTab);
}
// An extra tab to ensure the scrollbox is overflowing
await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/', true);
tabsToRemove.push(gBrowser.selectedTab);
ok(scrollbox.overflowing, 'The scrollbox should be overflowing after opening enough tabs');
ok(scrollbox.scrollPosition === 0, 'The scrollbox should be scrolled to the top');
gBrowser.selectedTab = gBrowser.tabs[gBrowser.tabs.length - 1];
await new Promise((resolve) => {
setTimeout(() => {
Assert.greater(scrollbox.scrollPosition, 0, 'The scrollbox should be scrolled to the bottom');
resolve();
}, 200);
});
gBrowser.selectedTab = gBrowser.visibleTabs[0];
await new Promise((resolve) => {
setTimeout(() => {
// TODO: Use a real scroll position check instead of a hardcoded value
Assert.less(scrollbox.scrollPosition, 60, 'The scrollbox should be scrolled to the top');
resolve();
}, 200);
});
for (const tab of tabsToRemove) {
await BrowserTestUtils.removeTab(tab);
}
});