Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[accname] Require specification of subtest count #42769

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion accname/name/comp_embedded_control.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@


<script>
AriaUtils.verifyLabelsBySelector(".ex");
AriaUtils.verifyLabelsBySelector(26, ".ex");
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion accname/name/comp_hidden_not_referenced.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<!-- that are both not rendered and excluded from the a11y tree. -->

<script>
AriaUtils.verifyLabelsBySelector(".ex");
AriaUtils.verifyLabelsBySelector(5, ".ex");
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion accname/name/comp_host_language_label.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ <h2>SVG title</h2>
<!-- todo: does HTML input[placeholder="foo"] count as a host language labeling mechanism? -->

<script>
AriaUtils.verifyLabelsBySelector(".ex");
AriaUtils.verifyLabelsBySelector(46, ".ex");
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion accname/name/comp_label.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<!-- Todo: test all remaining cases of https://w3c.github.io/accname/#comp_label -->

<script>
AriaUtils.verifyLabelsBySelector(".ex");
AriaUtils.verifyLabelsBySelector(1, ".ex");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below... Keep comp_label.html as-is (but with a warning) to make way for #41463

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jugglinmike #41463 was also merged since the the time this was filed.

</script>
</body>
</html>
2 changes: 1 addition & 1 deletion accname/name/comp_labelledby.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h2 id="h">div group label</h2>
-->

<script>
AriaUtils.verifyLabelsBySelector(".ex");
AriaUtils.verifyLabelsBySelector(1, ".ex");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below... Keep comp_labelledby.html as-is (but with a warning) to make way for #42522

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#42522 was since merged so it's no longer necessary to leave this change out of the PR, but it should get the mentioned argument order change, and will need an update to the expectedCount integer.

</script>
</body>
</html>
2 changes: 1 addition & 1 deletion accname/name/comp_name_from_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ <h3 data-expectedlabel="one two three" data-testname="heading name from content
<br>

<script>
AriaUtils.verifyLabelsBySelector(".ex");
AriaUtils.verifyLabelsBySelector(53, ".ex");
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion accname/name/comp_text_node.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h2 class="ex" data-expectedlabel="heading label" data-testname="heading with te
<!-- Todo: test all remaining cases of https://w3c.github.io/accname/#comp_text_node -->

<script>
AriaUtils.verifyLabelsBySelector(".ex");
AriaUtils.verifyLabelsBySelector(1, ".ex");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below... Keep comp_text_node.html as-is (but with a warning) to make way for #42407

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#42407 was since merged so it's no longer necessary to leave this change out of the PR, but it should get the mentioned argument order change, and will need an update to the expectedCount integer.

</script>
</body>
</html>
2 changes: 1 addition & 1 deletion accname/name/comp_tooltip.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<iframe title="label" data-expectedlabel="label" data-testname="iframe with tooltip label" width="20px" height="20px" class="ex"></iframe>

<script>
AriaUtils.verifyLabelsBySelector(".ex");
AriaUtils.verifyLabelsBySelector(19, ".ex");
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion accname/name/shadowdom/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
document.getElementById('host1').attachShadow({ mode: 'open' }).innerHTML = 'foo';
document.getElementById('host2').attachShadow({ mode: 'open' }).innerHTML = '<div aria-label="bar"></div>';

AriaUtils.verifyLabelsBySelector('.labelled');
AriaUtils.verifyLabelsBySelector(2, '.labelled');

</script>
2 changes: 1 addition & 1 deletion accname/name/shadowdom/slot.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@
document.getElementById('host3').attachShadow({ mode: 'open' }).innerHTML = 'foo <slot aria-label="label"></slot> bar';
document.getElementById('host4').attachShadow({ mode: 'open' }).innerHTML = 'foo <slot aria-label="label">default</slot> bar';

AriaUtils.verifyLabelsBySelector('.labelled');
AriaUtils.verifyLabelsBySelector(4, '.labelled');

</script>
8 changes: 4 additions & 4 deletions wai-aria/scripts/aria-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ const AriaUtils = {
data-expectedlabel="foo"
class="ex">

AriaUtils.verifyLabelsBySelector(".ex")
AriaUtils.verifyLabelsBySelector(1, ".ex")

*/
verifyLabelsBySelector: function(selector) {
verifyLabelsBySelector: function(expectedCount, selector) {
const els = document.querySelectorAll(selector);
if (!els.length) {
throw `Selector passed in verifyLabelsBySelector("${selector}") should match at least one element.`;
if (els.length !== expectedCount) {
throw `verifyLabelsBySelector expected ${expectedCount} elements but received ${els.length}`;
Comment on lines +130 to +133
Copy link
Contributor

@cookiecrook cookiecrook Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for filing this! I agree it's a good move to be more explicit about the expectations.

However, this is going to break a few outstanding PRs that expect selector to be first... I also would prefer selector remain the first argument (as the method name implies) and throw a warning if a count is not provided. And the error only if it is provided but doesn't match.

comp_label.html, comp_labelledby.html, and comp_text_node.html could then be left out of this PR to avoid conflicts/breakage with the outstanding PRs. They would throw a warning but not an error, and if this lands first, we could then update the other files in those PRs (or later ones) to use the optional-but-recommended expectedCount.

}
for (const el of els) {
let label = el.getAttribute("data-expectedlabel");
Expand Down