Bug 1845228: Never descend into script or style elements when computing the accessible text equivalent of hidden subtrees. r=morgan

Differential Revision: https://phabricator.services.mozilla.com/D184452
This commit is contained in:
James Teh 2023-07-26 01:37:55 +00:00
Родитель 8ef90197a3
Коммит 055682edb3
2 изменённых файлов: 16 добавлений и 0 удалений

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

@ -263,6 +263,11 @@ nsresult nsTextEquivUtils::AppendFromDOMNode(nsIContent* aContent,
if (rv != NS_OK_NO_NAME_CLAUSE_HANDLED) return NS_OK;
if (aContent->IsAnyOfHTMLElements(nsGkAtoms::script, nsGkAtoms::style)) {
// The text within these elements is never meant for users.
return NS_OK;
}
if (aContent->IsXULElement()) {
nsAutoString textEquivalent;
if (aContent->NodeInfo()->Equals(nsGkAtoms::label, kNameSpaceID_XUL)) {

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

@ -267,6 +267,9 @@
const shadowButtonHiddenText = shadowRoot.getElementById("shadowButtonHiddenText");
testName(shadowButtonHiddenText, "shadowButtonHiddenText");
// Label from a hidden element containing script and style elements.
testName("buttonScriptStyle", "content");
SimpleTest.finish();
}
@ -751,5 +754,13 @@
const shadowRoot = shadowHost.attachShadow({ mode: "open" });
shadowRoot.append(document.getElementById("shadowTemplate").content.cloneNode(true));
</script>
<!-- aria-labelledby referring to a hidden container with script/style -->
<button id="buttonScriptStyle" aria-labelledby="hiddenScriptStyle"></button>
<div id="hiddenScriptStyle" hidden>
<script> 42; </script>
<style> .noOp {} </style>
<span>content</span>
</div>
</body>
</html>