diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /toolkit/mozapps/extensions/test/browser/browser_menu_button_accessibility.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/mozapps/extensions/test/browser/browser_menu_button_accessibility.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/browser/browser_menu_button_accessibility.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/browser/browser_menu_button_accessibility.js b/toolkit/mozapps/extensions/test/browser/browser_menu_button_accessibility.js new file mode 100644 index 0000000000..eff89cc47c --- /dev/null +++ b/toolkit/mozapps/extensions/test/browser/browser_menu_button_accessibility.js @@ -0,0 +1,81 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +async function testOpenMenu(btn, method) { + let shown = BrowserTestUtils.waitForEvent(btn.ownerGlobal, "shown", true); + await method(); + await shown; + is(btn.getAttribute("aria-expanded"), "true", "expanded when open"); +} + +async function testCloseMenu(btn, method) { + let hidden = BrowserTestUtils.waitForEvent(btn.ownerGlobal, "hidden", true); + await method(); + await hidden; + is(btn.getAttribute("aria-expanded"), "false", "not expanded when closed"); +} + +async function testButton(btn) { + let win = btn.ownerGlobal; + + is(btn.getAttribute("aria-haspopup"), "menu", "it has a menu"); + is(btn.getAttribute("aria-expanded"), "false", "not expanded"); + + info("Test open/close with mouse"); + await testOpenMenu(btn, () => { + EventUtils.synthesizeMouseAtCenter(btn, {}, win); + }); + await testCloseMenu(btn, () => { + let spacer = win.document.querySelector(".main-heading .spacer"); + EventUtils.synthesizeMouseAtCenter(spacer, {}, win); + }); + + info("Test open/close with keyboard"); + await testOpenMenu(btn, async () => { + btn.focus(); + EventUtils.synthesizeKey(" ", {}, win); + }); + await testCloseMenu(btn, () => { + EventUtils.synthesizeKey("Escape", {}, win); + }); +} + +add_task(async function testPageOptionsMenuButton() { + let win = await loadInitialView("extension"); + + await testButton( + win.document.querySelector(".page-options-menu .more-options-button") + ); + + await closeView(win); +}); + +add_task(async function testCardMoreOptionsButton() { + let id = "more-options-button@mochi.test"; + let extension = ExtensionTestUtils.loadExtension({ + manifest: { + browser_specific_settings: { gecko: { id } }, + }, + useAddonManager: "temporary", + }); + await extension.startup(); + + let win = await loadInitialView("extension"); + let card = getAddonCard(win, id); + + info("Check list page"); + await testButton(card.querySelector(".more-options-button")); + + let viewLoaded = waitForViewLoad(win); + EventUtils.synthesizeMouseAtCenter(card, {}, win); + await viewLoaded; + + info("Check detail page"); + card = getAddonCard(win, id); + await testButton(card.querySelector(".more-options-button")); + + await closeView(win); + await extension.unload(); +}); |