commit ad2c5304febf56701dca0f972797eff6dfe5f606
parent f4fb3c2ef4e6383f19b633ede50187a8fdf17cf9
Author: Eitan Isaacson <eitan@monotonous.org>
Date: Mon, 3 Nov 2025 21:04:32 +0000
Bug 1997613 - Check if anchor actually has accessible. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D270901
Diffstat:
2 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/accessible/generic/LocalAccessible.cpp b/accessible/generic/LocalAccessible.cpp
@@ -2432,7 +2432,8 @@ Relation LocalAccessible::RelationByType(RelationType aType) const {
GetFrame())) {
LocalAccessible* anchorAcc =
mDoc->GetAccessible(anchorFrame->GetContent());
- if (anchorAcc->GetAnchorPositionTargetDetailsRelation() == this &&
+ if (anchorAcc &&
+ anchorAcc->GetAnchorPositionTargetDetailsRelation() == this &&
nsAccUtils::IsValidDetailsTargetForAnchor(this, anchorAcc)) {
rel.AppendTarget(anchorAcc);
}
diff --git a/accessible/tests/browser/relations/browser_anchor_positioning.js b/accessible/tests/browser/relations/browser_anchor_positioning.js
@@ -616,3 +616,50 @@ addAccessibleTask(
},
{ chrome: true, topLevel: true }
);
+
+/**
+ * Test details relations when content does not have accessibles.
+ */
+addAccessibleTask(
+ `
+ <style>
+ #btn1 {
+ anchor-name: --btn1;
+ }
+
+ #target1 {
+ position: absolute;
+ position-anchor: --btn1;
+ left: anchor(right);
+ bottom: anchor(top);
+ }
+
+ #btn2 {
+ anchor-name: --btn2;
+ }
+
+ #target2 {
+ position: absolute;
+ position-anchor: --btn2;
+ left: anchor(right);
+ bottom: anchor(top);
+ }
+ </style>
+
+ <div id="target1">World</div>
+ <button id="btn1" aria-hidden="true">Hello</button>
+
+ <div id="target2" aria-hidden="true">World</div>
+ <button id="btn2">Hello</button>
+ `,
+ async function testARIAHiddenAnchorsAndPosition(browser, docAcc) {
+ info("ARIA hidden anchor");
+ const target1 = findAccessibleChildByID(docAcc, "target1");
+ await testCachedRelation(target1, RELATION_DETAILS_FOR, []);
+
+ info("ARIA hidden target");
+ const btn2 = findAccessibleChildByID(docAcc, "btn2");
+ await testCachedRelation(btn2, RELATION_DETAILS, []);
+ },
+ { chrome: true, topLevel: true }
+);