summaryrefslogtreecommitdiffstats
path: root/testing/mochitest/tests/SimpleTest
diff options
context:
space:
mode:
Diffstat (limited to 'testing/mochitest/tests/SimpleTest')
-rw-r--r--testing/mochitest/tests/SimpleTest/AccessibilityUtils.js27
-rw-r--r--testing/mochitest/tests/SimpleTest/EventUtils.js4
2 files changed, 24 insertions, 7 deletions
diff --git a/testing/mochitest/tests/SimpleTest/AccessibilityUtils.js b/testing/mochitest/tests/SimpleTest/AccessibilityUtils.js
index cf4daaf416..27a0bdf1f5 100644
--- a/testing/mochitest/tests/SimpleTest/AccessibilityUtils.js
+++ b/testing/mochitest/tests/SimpleTest/AccessibilityUtils.js
@@ -614,12 +614,13 @@ this.AccessibilityUtils = (function () {
(node.tagName == "menuitem" &&
node.classList.contains("urlbarView-result-menuitem"));
+ let parentNode = node.getRootNode().host ?? node.parentNode;
const isParentMenu =
- node.parentNode.getAttribute("role") == "menu" ||
- (node.parentNode.tagName == "richlistbox" &&
- node.parentNode.classList.contains("autocomplete-richlistbox")) ||
- (node.parentNode.tagName == "menupopup" &&
- node.parentNode.classList.contains("urlbarView-result-menu"));
+ parentNode.getAttribute("role") == "menu" ||
+ (parentNode.tagName == "richlistbox" &&
+ parentNode.classList.contains("autocomplete-richlistbox")) ||
+ (parentNode.tagName == "menupopup" &&
+ parentNode.classList.contains("urlbarView-result-menu"));
return (
isMenuItem &&
isParentMenu &&
@@ -1078,6 +1079,22 @@ this.AccessibilityUtils = (function () {
}
// Walk a11y ancestors until we find one which is interactive.
for (; acc; acc = acc.parent) {
+ const relation = acc.getRelationByType(
+ Ci.nsIAccessibleRelation.RELATION_LABEL_FOR
+ );
+ if (
+ acc.role === Ci.nsIAccessibleRole.ROLE_LABEL &&
+ relation.targetsCount > 0
+ ) {
+ // If a <label> was clicked to activate a radiobutton or a checkbox,
+ // return the accessible of the related input.
+ // Note: aria-labelledby doesn't give the node a role of label, so this
+ // won't work for aria-labelledby cases. That said, aria-labelledby also
+ // doesn't have implicit click behaviour either and there's not really
+ // any way we can check for that.
+ const targetAcc = relation.getTarget(0);
+ return targetAcc;
+ }
if (INTERACTIVE_ROLES.has(acc.role)) {
return acc;
}
diff --git a/testing/mochitest/tests/SimpleTest/EventUtils.js b/testing/mochitest/tests/SimpleTest/EventUtils.js
index 8833b8bc59..59ad054714 100644
--- a/testing/mochitest/tests/SimpleTest/EventUtils.js
+++ b/testing/mochitest/tests/SimpleTest/EventUtils.js
@@ -42,8 +42,8 @@ window.__defineGetter__("_EU_ChromeUtils", function () {
window.__defineGetter__("_EU_OS", function () {
delete this._EU_OS;
try {
- this._EU_OS = _EU_ChromeUtils.import(
- "resource://gre/modules/AppConstants.jsm"
+ this._EU_OS = _EU_ChromeUtils.importESModule(
+ "resource://gre/modules/AppConstants.sys.mjs"
).platform;
} catch (ex) {
this._EU_OS = null;