Bug 2069276: Don't expose IA2 text interfaces for XUL boxes. r=accessibility-platform-reviewers,morgan

In general, it's expected that any container which can have TextLeafAccessible children should be a HyperTextAccessible.
Bug 1979253 enforced this even for XUL boxes.
Unfortunately, we use XUL boxes for address bar action buttons.
These don't actually contain any text.
However, because we expose IA2 text interfaces, NVDA mouse tracking looks for text and doesn't find any, causing it to report nothing.
Rather than making a special case exception for the HyperTextAccessible -> TextLeafAccessible invariant (which might cause problems on other platforms, particularly Mac), just avoid exposing the IA2 text interfaces for these elements.

Differential Revision: https://phabricator.services.mozilla.com/D324168
This commit is contained in:
James Teh
2026-09-09 01:29:48 +00:00
committed by jteh@mozilla.com
parent 1d22e25150
commit 3cc1528e15
2 changed files with 47 additions and 3 deletions
@@ -97,3 +97,37 @@ addAccessibleTask(``, async function testAddressBarTextModel() {
const attrs = await runPython(`urlBar.attributes`);
ok(attrs.includes("text-model:a1;"), "Address bar includes text-model:a1");
});
/**
* Test that HyperTextAccessible isn't used for XUL box/hbox/vbox elements;
* e.g. the address bar's action buttons. See bug 2069276.
*/
addAccessibleTask(``, async function testXulBoxNoTextInterface() {
info("Focusing address bar");
let focused = waitForEvent(EVENT_FOCUS, "urlbar-input");
gURLBar.inputField.focus();
await focused;
info("Tabbing to address bar action button");
focused = waitForEvent(
EVENT_FOCUS,
evt =>
evt.accessible.DOMNode.tagName == "hbox" &&
evt.accessible.DOMNode.role == "button"
);
EventUtils.synthesizeKey("KEY_Tab");
await focused;
ok(true, "Address bar action button got focus");
const hasTextInterface = await runPython(`
try:
toIa2(getDocIa2().accFocus).QueryInterface(IAccessibleText)
return True
except COMError:
return False
`);
ok(
!hasTextInterface,
"Address bar action button does not support IAccessibleText"
);
});
+13 -3
View File
@@ -71,9 +71,19 @@ MsaaAccessible* MsaaAccessible::Create(Accessible* aAcc) {
return new ia2AccessibleImage(aAcc);
}
if (LocalAccessible* localAcc = aAcc->AsLocal()) {
if (localAcc->GetContent() &&
localAcc->GetContent()->IsXULElement(nsGkAtoms::menuitem)) {
return new MsaaXULMenuitemAccessible(aAcc);
if (nsIContent* content = localAcc->GetContent()) {
if (content->IsXULElement(nsGkAtoms::menuitem)) {
return new MsaaXULMenuitemAccessible(aAcc);
}
if (content->IsXULElement(nsGkAtoms::box) ||
content->IsXULElement(nsGkAtoms::hbox)) {
// Bug 2069276: Exposing text interfaces for XUL boxes causes problems
// for some clients; e.g. NVDA mouse tracking on address bar action
// buttons. Generally, XUL is more like desktop UI anyway, which usually
// doesn't expose text interfaces for buttons. Therefore, don't use
// ia2AccessibleHypertext for these.
return new MsaaAccessible(aAcc);
}
}
}
if (aAcc->IsHyperText()) {