From 1aaafd8cdcaa37d977206adbabc66c92d2bc7dfd Mon Sep 17 00:00:00 2001 From: James Teh Date: Mon, 16 Jun 2025 00:13:37 +0000 Subject: [PATCH] Bug 1971642: When falling back to the next valid ARIA role, use a case insensitive comparison when skipping roles. a=dmeehan We assume ARIA roles are case insensitive when setting up the role map entry. In contrast, previously, when falling back to the next valid role due to the criteria for an earlier role not being met, we were using a case sensitive comparison. This resulted in infinite recursion when an invalid role contained upper case characters because we kept trying to process the ARIA role we were already processing. To fix this, use a case sensitive comparison here, making it consistent with other ARIA role checks. Original Revision: https://phabricator.services.mozilla.com/D253617 Differential Revision: https://phabricator.services.mozilla.com/D253753 --- accessible/base/ARIAMap.cpp | 3 ++- accessible/tests/browser/role/browser_computedARIARole.js | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/accessible/base/ARIAMap.cpp b/accessible/base/ARIAMap.cpp index 8bdb102002e2..2a0dfd412ae0 100644 --- a/accessible/base/ARIAMap.cpp +++ b/accessible/base/ARIAMap.cpp @@ -1519,7 +1519,8 @@ uint8_t aria::GetFirstValidRoleMapIndexExcluding( // Skip any roles that we aren't interested in. bool shouldSkip = false; for (nsStaticAtom* atomRole : aRolesToSkip) { - if (role.Equals(atomRole->GetUTF16String())) { + if (role.Equals(atomRole->GetUTF16String(), + nsCaseInsensitiveStringComparator)) { shouldSkip = true; break; } diff --git a/accessible/tests/browser/role/browser_computedARIARole.js b/accessible/tests/browser/role/browser_computedARIARole.js index 6cc5e44aae34..f0db12dedbc4 100644 --- a/accessible/tests/browser/role/browser_computedARIARole.js +++ b/accessible/tests/browser/role/browser_computedARIARole.js @@ -19,6 +19,7 @@ addAccessibleTask(
unknown ARIA role
+
unlabelled region with fallback to group, upper case
HTML main
@@ -61,6 +62,12 @@ addAccessibleTask( testComputedARIARole("ariaRowgroup", "rowgroup"); testComputedARIARole("ariaSearchbox", "searchbox"); testComputedARIARole("ariaUnknown", "generic"); + // XXX Ideally, ariaFallbackUpperCase would be tested in + // testing/web-platform/tests/wai-aria/role/fallback-roles.html + // However, it's unclear in the spec whether ARIA roles are intended to be + // case insensitive or not, so we can't reasonably assume that in WPT until + // that's cleared up. See https://github.com/w3c/aria/issues/2548. + testComputedARIARole("ariaFallbackUpperCase", "group"); testComputedARIARole("htmlButton", "button"); // There is only a single ARIA role for buttons, but Gecko uses different // roles depending on states.