Skip to content

Add tests for accnames from hidden labels, captions, and legends - #44965

Open
adampage wants to merge 22 commits into
web-platform-tests:masterfrom
adampage:html-aam-hidden-names
Open

Add tests for accnames from hidden labels, captions, and legends#44965
adampage wants to merge 22 commits into
web-platform-tests:masterfrom
adampage:html-aam-hidden-names

Conversation

@adampage

@adampage adampage commented Mar 7, 2024

Copy link
Copy Markdown
Member

Accname tests to support w3c/html-aam#533’s clarification that hidden labels, captions, and legends will not provide an accname to their naturally associated elements unless they are explicitly referenced using aria-labelledby.

@adampage
adampage marked this pull request as draft March 7, 2024 18:22

@cookiecrook cookiecrook left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks okay to me, but not merging immediately since we only got one CI run.

@scottaohara

Copy link
Copy Markdown
Contributor

would this PR be the place to also create the tests for how browsers should use other naming mechanisms if these elements are hidden?

e.g.,

<label for=d hidden>
  this should not be used, cause it'll return the empty string
</label>
<input id=d title="this should be used">

@adampage

Copy link
Copy Markdown
Member Author

would this PR be the place to also create the tests for how browsers should use other naming mechanisms if these elements are hidden?

So... I took ☝🏻 this ball and ran with it... maybe in the wrong direction. 😵‍💫

I focused on HTML-AAM’s “4.1 Accname computation by element” section and wrote/copypasta’d a boatload of new tests for each specific element identified there.

Every test specimen follows the same pattern: I simultaneously throw all possible accname techniques at the element, then I assert which one should win based on the conditionals described in the spec. Next, I eliminate 1 technique at a time for subsequent test specimens, rinse and repeat until the element has no remaining accname candidates.

I took a few notes along the way for a few tweaks I might propose in the HTML-AAM spec. I also left 2 sections incomplete:

Anyhow, I’ll pause here. The test results are interesting. Please let me know what you think, @scottaohara / @cookiecrook.

@cookiecrook cookiecrook left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Updating because this PR increased in scope since my last review. I shared offline feedback with Adam: mainly that the numbered directories might be fragile (as the spec changes) and that they may complicate the browsing experience on wpt.fyi. He also plans to utilize a new JavaScript convenience method to reduce some of the markup duplication.

@adampage

Copy link
Copy Markdown
Member Author

Alrightey, @cookiecrook and @scottaohara, I just committed a monster of an update. 😬

This change:

Now that the subtests are being built dynamically, I was able to quickly introduce a bunch more name-supporting HTML elements that I‘d neglected in my previous push (e.g., <thead>, <progress>, <hr> 🤯 , <input type="color">, etc.).

As a result, the number of subtests have almost doubled from 276 to 510.

I also scattered a few TODO notes around, such as this bit about phrasing elements which I think dovetails with ARIA issues you’ve filed recently, @scottaohara / @rahimabdi. Many of these notes will require deeper investigation on my part. I’m hoping most of them will be resolved either by:

  1. Proposing updates to the HTML-AAM spec itself
  2. Updating/removing specific test expectations
  3. Accepting a failed test result and filing browser bugs

There are also a number of tests that are failing because of web driver errors, such as <optgroup>. I’m not sure what do with those, if anything?

At the end of all of this, I’m looking at HTML-AAM’s Accessible Name Computations By HTML Element section and thinking it could be simplified. Most of the computation steps follow a very linear path through a prioritized set of potential naming sources. My gut says we can define a very small number of “rule sets” and then make a table to pair each nameable HTML element with one of those rule sets. cc: @rahimabdi

@adampage
adampage requested a review from cookiecrook May 29, 2024 01:30

@cookiecrook cookiecrook left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

incomplete review, and I plan to come back to it, but wanted to share feedback as I can since my work time is limited.

Comment thread accname/name/comp_hidden_not_referenced.html
Comment thread html-aam/scripts/html-aam-accname-utils.js Outdated
Comment thread html-aam/accname-computation-by-element/figure.html Outdated
Comment thread html-aam/accname-computation-by-element/input-image.html
@cookiecrook

Copy link
Copy Markdown
Contributor

Bulk edit of stale PRs... If you're the original submitter or assignee, will you dig back through the history and determine what the next steps are? Thanks.

Comment thread html-aam/accname-computation-by-element/figure.html Outdated
Comment thread html-aam/accname-computation-by-element/img.html

@scottaohara scottaohara left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

did a quick review of this with @rahimabdi today. some new comments for you @adampage (for when you have time to look, again)

@adampage

Copy link
Copy Markdown
Member Author

Awesome, thanks very much, @scottaohara and @rahimabdi. I’m keen to land this one. I’ll make time within the next couple weeks to review and update.

@adampage

Copy link
Copy Markdown
Member Author

Heya @scottaohara / @rahimabdi / @giacomo-petri / @cookiecrook, thank you for your reviews, and apologies for taking so long to get back this. I’ve reviewed the last year’s (🤯) worth of feedback and made these 3 updates:

  1. Removed figcaption as a name source for figurelatest results
  2. Added figcaption as a name source for an imgelement with afigure` ancestor — only Safari passes
  3. Added aria-placeholder as a name source after placeholder — only Firefox fails

Here’s the latest browser results for the complete set.

@rahimabdi
rahimabdi self-requested a review June 30, 2026 17:31
@rahimabdi

Copy link
Copy Markdown
Contributor

LGTM, thank you very much @adampage!

I especially like the html-aam/scripts/html-aam-accname-utils.js utils which should make future testing easier.

@giacomo-petri giacomo-petri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For a potential follow-up PR, since we've added specific scenarios, it might be worth considering scenarios where the element is encapsulated by its label (e.g., a button or an input type button), in which case the label and its content/value should be excluded.
e.g.
button

If the button element is encapsulated by its label element, ignore the button element's subtree from its computed accessible name.

input[type="button"]

If the control is encapsulated by its label element, and the control has an author specified value or the lack of a value has produced an implementation defined string to render, then exclude either from the control's computed accessible name.

important
In other-form-elements.html, we should probably remove the input type="hidden", since it is removed from the accessibility tree, and I don't think we should be checking its acc name

Comment thread html-aam/accname-computation-by-element/other-form-elements.html Outdated
@adampage

Copy link
Copy Markdown
Member Author

For a potential follow-up PR, since we've added specific scenarios, it might be worth considering scenarios where the element is encapsulated by its label (e.g., a button or an input type button), in which case the label and its content/value should be excluded. e.g. button

Oh, nice one, @giacomo-petri — I hadn’t caught this update to HTML-AAM. I’ve added it to this PR via 9953c9c.

important In other-form-elements.html, we should probably remove the input type="hidden", since it is removed from the accessibility tree, and I don't think we should be checking its acc name

Oh my goodness. 🤦🏻 Thank you for catching this. Fixed in 96fea49.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants