Chromium Code Reviews| 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..791e2c4fcb2404cd0e71e1eccb7a5b11d537f7e2 |
| --- /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){ |
|
dmazzoni
2015/06/05 19:46:01
Nit: space between ")" and "{" (and more below)
aboxhall
2015/06/05 19:53:57
Done.
|
| + 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"); |
| +}, "Button with chain of aria-labelledby references."); |
|
dmazzoni
2015/06/05 19:46:01
Could you maybe make it clear that the aria-labell
aboxhall
2015/06/05 19:53:56
Fixed up the test title, thanks.
|
| +</script> |
| + |
| +<script> |
| +if (window.testRunner) |
| + document.body.className = "hideAllContainers"; |
| +</script> |