test: Added tests for compact mode, b=(no-bug), c=compact-mode, tests, workspaces

This commit is contained in:
Mr. M
2025-05-11 01:38:31 +02:00
parent 1df7da7836
commit 0343430611
7 changed files with 79 additions and 60 deletions

View File

@@ -171,6 +171,13 @@ var gZenCompactModeManager = {
this._evenListeners.push(callback);
},
removeEventListener(callback) {
const index = this._evenListeners.indexOf(callback);
if (index !== -1) {
this._evenListeners.splice(index, 1);
}
},
async _updateEvent() {
// IF we are animating IN, call the callbacks first so we can calculate the width
// once the window buttons are shown

View File

@@ -0,0 +1,2 @@
["browser_compact_mode_width.js"]

View File

@@ -0,0 +1,67 @@
/* Any copyright is dedicated to the Public Domain.
https://creativecommons.org/publicdomain/zero/1.0/ */
'use strict';
function goToRightSideTabs(callback) {
return new Promise(async (resolve) => {
await SpecialPowers.pushPrefEnv({
set: [['zen.tabs.vertical.right-side', true]],
});
setTimeout(async () => {
await callback();
await SpecialPowers.popPrefEnv();
setTimeout(() => {
resolve();
}, 1000); // Wait for new layout
}, 1000); // Wait for new layout
});
}
async function testSidebarWidth() {
let resolvePromise;
const promise = new Promise((resolve) => {
resolvePromise = resolve;
});
let hasRan = false;
const ogSize = gNavToolbox.getBoundingClientRect().width;
const onCompactChanged = (event) => {
if (hasRan) {
setTimeout(() => {
gZenCompactModeManager.removeEventListener(onCompactChanged);
resolvePromise();
}, 500);
return;
}
setTimeout(() => {
const newSize = gNavToolbox.style.getPropertyValue('--zen-sidebar-width').replace('px', '');
Assert.equal(
newSize,
ogSize,
'The size of the titlebar should be the same as the original size'
);
hasRan = true;
gZenCompactModeManager.preference = false;
}, 500);
};
gZenCompactModeManager.addEventListener(onCompactChanged);
gZenCompactModeManager.preference = true;
await promise;
}
add_task(async function test_Compact_Mode_Width() {
await testSidebarWidth();
});
add_task(async function test_Compact_Mode_Width_Right_Side() {
await goToRightSideTabs(testSidebarWidth);
});
add_task(async function test_Compact_Mode_Hover() {
gNavToolbox.setAttribute('zen-has-hover', true);
await testSidebarWidth();
gNavToolbox.removeAttribute('zen-has-hover');
});

View File

@@ -1,5 +1,6 @@
BROWSER_CHROME_MANIFESTS += [
"compact_mode/browser.toml",
"container_essentials/browser.toml",
"pinned/browser.toml",
"urlbar/browser.toml",

View File

@@ -13,5 +13,6 @@ cd ./engine
zen/tests/workspaces \
zen/tests/container_essentials \
zen/tests/urlbar \
zen/tests/pinned
zen/tests/pinned \
zen/tests/compact_mode
cd ..

View File

@@ -4,4 +4,3 @@ support-files = [
]
["browser_basic_workspaces.js"]
["browser_restore_workspaces.js"]

View File

@@ -1,58 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Test that sessionrestore handles cycles in the shentry graph properly.
//
// These cycles shouldn't be there in the first place, but they cause hangs
// when they mysteriously appear (bug 687710). Docshell code assumes this
// graph is a tree and tires to walk to the root. But if there's a cycle,
// there is no root, and we loop forever.
var stateBackup = ss.getBrowserState();
var state = {
windows: [
{
tabs: [
{
entries: [
{
docIdentifier: 1,
url: 'http://example.com',
triggeringPrincipal_base64,
children: [
{
docIdentifier: 2,
url: 'http://example.com',
triggeringPrincipal_base64,
},
],
},
{
docIdentifier: 2,
url: 'http://example.com',
triggeringPrincipal_base64,
children: [
{
docIdentifier: 1,
url: 'http://example.com',
triggeringPrincipal_base64,
},
],
},
],
},
],
},
],
};
add_task(async function test() {
registerCleanupFunction(function () {
ss.setBrowserState(stateBackup);
});
/* This test fails by hanging. */
await setBrowserState(state);
ok(true, "Didn't hang!");
});