| html-aam-accname-utils.js |
Builds a collection of WPT subtests for verifying the computation steps
documented in https://www.w3.org/TR/html-aam-1.0/#accname-computation.
For each element in elements[], a collection of subtests will be generated to
test every potential name source in nameSources[].
Each entry in elements[] must have a key that is a valid CSS selector
conforming to either:
- `tagname`
- `tagname[attrname="attrvalue"]`
This key will be parsed to create the DOM element which will be used to
test the computed name.
Each entry in elements[] may have an optional properties object specifying
any of the following:
- descendants[]: elements to be appended as descendants of the test element.
This array may include the string 'textNode' to append a text node.
- ancestors[]: elements to be prepended as ancestors of the test element.
- attrs[]: attributes to be added to the element for every subtest. For
example, an `a` element may have an href attribute.
- specialContext: a string indicating a special case that requires complex
test markup. Currently supported values are 'area', 'ruby', 'rp', and 'rt'.
nameSources[] is necessarily order-sensitive, matching the computation steps
in HTML-AAM. Each string in nameSources[] is a unique identifier and should
have a matching key in the nameValues{} dictionary later in this file.
The first subtest generated will include *every* potential name source and
verify that the first source “wins”. Each subsequent subtest eliminates the
name source from the previous test, then performs the same verification.
In the final subtest, all potential name sources have been eliminated and the
computed name is expected to be empty.
The following example test configuration will generate 24 WPT subtests:
3 elements * 8 potential name sources = 24 subtests
Example:
const testConfig = {
elements: {
'input[type="text"]': { attrs: ['value'] },
'input[type="search"]': { attrs: ['value'] },
'textarea': { descendants: ['textNode'] }
},
nameSources: [
'from 2 aria-labelledby refs',
'from 1 aria-labelledby ref',
'from aria-label',
'from 2 labels',
'from 1 label',
'from title',
'from placeholder',
'to be empty'
]
}
HtmlAamAccnameUtils.buildNameComputationTests(testConfig);
|
15330 |
- |