OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> |
| 4 |
| 5 <div role="listbox" id="listbox" tabindex="0"> |
| 6 <div id="opt1" role="option">Option 1</div> |
| 7 <div id="opt2" role="option" aria-selected="false">Option 2</div> |
| 8 </div> |
| 9 |
| 10 <div role="tree" id="tree"> |
| 11 <div id="treeitem1" role="treeitem" tabindex="-1">Tree item 1</div> |
| 12 <div id="treeitem2" role="treeitem">Tree item 2</div> |
| 13 </div> |
| 14 |
| 15 <script> |
| 16 var listbox = document.getElementById("listbox"); |
| 17 |
| 18 function axElementById(id) { |
| 19 return accessibilityController.accessibleElementById(id); |
| 20 } |
| 21 |
| 22 test(function(t) { |
| 23 listbox.focus(); |
| 24 var axOption1 = axElementById("opt1"); |
| 25 assert_equals(axOption1.isSelectable, true); |
| 26 }, "Descendant widgets are selectable in a single selection container"); |
| 27 |
| 28 test(function(t) { |
| 29 listbox.focus(); |
| 30 listbox.setAttribute("aria-activedescendant", "opt1"); |
| 31 var axOption1 = axElementById("opt1"); |
| 32 assert_equals(axOption1.isSelected, true); |
| 33 }, "Selection follows activedescendant in a single selection container"); |
| 34 |
| 35 test(function(t) { |
| 36 listbox.focus(); |
| 37 listbox.setAttribute("aria-activedescendant", "opt2"); |
| 38 var axOption2 = axElementById("opt2"); |
| 39 assert_equals(axOption2.isSelected, false); |
| 40 }, "Selection doesn't follow activedescendant when aria-selected=false"); |
| 41 |
| 42 test(function(t) { |
| 43 listbox.focus(); |
| 44 listbox.setAttribute("aria-activedescendant", "opt2"); |
| 45 var axOption1 = axElementById("opt1"); |
| 46 assert_equals(axOption1.isSelected, false); |
| 47 }, "Only focused item is marked as selected in a single selection container"); |
| 48 |
| 49 test(function(t) { |
| 50 document.getElementById('treeitem1').focus(); |
| 51 var treeitem1 = axElementById("treeitem1"); |
| 52 assert_equals(treeitem1.isSelected, true); |
| 53 }, "Selection follows tabindex focus in a single selection container"); |
| 54 |
| 55 test(function(t) { |
| 56 document.getElementById('treeitem2').focus(); |
| 57 var treeitem2 = axElementById("treeitem2"); |
| 58 assert_equals(treeitem2.isSelected, false); |
| 59 }, "Selection doesn't follow focus when aria-selected=false"); |
| 60 |
| 61 </script> |
OLD | NEW |