Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Unified Diff: LayoutTests/accessibility/name-calc-aria-label.html

Issue 1160793007: Include aria-label in acc name calculation. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Missing y Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/modules/accessibility/AXNodeObject.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/accessibility/name-calc-aria-label.html
diff --git a/LayoutTests/accessibility/name-calc-aria-label.html b/LayoutTests/accessibility/name-calc-aria-label.html
new file mode 100644
index 0000000000000000000000000000000000000000..1831e2a4335cd9d23b7042a83b86ff13df6e244a
--- /dev/null
+++ b/LayoutTests/accessibility/name-calc-aria-label.html
@@ -0,0 +1,111 @@
+<!DOCTYPE HTML>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+<style>
+.hideAllContainers .container {
+ display: none;
+}
+</style>
+
+<div class="container">
+ <button id="labelOnly" aria-label="Label">Contents</button>
+</div>
+
+<script>
+test(function(t) {
+ var axLabelOnly = accessibilityController.accessibleElementById("labelOnly");
+ assert_equals(axLabelOnly.name, "Label");
+ assert_equals(axLabelOnly.nameFrom, "attribute");
+}, "Button with aria-label.");
+</script>
+
+<div class="container">
+ <button id="emptyLabel1" aria-label="">Contents</button>
+</div>
+
+<script>
+test(function(t) {
+ var axEmptyLabel1 = accessibilityController.accessibleElementById("emptyLabel1");
+ assert_equals(axEmptyLabel1.name, "Contents");
+ assert_equals(axEmptyLabel1.nameFrom, "contents");
+}, "Button with explicitly empty label.");
+</script>
+
+<div class="container">
+ <button id="emptyLabel2" aria-label>Contents</button>
+</div>
+
+<script>
+test(function(t) {
+ var axEmptyLabel2 = accessibilityController.accessibleElementById("emptyLabel2");
+ assert_equals(axEmptyLabel2.name, "Contents");
+ assert_equals(axEmptyLabel2.nameFrom, "contents");
+}, "Button with label value not specified.");
+</script>
+
+<div class="container">
+ <button id="labelledby1" aria-labelledby="label1" aria-label="Label">Contents</button>
+ <div id="label1">Labelledby 1</div>
+</div>
+
+<script>
+test(function(t) {
+ var axLabelledby1 = accessibilityController.accessibleElementById("labelledby1");
+ assert_equals(axLabelledby1.name, "Labelledby 1");
+ assert_equals(axLabelledby1.nameFrom, "relatedElement");
+ assert_equals(axLabelledby1.nameElementCount(), 1);
+ assert_equals(axLabelledby1.nameElementAtIndex(0).role, "AXRole: AXDiv");
+}, "aria-labelledby trumps both aria-label and contents.");
+</script>
+
+<div class="container">
+ <button id="labelledby2" aria-labelledby="label2">Contents</button>
+ <div id="label2" aria-label="Label 2 label">Contents 2</div>
+</div>
+
+<script>
+test(function(t) {
+ var axLabelledby2 = accessibilityController.accessibleElementById("labelledby2");
+ assert_equals(axLabelledby2.name, "Label 2 label");
+ assert_equals(axLabelledby2.nameFrom, "relatedElement");
+ assert_equals(axLabelledby2.nameElementCount(), 1);
+ assert_equals(axLabelledby2.nameElementAtIndex(0).role, "AXRole: AXDiv");
+}, "Button with aria-labelledby referencing an element with an aria-label uses the aria-label as text alternative.");
+</script>
+
+<div class="container">
+ <button id="labelledby3" aria-labelledby="label3">Contents</button>
+ <div id="label3" aria-label="">Contents 3</div>
+</div>
+
+<script>
+test(function(t) {
+ var axLabelledby3 = accessibilityController.accessibleElementById("labelledby3");
+ assert_equals(axLabelledby3.name, "Contents 3");
+ assert_equals(axLabelledby3.nameFrom, "relatedElement");
+ assert_equals(axLabelledby3.nameElementCount(), 1);
+ assert_equals(axLabelledby3.nameElementAtIndex(0).role, "AXRole: AXDiv");
+}, "aria-labelledby reference to element with empty aria-label.");
+</script>
+
+<div class="container">
+ <button id="labelledby4" aria-labelledby="label4">Contents</button>
+ <div id="label4" aria-label="Label 4 label" aria-labelledby="label4chained">Contents 4</div>
+ <p id="label4chained">Contents 4 chained</p>
+</div>
+
+<script>
+test(function(t) {
+ var axLabelledby4 = accessibilityController.accessibleElementById("labelledby4");
+ assert_equals(axLabelledby4.name, "Label 4 label");
+ assert_equals(axLabelledby4.nameFrom, "relatedElement");
+ assert_equals(axLabelledby4.nameElementCount(), 1);
+ assert_equals(axLabelledby4.nameElementAtIndex(0).role, "AXRole: AXDiv");
+}, "Recursive aria-labelledby references aren't followed even in presence of aria-label, even though aria-labelledby normally trumps aria-label.");
+</script>
+
+<script>
+if (window.testRunner)
+ document.body.className = "hideAllContainers";
+</script>
« no previous file with comments | « no previous file | Source/modules/accessibility/AXNodeObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698