summaryrefslogtreecommitdiffstats
path: root/accessible/tests/browser/role
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /accessible/tests/browser/role
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'accessible/tests/browser/role')
-rw-r--r--accessible/tests/browser/role/browser.toml15
-rw-r--r--accessible/tests/browser/role/browser_computedARIARole.js88
-rw-r--r--accessible/tests/browser/role/browser_minimumRole.js59
-rw-r--r--accessible/tests/browser/role/head.js18
4 files changed, 180 insertions, 0 deletions
diff --git a/accessible/tests/browser/role/browser.toml b/accessible/tests/browser/role/browser.toml
new file mode 100644
index 0000000000..ac593eb0e6
--- /dev/null
+++ b/accessible/tests/browser/role/browser.toml
@@ -0,0 +1,15 @@
+[DEFAULT]
+subsuite = "a11y"
+support-files = [
+ "head.js",
+ "!/accessible/tests/browser/shared-head.js",
+ "!/accessible/tests/mochitest/*.js",
+ "!/accessible/tests/browser/*.mjs",
+]
+prefs = [
+ "javascript.options.asyncstack_capture_debuggee_only=false",
+ "dom.element.popover.enabled=true"
+]
+
+["browser_computedARIARole.js"]
+["browser_minimumRole.js"]
diff --git a/accessible/tests/browser/role/browser_computedARIARole.js b/accessible/tests/browser/role/browser_computedARIARole.js
new file mode 100644
index 0000000000..50cfe43c98
--- /dev/null
+++ b/accessible/tests/browser/role/browser_computedARIARole.js
@@ -0,0 +1,88 @@
+/* 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";
+
+addAccessibleTask(
+ `
+<div id="ariaButton" role="button">ARIA button</div>
+<div id="ariaLog" role="log">ARIA log</div>
+<div id="ariaMain" role="main">ARIA main</div>
+<div id="ariaRegion" role="region" aria-label="ARIA region">ARIA region</div>
+<nav id="ariaUnnamedRegion" role="region">ARIA unnamed region</nav>
+<div id="ariaDirectory" role="directory">ARIA directory</div>
+<div id="ariaAlertdialog" role="alertdialog">ARIA alertdialog</div>
+<div id="ariaFeed" role="feed">ARIA feed</div>
+<div id="ariaRowgroup" role="rowgroup">ARIA rowgroup</div>
+<div id="ariaSearchbox" role="searchbox">ARIA searchbox</div>
+<div id="ariaUnknown" role="unknown">unknown ARIA role</div>
+<button id="htmlButton">HTML button</button>
+<button id="toggleButton" aria-pressed="true">toggle button</button>
+<main id="htmlMain">HTML main</main>
+<header id="htmlHeader">HTML header</header>
+<section id="htmlSection">
+ <header id="htmlSectionHeader">HTML header inside section</header>
+</section>
+<section id="htmlRegion" aria-label="HTML region">HTML region</section>
+<fieldset id="htmlFieldset">HTML fieldset</fieldset>
+<table>
+ <tbody id="htmlTbody" tabindex="-1"><tr><th>HTML tbody</th></tr></tbody>
+</table>
+<table role="grid">
+ <tr>
+ <td id="htmlGridcell">HTML implicit gridcell</td>
+ </tr>
+</table>
+<div id="htmlDiv">HTML div</div>
+<span id="htmlSpan" aria-label="HTML span">HTML span</span>
+<iframe id="iframe"></iframe>
+ `,
+ async function (browser, docAcc) {
+ function testComputedARIARole(id, role) {
+ const acc = findAccessibleChildByID(docAcc, id);
+ is(acc.computedARIARole, role, `computedARIARole for ${id} is correct`);
+ }
+
+ testComputedARIARole("ariaButton", "button");
+ testComputedARIARole("ariaLog", "log");
+ // Landmarks map to a single Gecko role.
+ testComputedARIARole("ariaMain", "main");
+ testComputedARIARole("ariaRegion", "region");
+ // Unnamed ARIA regions should ignore the ARIA role.
+ testComputedARIARole("ariaUnnamedRegion", "navigation");
+ // The directory ARIA role is an alias of list.
+ testComputedARIARole("ariaDirectory", "list");
+ // alertdialog, feed, rowgroup and searchbox map to a Gecko role, but it
+ // isn't unique.
+ testComputedARIARole("ariaAlertdialog", "alertdialog");
+ testComputedARIARole("ariaFeed", "feed");
+ testComputedARIARole("ariaRowgroup", "rowgroup");
+ testComputedARIARole("ariaSearchbox", "searchbox");
+ testComputedARIARole("ariaUnknown", "generic");
+ testComputedARIARole("htmlButton", "button");
+ // There is only a single ARIA role for buttons, but Gecko uses different
+ // roles depending on states.
+ testComputedARIARole("toggleButton", "button");
+ testComputedARIARole("htmlMain", "main");
+ testComputedARIARole("htmlHeader", "banner");
+ // <section> only maps to the region ARIA role if it has a label.
+ testComputedARIARole("htmlSection", "generic");
+ // <header> only maps to the banner role if it is not a child of a
+ // sectioning element.
+ testComputedARIARole("htmlSectionHeader", "generic");
+ testComputedARIARole("htmlRegion", "region");
+ // Gecko doesn't have a rowgroup role. Ensure we differentiate for
+ // computedARIARole.
+ testComputedARIARole("htmlFieldset", "group");
+ testComputedARIARole("htmlTbody", "rowgroup");
+ // <td> inside <table role="grid"> implicitly maps to ARIA gridcell.
+ testComputedARIARole("htmlGridcell", "gridcell");
+ // Test generics.
+ testComputedARIARole("htmlDiv", "generic");
+ testComputedARIARole("htmlSpan", "generic");
+ // Some roles can't be mapped to ARIA role tokens.
+ testComputedARIARole("iframe", "");
+ },
+ { chrome: true, topLevel: true }
+);
diff --git a/accessible/tests/browser/role/browser_minimumRole.js b/accessible/tests/browser/role/browser_minimumRole.js
new file mode 100644
index 0000000000..c02c35bc9c
--- /dev/null
+++ b/accessible/tests/browser/role/browser_minimumRole.js
@@ -0,0 +1,59 @@
+/* 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";
+
+/* import-globals-from ../../mochitest/role.js */
+loadScripts({ name: "role.js", dir: MOCHITESTS_DIR });
+
+/**
+ * Test that popover gets a minimum role.
+ */
+addAccessibleTask(
+ `
+<div id="generic" popover>generic</div>
+<div id="alert" role="alert" popover>alert</div>
+<blockquote id="blockquote" popover>blockquote</div>
+ `,
+ async function testPopover(browser, docAcc) {
+ let generic = findAccessibleChildByID(docAcc, "generic");
+ ok(!generic, "generic doesn't have an Accessible");
+ info("Showing generic");
+ let shown = waitForEvent(EVENT_SHOW, "generic");
+ await invokeContentTask(browser, [], () => {
+ content.document.getElementById("generic").showPopover();
+ });
+ generic = (await shown).accessible;
+ testRole(generic, ROLE_GROUPING, "generic has minimum role group");
+ info("Setting popover to null on generic");
+ // Setting popover to null causes the Accessible to be recreated.
+ shown = waitForEvent(EVENT_SHOW, "generic");
+ await invokeContentTask(browser, [], () => {
+ content.document.getElementById("generic").popover = null;
+ });
+ generic = (await shown).accessible;
+ testRole(generic, ROLE_SECTION, "generic has generic role");
+
+ let alert = findAccessibleChildByID(docAcc, "alert");
+ ok(!alert, "alert doesn't have an Accessible");
+ info("Showing alert");
+ shown = waitForEvent(EVENT_SHOW, "alert");
+ await invokeContentTask(browser, [], () => {
+ content.document.getElementById("alert").showPopover();
+ });
+ alert = (await shown).accessible;
+ testRole(alert, ROLE_ALERT, "alert has role alert");
+
+ let blockquote = findAccessibleChildByID(docAcc, "blockquote");
+ ok(!blockquote, "blockquote doesn't have an Accessible");
+ info("Showing blockquote");
+ shown = waitForEvent(EVENT_SHOW, "blockquote");
+ await invokeContentTask(browser, [], () => {
+ content.document.getElementById("blockquote").showPopover();
+ });
+ blockquote = (await shown).accessible;
+ testRole(blockquote, ROLE_BLOCKQUOTE, "blockquote has role blockquote");
+ },
+ { chrome: true, topLevel: true }
+);
diff --git a/accessible/tests/browser/role/head.js b/accessible/tests/browser/role/head.js
new file mode 100644
index 0000000000..afc50984bd
--- /dev/null
+++ b/accessible/tests/browser/role/head.js
@@ -0,0 +1,18 @@
+/* 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";
+
+// Load the shared-head file first.
+Services.scriptloader.loadSubScript(
+ "chrome://mochitests/content/browser/accessible/tests/browser/shared-head.js",
+ this
+);
+
+// Loading and common.js from accessible/tests/mochitest/ for all tests, as
+// well as promisified-events.js.
+loadScripts(
+ { name: "common.js", dir: MOCHITESTS_DIR },
+ { name: "promisified-events.js", dir: MOCHITESTS_DIR }
+);