зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1863480: Expose all relations via xpcAccessible::GetRelations. r=morgan,devtools-reviewers,nchevobbe
Previously, only an outdated hard-coded subset was being exposed. This meant that missing relations such as details and error message were not exposed in the DevTools Accessibility Inspector. We now expose all relations in the RelationType enum so we don't need to keep this up to date. Differential Revision: https://phabricator.services.mozilla.com/D193008
This commit is contained in:
Родитель
76b13c585e
Коммит
acdf382ad2
|
@ -461,32 +461,10 @@ xpcAccessible::GetRelations(nsIArray** aRelations) {
|
|||
nsCOMPtr<nsIMutableArray> relations = do_CreateInstance(NS_ARRAY_CONTRACTID);
|
||||
NS_ENSURE_TRUE(relations, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
static const uint32_t relationTypes[] = {
|
||||
nsIAccessibleRelation::RELATION_LABELLED_BY,
|
||||
nsIAccessibleRelation::RELATION_LABEL_FOR,
|
||||
nsIAccessibleRelation::RELATION_DESCRIBED_BY,
|
||||
nsIAccessibleRelation::RELATION_DESCRIPTION_FOR,
|
||||
nsIAccessibleRelation::RELATION_NODE_CHILD_OF,
|
||||
nsIAccessibleRelation::RELATION_NODE_PARENT_OF,
|
||||
nsIAccessibleRelation::RELATION_CONTROLLED_BY,
|
||||
nsIAccessibleRelation::RELATION_CONTROLLER_FOR,
|
||||
nsIAccessibleRelation::RELATION_FLOWS_TO,
|
||||
nsIAccessibleRelation::RELATION_FLOWS_FROM,
|
||||
nsIAccessibleRelation::RELATION_MEMBER_OF,
|
||||
nsIAccessibleRelation::RELATION_SUBWINDOW_OF,
|
||||
nsIAccessibleRelation::RELATION_EMBEDS,
|
||||
nsIAccessibleRelation::RELATION_EMBEDDED_BY,
|
||||
nsIAccessibleRelation::RELATION_POPUP_FOR,
|
||||
nsIAccessibleRelation::RELATION_PARENT_WINDOW_OF,
|
||||
nsIAccessibleRelation::RELATION_DEFAULT_BUTTON,
|
||||
nsIAccessibleRelation::RELATION_CONTAINING_DOCUMENT,
|
||||
nsIAccessibleRelation::RELATION_CONTAINING_TAB_PANE,
|
||||
nsIAccessibleRelation::RELATION_CONTAINING_APPLICATION};
|
||||
|
||||
for (uint32_t idx = 0; idx < ArrayLength(relationTypes); idx++) {
|
||||
for (uint32_t type = 0; type <= static_cast<uint32_t>(RelationType::LAST);
|
||||
++type) {
|
||||
nsCOMPtr<nsIAccessibleRelation> relation;
|
||||
nsresult rv =
|
||||
GetRelationByType(relationTypes[idx], getter_AddRefs(relation));
|
||||
nsresult rv = GetRelationByType(type, getter_AddRefs(relation));
|
||||
|
||||
if (NS_SUCCEEDED(rv) && relation) {
|
||||
uint32_t targets = 0;
|
||||
|
|
|
@ -61,27 +61,43 @@ add_task(async function () {
|
|||
const labelAccessibleFront = await a11yWalker.getAccessibleFor(labelNode);
|
||||
const controlAccessibleFront = await a11yWalker.getAccessibleFor(controlNode);
|
||||
const docAccessibleFront = await a11yWalker.getAccessibleFor(walker.rootNode);
|
||||
const relations = await labelAccessibleFront.getRelations();
|
||||
is(relations.length, 2, "Accessible front has a correct number of relations");
|
||||
is(relations[0].type, "label for", "Label has a label for relation");
|
||||
is(relations[0].targets.length, 1, "Label is a label for one target");
|
||||
const labelRelations = await labelAccessibleFront.getRelations();
|
||||
is(labelRelations.length, 2, "Label has correct number of relations");
|
||||
is(labelRelations[0].type, "label for", "Label has a label for relation");
|
||||
is(labelRelations[0].targets.length, 1, "Label is a label for one target");
|
||||
is(
|
||||
relations[0].targets[0],
|
||||
labelRelations[0].targets[0],
|
||||
controlAccessibleFront,
|
||||
"Label is a label for control accessible front"
|
||||
);
|
||||
is(
|
||||
relations[1].type,
|
||||
labelRelations[1].type,
|
||||
"containing document",
|
||||
"Label has a containing document relation"
|
||||
);
|
||||
is(relations[1].targets.length, 1, "Label is contained by just one document");
|
||||
is(
|
||||
relations[1].targets[0],
|
||||
labelRelations[1].targets.length,
|
||||
1,
|
||||
"Label is contained by just one document"
|
||||
);
|
||||
is(
|
||||
labelRelations[1].targets[0],
|
||||
docAccessibleFront,
|
||||
"Label's containing document is a root document"
|
||||
);
|
||||
|
||||
const controlRelations = await controlAccessibleFront.getRelations();
|
||||
is(controlRelations.length, 3, "Control has correct number of relations");
|
||||
is(controlRelations[2].type, "details", "Control has a details relation");
|
||||
is(controlRelations[2].targets.length, 1, "Control has one details target");
|
||||
const detailsNode = await walker.querySelector(walker.rootNode, "#details");
|
||||
const detailsAccessibleFront = await a11yWalker.getAccessibleFor(detailsNode);
|
||||
is(
|
||||
controlRelations[2].targets[0],
|
||||
detailsAccessibleFront,
|
||||
"Control has correct details target"
|
||||
);
|
||||
|
||||
info("Snapshot");
|
||||
const snapshot = await controlAccessibleFront.snapshot();
|
||||
Assert.deepEqual(snapshot, {
|
||||
|
|
|
@ -44,7 +44,7 @@ add_task(async function () {
|
|||
);
|
||||
is(
|
||||
ancestry[0].children.length,
|
||||
7,
|
||||
8,
|
||||
"Root doc should have correct number of children"
|
||||
);
|
||||
ok(
|
||||
|
@ -73,7 +73,7 @@ add_task(async function () {
|
|||
|
||||
// Ensure reorder event is emitted by walker when DOM tree changes.
|
||||
let docChildren = await a11yDoc.children();
|
||||
is(docChildren.length, 7, "Root doc should have correct number of children");
|
||||
is(docChildren.length, 8, "Root doc should have correct number of children");
|
||||
|
||||
await emitA11yEvent(
|
||||
a11yWalker,
|
||||
|
@ -90,7 +90,7 @@ add_task(async function () {
|
|||
);
|
||||
|
||||
docChildren = await a11yDoc.children();
|
||||
is(docChildren.length, 8, "Root doc should have correct number of children");
|
||||
is(docChildren.length, 9, "Root doc should have correct number of children");
|
||||
|
||||
let shown = await a11yWalker.highlightAccessible(docChildren[0]);
|
||||
ok(shown, "AccessibleHighlighter highlighted the node");
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
<div id="slider" role="slider" aria-valuenow="5"
|
||||
aria-valuemin="0" aria-valuemax="7">slider</div>
|
||||
<label id="label" for="control">Label
|
||||
<input id="control">
|
||||
<input id="control" aria-details="details">
|
||||
</label>
|
||||
<div id="details">details</div>
|
||||
<header id="header">header</header>
|
||||
<nav id="nav">nav</nav>
|
||||
<footer id="footer">footer</footer>
|
||||
|
|
Загрузка…
Ссылка в новой задаче