diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /accessible/tests/browser/general | |
parent | Initial commit. (diff) | |
download | firefox-upstream/124.0.1.tar.xz firefox-upstream/124.0.1.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | accessible/tests/browser/general/browser.toml | 13 | ||||
-rw-r--r-- | accessible/tests/browser/general/browser_test_doc_creation.js | 55 | ||||
-rw-r--r-- | accessible/tests/browser/general/browser_test_urlbar.js | 40 | ||||
-rw-r--r-- | accessible/tests/browser/general/head.js | 71 |
4 files changed, 179 insertions, 0 deletions
diff --git a/accessible/tests/browser/general/browser.toml b/accessible/tests/browser/general/browser.toml new file mode 100644 index 0000000000..95c66e0904 --- /dev/null +++ b/accessible/tests/browser/general/browser.toml @@ -0,0 +1,13 @@ +[DEFAULT] +subsuite = "a11y" +support-files = [ + "!/accessible/tests/browser/shared-head.js", + "head.js", + "!/accessible/tests/mochitest/*.js", +] +skip-if = ["a11y_checks"] +prefs = ["javascript.options.asyncstack_capture_debuggee_only=false"] + +["browser_test_doc_creation.js"] + +["browser_test_urlbar.js"] diff --git a/accessible/tests/browser/general/browser_test_doc_creation.js b/accessible/tests/browser/general/browser_test_doc_creation.js new file mode 100644 index 0000000000..7ee07f63fd --- /dev/null +++ b/accessible/tests/browser/general/browser_test_doc_creation.js @@ -0,0 +1,55 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +const tab1URL = `data:text/html, + <html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <meta charset="utf-8"/> + <title>First tab to be loaded</title> + </head> + <body> + <butotn>JUST A BUTTON</butotn> + </body> + </html>`; + +const tab2URL = `data:text/html, + <html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <meta charset="utf-8"/> + <title>Second tab to be loaded</title> + </head> + <body> + <butotn>JUST A BUTTON</butotn> + </body> + </html>`; + +// Checking that, if there are open windows before accessibility was started, +// root accessibles for open windows are created so that all root accessibles +// are stored in application accessible children array. +add_task(async function testDocumentCreation() { + let tab1 = await openNewTab(tab1URL); + let tab2 = await openNewTab(tab2URL); + let accService = await initAccessibilityService(); + + info("Verifying that each tab content document is in accessible cache."); + for (const browser of [...gBrowser.browsers]) { + await SpecialPowers.spawn(browser, [], async () => { + let accServiceContent = Cc[ + "@mozilla.org/accessibilityService;1" + ].getService(Ci.nsIAccessibilityService); + Assert.ok( + !!accServiceContent.getAccessibleFromCache(content.document), + "Document accessible is in cache." + ); + }); + } + + BrowserTestUtils.removeTab(tab1); + BrowserTestUtils.removeTab(tab2); + + accService = null; // eslint-disable-line no-unused-vars + await shutdownAccessibilityService(); +}); diff --git a/accessible/tests/browser/general/browser_test_urlbar.js b/accessible/tests/browser/general/browser_test_urlbar.js new file mode 100644 index 0000000000..5cfd66ee3a --- /dev/null +++ b/accessible/tests/browser/general/browser_test_urlbar.js @@ -0,0 +1,40 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +const { UrlbarTestUtils } = ChromeUtils.importESModule( + "resource://testing-common/UrlbarTestUtils.sys.mjs" +); + +// Checking that the awesomebar popup gets COMBOBOX_LIST role instead of +// LISTBOX, since its parent is a <panel> (see Bug 1422465) +add_task(async function testAutocompleteRichResult() { + let tab = await openNewTab("data:text/html;charset=utf-8,"); + let accService = await initAccessibilityService(); + + info("Opening the URL bar and entering a key to show the urlbar panel"); + await UrlbarTestUtils.promiseAutocompleteResultPopup({ + window, + waitForFocus, + value: "a", + }); + + info("Waiting for accessibility to be created for the results list"); + let resultsView; + resultsView = gURLBar.view.panel.querySelector(".urlbarView-results"); + await TestUtils.waitForCondition(() => + accService.getAccessibleFor(resultsView) + ); + + info("Confirming that the special case is handled in XULListboxAccessible"); + let accessible = accService.getAccessibleFor(resultsView); + is(accessible.role, ROLE_COMBOBOX_LIST, "Right role"); + + BrowserTestUtils.removeTab(tab); +}); + +registerCleanupFunction(async function () { + await shutdownAccessibilityService(); +}); diff --git a/accessible/tests/browser/general/head.js b/accessible/tests/browser/general/head.js new file mode 100644 index 0000000000..841436043c --- /dev/null +++ b/accessible/tests/browser/general/head.js @@ -0,0 +1,71 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +/* exported initAccessibilityService, openNewTab, shutdownAccessibilityService */ + +// Load the shared-head file first. +Services.scriptloader.loadSubScript( + "chrome://mochitests/content/browser/accessible/tests/browser/shared-head.js", + this +); + +const nsIAccessibleRole = Ci.nsIAccessibleRole; // eslint-disable-line no-unused-vars + +/* import-globals-from ../../mochitest/role.js */ +loadScripts({ name: "role.js", dir: MOCHITESTS_DIR }); + +async function openNewTab(url) { + const forceNewProcess = true; + + return BrowserTestUtils.openNewForegroundTab({ + gBrowser, + url, + forceNewProcess, + }); +} + +async function initAccessibilityService() { + info("Create accessibility service."); + let accService = Cc["@mozilla.org/accessibilityService;1"].getService( + Ci.nsIAccessibilityService + ); + + await new Promise(resolve => { + if (Services.appinfo.accessibilityEnabled) { + resolve(); + return; + } + + let observe = (subject, topic, data) => { + if (data === "1") { + Services.obs.removeObserver(observe, "a11y-init-or-shutdown"); + resolve(); + } + }; + Services.obs.addObserver(observe, "a11y-init-or-shutdown"); + }); + + return accService; +} + +function shutdownAccessibilityService() { + forceGC(); + + return new Promise(resolve => { + if (!Services.appinfo.accessibilityEnabled) { + resolve(); + return; + } + + let observe = (subject, topic, data) => { + if (data === "0") { + Services.obs.removeObserver(observe, "a11y-init-or-shutdown"); + resolve(); + } + }; + Services.obs.addObserver(observe, "a11y-init-or-shutdown"); + }); +} |