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" aria-activedescendant="opt3"> |
| 6 <div id="opt1" role="option">Option 1</div> |
| 7 <div id="opt2" role="option" aria-selected="false">Option 2</div> |
| 8 <div id="opt3" role="option">Option 3</div> |
| 9 </div> |
| 10 |
| 11 <div role="listbox" id="listbox2"> |
| 12 <div id="opt2.1" role="option">Option 2.1</div> |
| 13 </div> |
| 14 |
| 15 <div role="tree" id="tree"> |
| 16 <div id="treeitem1" role="treeitem" tabindex="-1">Tree item 1</div> |
| 17 <div id="treeitem2" role="treeitem">Tree item 2</div> |
| 18 </div> |
| 19 |
| 20 <script> |
| 21 var listbox = document.getElementById("listbox"); |
| 22 |
| 23 function axElementById(id) { |
| 24 return accessibilityController.accessibleElementById(id); |
| 25 } |
| 26 |
| 27 test(function(t) { |
| 28 listbox.focus(); |
| 29 var axOption1 = axElementById("opt1"); |
| 30 assert_equals(axOption1.isSelectable, true); |
| 31 }, "Descendant widgets are selectable in a single selection container"); |
| 32 |
| 33 test(function(t) { |
| 34 listbox.focus(); |
| 35 listbox.setAttribute("aria-activedescendant", "opt1"); |
| 36 var axOption1 = axElementById("opt1"); |
| 37 assert_equals(axOption1.isSelected, true); |
| 38 }, "Selection follows activedescendant in a single selection container"); |
| 39 |
| 40 |
| 41 test(function(t) { |
| 42 var axOption = axElementById("opt2.1"); |
| 43 assert_equals(axOption.isSelectable, true); |
| 44 }, "Options are selectable even if it is not clear they can be from markup"); |
| 45 |
| 46 test(function(t) { |
| 47 listbox.focus(); |
| 48 listbox.setAttribute("aria-activedescendant", "opt2"); |
| 49 var axOption2 = axElementById("opt2"); |
| 50 assert_equals(axOption2.isSelected, false); |
| 51 }, "Selection doesn't follow activedescendant when aria-selected=false"); |
| 52 |
| 53 test(function(t) { |
| 54 listbox.focus(); |
| 55 listbox.setAttribute("aria-activedescendant", "opt2"); |
| 56 var axOption1 = axElementById("opt1"); |
| 57 assert_equals(axOption1.isSelected, false); |
| 58 }, "Only focused item is marked as selected in a single selection container"); |
| 59 |
| 60 test(function(t) { |
| 61 document.getElementById('treeitem1').focus(); |
| 62 var treeitem1 = axElementById("treeitem1"); |
| 63 assert_equals(treeitem1.isSelected, true); |
| 64 }, "Selection follows tabindex focus in a single selection container"); |
| 65 |
| 66 test(function(t) { |
| 67 document.getElementById('treeitem2').focus(); |
| 68 var treeitem2 = axElementById("treeitem2"); |
| 69 assert_equals(treeitem2.isSelected, false); |
| 70 }, "Selection doesn't follow focus when aria-selected=false"); |
| 71 |
| 72 </script> |
OLD | NEW |