Bug 1720334: Represent checked/unchecked state with AXValue for treeitems r=eeejay

Differential Revision: https://phabricator.services.mozilla.com/D121215
This commit is contained in:
Morgan Reschenberg 2021-08-02 19:41:21 +00:00
Родитель 77fe82a3bb
Коммит f57cc30276
4 изменённых файлов: 75 добавлений и 1 удалений

Просмотреть файл

@ -111,7 +111,7 @@ using namespace mozilla::a11y;
static const uint64_t kCachedStates =
states::CHECKED | states::PRESSED | states::MIXED | states::EXPANDED |
states::CURRENT | states::SELECTED | states::TRAVERSED | states::LINKED |
states::HASPOPUP | states::BUSY | states::MULTI_LINE;
states::HASPOPUP | states::BUSY | states::MULTI_LINE | states::CHECKABLE;
static const uint64_t kCacheInitialized = ((uint64_t)0x1) << 63;
- (uint64_t)state {

Просмотреть файл

@ -174,6 +174,9 @@
// override
- (NSString*)moxLabel;
// override
- (id)moxValue;
// override
- (void)stateChanged:(uint64_t)state isEnabled:(BOOL)enabled;

Просмотреть файл

@ -625,6 +625,14 @@ enum CachedBool { eCachedBoolMiss, eCachedTrue, eCachedFalse };
return nsCocoaUtils::ToNSString(title);
}
- (id)moxValue {
if ([self stateWithMask:states::CHECKABLE] != 0) {
return @([self stateWithMask:states::CHECKED] != 0);
}
return nil;
}
- (void)stateChanged:(uint64_t)state isEnabled:(BOOL)enabled {
[super stateChanged:state isEnabled:enabled];

Просмотреть файл

@ -457,3 +457,66 @@ addAccessibleTask(
is(treeItems[1].getAttributeValue("AXDisclosing"), 1);
}
);
// Test outline rows correctly expose checkable, checked/unchecked status
addAccessibleTask(
`
<div role="tree" id="tree">
<div role="treeitem" aria-checked="false" id="l1">
Leaf 1
</div>
<div role="treeitem" aria-checked="true" id="l2">
Leaf 2
</div>
<div role="treeitem" id="l3">
Leaf 3
</div>
</div>
`,
async (browser, accDoc) => {
const tree = getNativeInterface(accDoc, "tree");
const treeItems = tree.getAttributeValue("AXChildren");
is(treeItems.length, 3, "Outline has three direct children");
is(
treeItems[0].getAttributeValue("AXValue"),
0,
"Child one is not checked"
);
is(treeItems[1].getAttributeValue("AXValue"), 1, "Child two is checked");
is(
treeItems[2].getAttributeValue("AXValue"),
"",
"Child three is not checkable and has no val"
);
let stateChanged = waitForEvent(EVENT_STATE_CHANGE, "l1");
await SpecialPowers.spawn(browser, [], () => {
content.document
.getElementById("l1")
.setAttribute("aria-checked", "true");
});
await stateChanged;
is(treeItems[0].getAttributeValue("AXValue"), 1, "Child one is checked");
stateChanged = waitForEvent(EVENT_STATE_CHANGE, "l2");
await SpecialPowers.spawn(browser, [], () => {
content.document.getElementById("l2").removeAttribute("aria-checked");
});
is(
treeItems[1].getAttributeValue("AXValue"),
"",
"Child two is not checkable and has no val"
);
stateChanged = waitForEvent(EVENT_STATE_CHANGE, "l3");
await SpecialPowers.spawn(browser, [], () => {
content.document
.getElementById("l3")
.setAttribute("aria-checked", "true");
});
await stateChanged;
is(treeItems[2].getAttributeValue("AXValue"), 1, "Child three is checked");
}
);