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

axe returns fallback text of video elements as the accessible name #3017

Closed
scurker opened this issue Jun 17, 2021 · 4 comments
Closed

axe returns fallback text of video elements as the accessible name #3017

scurker opened this issue Jun 17, 2021 · 4 comments
Labels
commons Issues in the common code (lib/commons) fix Bug fixes

Comments

@scurker
Copy link
Member

scurker commented Jun 17, 2021

Product: axe-core
Expectation: The accessible name calculation should not return the fallback text for <video> elements.
Actual: Accessible name calculation includes fallback text
Motivation: Screen readers to not appear to have this as the accessible name, nor do the accessibility trees of different browsers that I checked.

axe-core version: 4.2.2
axe-webdriver, extension or other integration version: N/A

Browser and Assistive Technology versions
(see included test case)

I've setup a codepen with different scenarios of alternate text for <video> elements.

await import('https://unpkg.com/axe-core')
axe.utils.getFlattenedTree()
$$('video').map(axe.commons.text.accessibleText)

The above returns the following:

[
  "", 
  "this is a video", 
  "this is a label for the video", 
  "", 
  "Your browser is not supported"
]

The last video in the above test case is one with a fallback:

<video>
  <source src="..." />
  Your browser is not supported
</video>

I don't think the accessible name calculation should be included except in instances where the video element is not supported, but I have not tested that specific use case. It's possible that this happens for audio elements as well.

According to the html spec the content of the elements is intended not to address accessibility concerns.

@WilcoFiers
Copy link
Contributor

I'm not surprised axe-core returns text content as accessible text. It may not be the accessible name of the element, but it is text that is accessible. This is how accessibleText is intended to work.

What is odd is that axe-core seems to return hidden text as part of accessible text. It is definitely not supposed to do that. It wouldn't return the text of a script element for instance. No idea what that'd be different for video. Worth a look.

@WilcoFiers WilcoFiers added commons Issues in the common code (lib/commons) fix Bug fixes labels Jun 18, 2021
@dylanb
Copy link
Contributor

dylanb commented Jun 18, 2021

I'm not surprised axe-core returns text content as accessible text. It may not be the accessible name of the element, but it is text that is accessible. This is how accessibleText is intended to work.

@WilcoFiers that is not really the case, accessibleText implements the accName algorithm - which is the calculation for the accessible name of something. Name from content is one portion of that algorithm. Seems like we have a bug related to which nodes support name from content.

@WilcoFiers
Copy link
Contributor

Axe-core's accessibleText from accName in two places. It is flagged and documented:
https://github.com/dequelabs/axe-core/blob/develop/lib/commons/aria/named-from-contents.js#L28
https://github.com/dequelabs/axe-core/blob/develop/lib/commons/text/subtree-text.js#L33

Axe-core relies on these to handle a bunch of scenarios. If you don't want this, you can use the strict flag. We can discuss whether or not the default should have been the other way around. But axe-core itself never uses strict, except in the accessibleName tests.

Either way, hidden text should get ignored by subtree-text. That definitely is a bug. I'll leave it up to the extension team to work out if you want strict or not.

@dylanb
Copy link
Contributor

dylanb commented Jun 20, 2021

That strict flag is buried very deeply. It should be documented here

* @param {Object} context

straker added a commit that referenced this issue Jun 22, 2021
* fix(accText): ignore text in embedded content elements

Closes  #3017

* Update lib/standards/html-elms.js

* Update lib/standards/html-elms.js

Co-authored-by: Steven Lambert <2433219+straker@users.noreply.github.com>

Co-authored-by: Steven Lambert <2433219+straker@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commons Issues in the common code (lib/commons) fix Bug fixes
Projects
None yet
Development

No branches or pull requests

3 participants