diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /toolkit/mozapps/extensions/test/browser/browser_sidebar_hidden_categories.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | toolkit/mozapps/extensions/test/browser/browser_sidebar_hidden_categories.js | 214 |
1 files changed, 214 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/browser/browser_sidebar_hidden_categories.js b/toolkit/mozapps/extensions/test/browser/browser_sidebar_hidden_categories.js new file mode 100644 index 0000000000..4cb641c2a0 --- /dev/null +++ b/toolkit/mozapps/extensions/test/browser/browser_sidebar_hidden_categories.js @@ -0,0 +1,214 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// Tests that the visible delay in showing the "Language" category occurs +// very minimally + +let gProvider; +let gInstall; +let gInstallProperties = [ + { + name: "Locale Category Test", + type: "locale", + }, +]; + +function installLocale() { + return new Promise(resolve => { + gInstall = gProvider.createInstalls(gInstallProperties)[0]; + gInstall.addTestListener({ + onInstallEnded(aInstall) { + gInstall.removeTestListener(this); + resolve(); + }, + }); + gInstall.install(); + }); +} + +async function checkCategory(win, category, { expectHidden, expectSelected }) { + await win.customElements.whenDefined("categories-box"); + + let categoriesBox = win.document.getElementById("categories"); + await categoriesBox.promiseRendered; + + let button = categoriesBox.getButtonByName(category); + is( + button.hidden, + expectHidden, + `${category} button is ${expectHidden ? "" : "not "}hidden` + ); + if (expectSelected !== undefined) { + is( + button.selected, + expectSelected, + `${category} button is ${expectSelected ? "" : "not "}selected` + ); + } +} + +add_setup(async function () { + gProvider = new MockProvider(); +}); + +add_task(async function testLocalesHiddenByDefault() { + gProvider.blockQueryResponses(); + + let viewLoaded = loadInitialView("extension", { + async loadCallback(win) { + await checkCategory(win, "locale", { expectHidden: true }); + gProvider.unblockQueryResponses(); + }, + }); + let win = await viewLoaded; + + await checkCategory(win, "locale", { expectHidden: true }); + + await installLocale(); + + await checkCategory(win, "locale", { + expectHidden: false, + expectSelected: false, + }); + + await closeView(win); +}); + +add_task(async function testLocalesShownWhenInstalled() { + gProvider.blockQueryResponses(); + + let viewLoaded = loadInitialView("extension", { + async loadCallback(win) { + await checkCategory(win, "locale", { + expectHidden: false, + expectSelected: false, + }); + gProvider.unblockQueryResponses(); + }, + }); + let win = await viewLoaded; + + await checkCategory(win, "locale", { + expectHidden: false, + expectSelected: false, + }); + + await closeView(win); +}); + +add_task(async function testLocalesHiddenWhenUninstalled() { + gInstall.cancel(); + gProvider.blockQueryResponses(); + + let viewLoaded = loadInitialView("extension", { + async loadCallback(win) { + await checkCategory(win, "locale", { + expectHidden: false, + expectSelected: false, + }); + gProvider.unblockQueryResponses(); + }, + }); + let win = await viewLoaded; + + await checkCategory(win, "locale", { expectHidden: true }); + + await closeView(win); +}); + +add_task(async function testLocalesHiddenWithoutDelay() { + gProvider.blockQueryResponses(); + + let viewLoaded = loadInitialView("extension", { + async loadCallback(win) { + await checkCategory(win, "locale", { expectHidden: true }); + gProvider.unblockQueryResponses(); + }, + }); + let win = await viewLoaded; + + await checkCategory(win, "locale", { expectHidden: true }); + + await closeView(win); +}); + +add_task(async function testLocalesShownAfterDelay() { + await installLocale(); + + gProvider.blockQueryResponses(); + + let viewLoaded = loadInitialView("extension", { + async loadCallback(win) { + await checkCategory(win, "locale", { expectHidden: true }); + gProvider.unblockQueryResponses(); + }, + }); + let win = await viewLoaded; + + await checkCategory(win, "locale", { + expectHidden: false, + expectSelected: false, + }); + + await closeView(win); +}); + +add_task(async function testLocalesShownIfPreviousView() { + gProvider.blockQueryResponses(); + + // Passing "locale" will set the last view to locales and open the view. + let viewLoaded = loadInitialView("locale", { + async loadCallback(win) { + await checkCategory(win, "locale", { + expectHidden: false, + expectSelected: true, + }); + gProvider.unblockQueryResponses(); + }, + }); + let win = await viewLoaded; + + await checkCategory(win, "locale", { + expectHidden: false, + expectSelected: true, + }); + + await closeView(win); +}); + +add_task(async function testLocalesHiddenIfPreviousViewAndNoLocales() { + gInstall.cancel(); + gProvider.blockQueryResponses(); + + // Passing "locale" will set the last view to locales and open the view. + let viewLoaded = loadInitialView("locale", { + async loadCallback(win) { + await checkCategory(win, "locale", { + expectHidden: false, + expectSelected: true, + }); + gProvider.unblockQueryResponses(); + }, + }); + let win = await viewLoaded; + + let categoryUtils = new CategoryUtilities(win); + + await TestUtils.waitForCondition( + () => categoryUtils.selectedCategory != "locale" + ); + + await checkCategory(win, "locale", { + expectHidden: true, + expectSelected: false, + }); + + is( + categoryUtils.getSelectedViewId(), + win.gViewController.defaultViewId, + "default view is selected" + ); + + await closeView(win); +}); |