Bug 1750583: Create MOXRootGroup for all body elements without a document role r=eeejay

Differential Revision: https://phabricator.services.mozilla.com/D138174
This commit is contained in:
Morgan Reschenberg 2022-02-10 20:46:54 +00:00
parent 873cae9829
commit 56b2c85bf3
3 changed files with 53 additions and 4 deletions

View File

@ -246,12 +246,12 @@ using namespace mozilla::a11y;
- (id)rootGroup {
NSArray* children = [super moxUnignoredChildren];
if (mRole != roles::APPLICATION && [children count] == 1 &&
if (mRole == roles::DOCUMENT && [children count] == 1 &&
[[[children firstObject] moxUnignoredChildren] count] != 0) {
// We only need a root group if our document:
// (1) has multiple children, or
// (2) a one child that is a leaf, or
// (3) has a role of APPLICATION
// (3) has a role other than the default document role
return nil;
}

View File

@ -317,8 +317,7 @@ static const uint64_t kCacheInitialized = ((uint64_t)0x1) << 63;
}
id nativeParent = GetNativeFromGeckoAccessible(parent);
if (parent->Role() == roles::DOCUMENT &&
[nativeParent respondsToSelector:@selector(rootGroup)]) {
if ([nativeParent respondsToSelector:@selector(rootGroup)]) {
// Before returning a WebArea as parent, check to see if
// there is a generated root group that is an intermediate container.
if (id<mozAccessible> rootGroup = [nativeParent rootGroup]) {

View File

@ -194,3 +194,53 @@ addAccessibleTask(
);
}
);
/**
* Test document with dialog role and heading
*/
addAccessibleTask(
`<body role="dialog" aria-labelledby="h">
<h1 id="h">
We're building a richer search experience
</h1>
</body>`,
async (browser, accDoc) => {
let doc = accDoc.nativeInterface.QueryInterface(
Ci.nsIAccessibleMacInterface
);
let docChildren = doc.getAttributeValue("AXChildren");
is(docChildren.length, 1, "The document contains a root group");
let rootGroup = docChildren[0];
is(
rootGroup.getAttributeValue("AXIdentifier"),
"root-group",
"Is generated root group"
);
is(rootGroup.getAttributeValue("AXRole"), "AXGroup", "Inherits role");
is(
rootGroup.getAttributeValue("AXSubrole"),
"AXApplicationDialog",
"Inherits subrole"
);
let rootGroupChildren = rootGroup.getAttributeValue("AXChildren");
is(rootGroupChildren.length, 1, "Root group has one child");
is(
rootGroupChildren[0].getAttributeValue("AXRole"),
"AXHeading",
"Heading is child of root group"
);
// From bottom-up
let heading = getNativeInterface(accDoc, "h");
rootGroup = heading.getAttributeValue("AXParent");
is(
rootGroup.getAttributeValue("AXIdentifier"),
"root-group",
"Parent is generated root group"
);
}
);