Bug 1766142: Expose explicit-name object attribute for cached RemoteAccessibles. r=morgan

The cache already includes this info.
We just needed to use it when exposing attributes to clients.

Differential Revision: https://phabricator.services.mozilla.com/D144684
This commit is contained in:
James Teh 2022-04-26 23:15:01 +00:00
Родитель 0f51d1ef7f
Коммит 7fabfd3b74
2 изменённых файлов: 33 добавлений и 0 удалений

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

@ -641,6 +641,11 @@ already_AddRefed<AccAttributes> RemoteAccessibleBase<Derived>::Attributes() {
}
}
nsAutoString name;
if (Name(name) != eNameFromSubtree && !name.IsVoid()) {
attributes->SetAttribute(nsGkAtoms::explicit_name, true);
}
return attributes.forget();
}

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

@ -231,3 +231,31 @@ addAccessibleTask(
},
{ chrome: true, topLevel: true, iframe: true, remoteIframe: true }
);
/**
* Test caching of the explicit-name attribute.
*/
addAccessibleTask(
`
<h1 id="h1">content</h1>
<button id="buttonContent">content</button>
<button id="buttonLabel" aria-label="label">content</button>
`,
async function(browser, docAcc) {
const h1 = findAccessibleChildByID(docAcc, "h1");
testAbsentAttrs(h1, { "explicit-name": "" });
const buttonContent = findAccessibleChildByID(docAcc, "buttonContent");
testAbsentAttrs(buttonContent, { "explicit-name": "" });
const buttonLabel = findAccessibleChildByID(docAcc, "buttonLabel");
testAttrs(buttonLabel, { "explicit-name": "true" }, true);
info("Setting aria-label on h1");
let nameChanged = waitForEvent(EVENT_NAME_CHANGE, h1);
await invokeContentTask(browser, [], () => {
content.document.getElementById("h1").setAttribute("aria-label", "label");
});
await nameChanged;
testAttrs(h1, { "explicit-name": "true" }, true);
},
{ chrome: true, topLevel: true, iframe: true, remoteIframe: true }
);