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

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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
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
42 changes: 36 additions & 6 deletions accname/name/comp_hidden_not_referenced.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<p>Tests the <a href="https://w3c.github.io/accname/#comp_hidden_not_referenced">#comp_hidden_not_referenced</a> portions of the AccName <em>Name Computation</em> algorithm.</p>

<button
class="ex"
class="ex-label"
data-expectedlabel="visible to all users"
data-testname="button containing a rendered, unreferenced element that is aria-hidden=true, an unreferenced element with the hidden host language attribute, and an unreferenced element that is unconditionally rendered"
>
Expand All @@ -25,7 +25,7 @@
</button>

<button
class="ex"
class="ex-label"
data-expectedlabel="hidden but referenced,"
data-testname="button labelled by element that is aria-hidden=true"
aria-labelledby="button-label-2"
Expand All @@ -36,7 +36,7 @@
</button>

<button
class="ex"
class="ex-label"
data-expectedlabel="hidden from all users but referenced,"
data-testname="button labelled by element with the hidden host language attribute"
aria-labelledby="button-label-3"
Expand All @@ -47,7 +47,7 @@
</button>

<a
class="ex"
class="ex-label"
data-testname="link labelled by elements with assorted visibility and a11y tree exposure"
data-expectedlabel="visible to all users, hidden but referenced, hidden from all users but referenced"
href="#"
Expand All @@ -62,7 +62,7 @@
</a>

<h2
class="ex"
class="ex-label"
data-testname="heading with name from content, containing element that is visibility:hidden with nested content that is visibility:visible"
data-expectedlabel="visible to all users, un-hidden for all users"
>
Expand All @@ -73,6 +73,36 @@
</span>
</h2>

<h2>Input with hidden label</h2>
<label id="hidden-label" for="input-01" hidden>Hidden label</label>
<input
id="input-01"
class="ex-label"
data-testname="Input that is aria-labelledby hidden label"
data-expectedlabel="Hidden label"
aria-labelledby="hidden-label"
>

<h2>Table with hidden caption</h2>
<table
class="ex-label"
data-testname="Table that is aria-labelledby hidden caption"
data-expectedlabel="Hidden caption"
aria-labelledby="hidden-caption"
>
<caption id="hidden-caption" hidden>Hidden caption</caption>
</table>

<h2>Fieldset with hidden legend</h2>
<fieldset
class="ex-label"
data-testname="Fieldset that is aria-labelledby hidden legend"
data-expectedlabel="Hidden legend"
aria-labelledby="hidden-legend"
>
<legend id="hidden-legend" hidden>Hidden legend</legend>
</fieldset>

Comment on lines +76 to +105
Copy link
Contributor

Choose a reason for hiding this comment

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

New tests to a file tracked in the current Interop project would only be accepted if they didn't introduce new failures mid-year. In this case, the 3 new tests are all passing in Chromium, Gecko, and WebKit.... (Edge unknown but likely passing?) so I think it's okay to include this in the PR... With the caveat that we could roll it back in the unlikely chance it causes a failure for Edge.

In the future, it may be easier to include Interop-tracked changes as a separate PR from ones that do not affect the current Interop project.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, understood, thanks. I’ll make that distinction for future PRs and check in with you if I have doubts.

Copy link
Contributor

Choose a reason for hiding this comment

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

In cases where you need to add a new valid-but-failing tests, add a new file that uses the same file name +".tentative" and have it only include the new failing tests... e.g. comp_hidden_not_referenced.tentative.html

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it. 👍🏻 I did just manually confirm that latest Edge is passing all 3 new tests, so... no harm no foul? But I’ll stay ready to roll it back regardless.

<!-- TODO: Test cases once https://github.com/w3c/aria/issues/1256 resolved: -->
<!-- - button labelled by an element that is aria-hidden=true which contains a nested child that is aria-hidden=false -->
<!-- - button labelled by an element that is aria-hidden=false which belongs to a parent that is aria-hidden=true -->
Expand All @@ -86,7 +116,7 @@
<!-- that are both not rendered and excluded from the a11y tree. -->

<script>
AriaUtils.verifyLabelsBySelector(".ex");
AriaUtils.verifyLabelsBySelector(".ex-label");
</script>
</body>
</html>
37 changes: 37 additions & 0 deletions html-aam/accname-computation-by-element/a.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!doctype html>
<html>

<head>
<meta charset="utf-8">
<title>Accname computation tests for &lt;a&gt;</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/wai-aria/scripts/aria-utils.js"></script>
<script src="/html-aam/scripts/html-aam-accname-utils.js"></script>
</head>

<body>
<script>
let testConfig = {
urlSpec: 'https://www.w3.org/TR/html-aam-1.0/#a-element-accessible-name-computation',
elements: {
'a': { attrs: ['href'] }
},
nameSources: [
'from 2 aria-labelledby refs',
'from 1 aria-labelledby ref',
'from aria-label',
'from subtree',
'from title',
'to be empty'
]
}
HtmlAamAccnameUtils.buildNameComputationTests(testConfig);
AriaUtils.verifyLabelsBySelector(".ex-label");
</script>
</body>

</html>
38 changes: 38 additions & 0 deletions html-aam/accname-computation-by-element/area.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!doctype html>
<html>

<head>
<meta charset="utf-8">
<title>Accname computation tests for &lt;area&gt;</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/wai-aria/scripts/aria-utils.js"></script>
<script src="/html-aam/scripts/html-aam-accname-utils.js"></script>
</head>

<body>
<script>
const testConfig = {
urlSpec: 'https://www.w3.org/TR/html-aam-1.0/#area-element-accessible-name-computation',
elements: {
'area': { attrs: ['href'], specialContext: 'area' }
},
nameSources: [
'from 2 aria-labelledby refs',
'from 1 aria-labelledby ref',
'from aria-label',
'from alt',
'from empty alt',
'from title',
'to be empty'
]
}
HtmlAamAccnameUtils.buildNameComputationTests(testConfig);
AriaUtils.verifyLabelsBySelector(".ex-label");
</script>
</body>

</html>
39 changes: 39 additions & 0 deletions html-aam/accname-computation-by-element/button.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!doctype html>
<html>

<head>
<meta charset="utf-8">
<title>Accname computation tests for &lt;button&gt;</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/wai-aria/scripts/aria-utils.js"></script>
<script src="/html-aam/scripts/html-aam-accname-utils.js"></script>
</head>

<body>
<script>
const testConfig = {
urlSpec: 'https://www.w3.org/TR/html-aam-1.0/#button-element-accessible-name-computation',
elements: {
'button': {}
},
nameSources: [
'from 2 aria-labelledby refs',
'from 1 aria-labelledby ref',
'from aria-label',
'from 2 labels',
'from 1 label',
'from subtree',
'from title',
'to be empty'
]
}
HtmlAamAccnameUtils.buildNameComputationTests(testConfig);
AriaUtils.verifyLabelsBySelector(".ex-label");
</script>
</body>

</html>
37 changes: 37 additions & 0 deletions html-aam/accname-computation-by-element/fieldset.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!doctype html>
<html>

<head>
<meta charset="utf-8">
<title>Accname computation tests for &lt;fieldset&gt;</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/wai-aria/scripts/aria-utils.js"></script>
<script src="/html-aam/scripts/html-aam-accname-utils.js"></script>
</head>

<body>
<script>
const testConfig = {
urlSpec: 'https://www.w3.org/TR/html-aam-1.0/#fieldset-element-accessible-name-computation',
elements: {
'fieldset': {}
},
nameSources: [
'from 2 aria-labelledby refs',
'from 1 aria-labelledby ref',
'from aria-label',
'from first legend',
'from title',
'to be empty'
]
}
HtmlAamAccnameUtils.buildNameComputationTests(testConfig);
AriaUtils.verifyLabelsBySelector(".ex-label");
</script>
</body>

</html>
37 changes: 37 additions & 0 deletions html-aam/accname-computation-by-element/figure.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!doctype html>
<html>

<head>
<meta charset="utf-8">
<title>Accname computation tests for &lt;figure&gt;</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/wai-aria/scripts/aria-utils.js"></script>
<script src="/html-aam/scripts/html-aam-accname-utils.js"></script>
</head>

<body>
<script>
const testConfig = {
urlSpec: 'https://www.w3.org/TR/html-aam-1.0/#figure-element-accessible-name-computation',
elements: {
'figure': {}
},
nameSources: [
'from 2 aria-labelledby refs',
'from 1 aria-labelledby ref',
'from aria-label',
'from first figcaption',
'from title',
'to be empty'
]
}
HtmlAamAccnameUtils.buildNameComputationTests(testConfig);
AriaUtils.verifyLabelsBySelector(".ex-label");
</script>
</body>

</html>
36 changes: 36 additions & 0 deletions html-aam/accname-computation-by-element/iframe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!doctype html>
<html>

<head>
<meta charset="utf-8">
<title>Accname computation tests for &lt;iframe&gt;</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/wai-aria/scripts/aria-utils.js"></script>
<script src="/html-aam/scripts/html-aam-accname-utils.js"></script>
</head>

<body>
<script>
const testConfig = {
urlSpec: 'https://www.w3.org/TR/html-aam-1.0/#iframe-element-accessible-name-computation',
elements: {
'iframe': {}
},
nameSources: [
'from 2 aria-labelledby refs',
'from 1 aria-labelledby ref',
'from aria-label',
'from title',
'to be empty'
]
}
HtmlAamAccnameUtils.buildNameComputationTests(testConfig);
AriaUtils.verifyLabelsBySelector(".ex-label");
</script>
</body>

</html>
38 changes: 38 additions & 0 deletions html-aam/accname-computation-by-element/img.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!doctype html>
<html>

<head>
<meta charset="utf-8">
<title>Accname computation tests for &lt;img&gt;</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/wai-aria/scripts/aria-utils.js"></script>
<script src="/html-aam/scripts/html-aam-accname-utils.js"></script>
</head>

<body>
<script>
const testConfig = {
urlSpec: 'https://www.w3.org/TR/html-aam-1.0/#img-element-accessible-name-computation',
elements: {
'img': { attrs: ['img src'] }
},
nameSources: [
'from 2 aria-labelledby refs',
'from 1 aria-labelledby ref',
'from aria-label',
'from alt',
'from empty alt',
'from title',
'to be empty'
]
}
HtmlAamAccnameUtils.buildNameComputationTests(testConfig);
AriaUtils.verifyLabelsBySelector(".ex-label");
</script>
</body>

</html>
Loading