Bug 1672243 - Introduce AXIndexForChildUIElement and implement AXTopLevelUIElement. r=MarcoZ

AXTopLevelUIElement is not really testable because it doesn't give a useful result in
headless mode. Since it is a clone of AXWindow, this shouldn't be much of an issue.

Differential Revision: https://phabricator.services.mozilla.com/D94154
This commit is contained in:
Eitan Isaacson 2020-10-22 17:12:39 +00:00
parent b7133788f4
commit 0e6061d30d
5 changed files with 47 additions and 0 deletions

View File

@ -114,6 +114,12 @@ inline id<mozAccessible> GetObjectOrRepresentedView(id<mozAccessible> aObject) {
// override
- (id<mozAccessible>)moxParent;
// override
- (NSNumber*)moxIndexForChildUIElement:(id)child;
// override
- (id)moxTopLevelUIElement;
// override
- (id<MOXTextMarkerSupport>)moxTextMarkerDelegate;

View File

@ -398,6 +398,14 @@ mozilla::LogModule* GetMacAccessibilityLog() {
#pragma mark - MOXAccessible protocol
- (NSNumber*)moxIndexForChildUIElement:(id)child {
return @([[self moxUnignoredChildren] indexOfObject:child]);
}
- (id)moxTopLevelUIElement {
return [self moxWindow];
}
- (id)moxHitTest:(NSPoint)point {
return GetObjectOrRepresentedView(self);
}

View File

@ -345,6 +345,9 @@
// AXCellForColumnAndRow
- (id _Nullable)moxCellForColumnAndRow:(NSArray* _Nonnull)columnAndRow;
// AXIndexForChildUIElement
- (NSNumber* _Nullable)moxIndexForChildUIElement:(id _Nonnull)child;
@end
// This protocol maps text marker and text marker range parameters to

View File

@ -37,3 +37,4 @@ skip-if = os == 'mac' && debug # Bug 1664577
[browser_rootgroup.js]
[browser_text_selection.js]
[browser_navigate.js]
[browser_hierarchy.js]

View File

@ -0,0 +1,29 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/**
* Test AXIndexForChildUIElement
*/
addAccessibleTask(
`<p id="p">Hello <a href="#" id="link">strange</a> world`,
(browser, accDoc) => {
let p = getNativeInterface(accDoc, "p");
let children = p.getAttributeValue("AXChildren");
is(children.length, 3, "p has 3 children");
is(
children[1].getAttributeValue("AXDOMIdentifier"),
"link",
"second child is link"
);
let index = p.getParameterizedAttributeValue(
"AXIndexForChildUIElement",
children[1]
);
is(index, 1, "link is second child");
}
);