Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <html> |
michael@0 | 2 | |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>nsIAccessibleSelectable HTML select testing</title> |
michael@0 | 5 | |
michael@0 | 6 | <link rel="stylesheet" type="text/css" |
michael@0 | 7 | href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
michael@0 | 8 | |
michael@0 | 9 | </style> |
michael@0 | 10 | |
michael@0 | 11 | <script type="application/javascript" |
michael@0 | 12 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 13 | |
michael@0 | 14 | <script type="application/javascript" |
michael@0 | 15 | src="../common.js"></script> |
michael@0 | 16 | <script type="application/javascript" |
michael@0 | 17 | src="../role.js"></script> |
michael@0 | 18 | <script type="application/javascript" |
michael@0 | 19 | src="../states.js"></script> |
michael@0 | 20 | <script type="application/javascript" |
michael@0 | 21 | src="../selectable.js"></script> |
michael@0 | 22 | |
michael@0 | 23 | <script type="application/javascript"> |
michael@0 | 24 | |
michael@0 | 25 | function doTest() |
michael@0 | 26 | { |
michael@0 | 27 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 28 | // select@size="1" aka combobox |
michael@0 | 29 | |
michael@0 | 30 | var id = "combobox"; |
michael@0 | 31 | var combobox = getAccessible(id); |
michael@0 | 32 | var comboboxList = combobox.firstChild; |
michael@0 | 33 | ok(isAccessible(comboboxList, [nsIAccessibleSelectable]), |
michael@0 | 34 | "No selectable accessible for list of " + id); |
michael@0 | 35 | |
michael@0 | 36 | var select = getAccessible(comboboxList, [nsIAccessibleSelectable]); |
michael@0 | 37 | testSelectableSelection(select, [ "cb1_item1" ]); |
michael@0 | 38 | |
michael@0 | 39 | // select 2nd item |
michael@0 | 40 | select.addItemToSelection(1); |
michael@0 | 41 | testSelectableSelection(select, [ "cb1_item2" ], "addItemToSelection(1): "); |
michael@0 | 42 | |
michael@0 | 43 | // unselect 2nd item, 1st item gets selected automatically |
michael@0 | 44 | select.removeItemFromSelection(1); |
michael@0 | 45 | testSelectableSelection(select, [ "cb1_item1" ], |
michael@0 | 46 | "removeItemFromSelection(1): "); |
michael@0 | 47 | |
michael@0 | 48 | // doesn't change selection |
michael@0 | 49 | is(select.selectAll(), false, |
michael@0 | 50 | "No way to select all items in combobox '" + id + "'"); |
michael@0 | 51 | testSelectableSelection(select, [ "cb1_item1" ], "selectAll: "); |
michael@0 | 52 | |
michael@0 | 53 | // doesn't change selection |
michael@0 | 54 | select.unselectAll(); |
michael@0 | 55 | testSelectableSelection(select, [ "cb1_item1" ], "unselectAll: "); |
michael@0 | 56 | |
michael@0 | 57 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 58 | // select@size="1" with optgroups |
michael@0 | 59 | |
michael@0 | 60 | id = "combobox2"; |
michael@0 | 61 | combobox = getAccessible(id); |
michael@0 | 62 | comboboxList = combobox.firstChild; |
michael@0 | 63 | ok(isAccessible(comboboxList, [nsIAccessibleSelectable]), |
michael@0 | 64 | "No selectable accessible for list of " + id); |
michael@0 | 65 | |
michael@0 | 66 | select = getAccessible(comboboxList, [nsIAccessibleSelectable]); |
michael@0 | 67 | testSelectableSelection(select, [ "cb2_item1" ]); |
michael@0 | 68 | |
michael@0 | 69 | select.addItemToSelection(1); |
michael@0 | 70 | testSelectableSelection(select, [ "cb2_item2" ]); |
michael@0 | 71 | |
michael@0 | 72 | select.removeItemFromSelection(1); |
michael@0 | 73 | testSelectableSelection(select, [ "cb2_item1" ]); |
michael@0 | 74 | |
michael@0 | 75 | is(select.selectAll(), false, |
michael@0 | 76 | "No way to select all items in combobox " + id + "'"); |
michael@0 | 77 | testSelectableSelection(select, [ "cb2_item1" ]); |
michael@0 | 78 | |
michael@0 | 79 | select.unselectAll(); |
michael@0 | 80 | testSelectableSelection(select, [ "cb2_item1" ]); |
michael@0 | 81 | |
michael@0 | 82 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 83 | // select@size="4" aka single selectable listbox |
michael@0 | 84 | |
michael@0 | 85 | var id = "listbox"; |
michael@0 | 86 | ok(isAccessible(id, [nsIAccessibleSelectable]), |
michael@0 | 87 | "No selectable accessible for " + id); |
michael@0 | 88 | |
michael@0 | 89 | select = getAccessible(id, [nsIAccessibleSelectable]); |
michael@0 | 90 | testSelectableSelection(select, [ ]); |
michael@0 | 91 | |
michael@0 | 92 | // select 2nd item |
michael@0 | 93 | select.addItemToSelection(1); |
michael@0 | 94 | testSelectableSelection(select, [ "lb1_item2" ], "addItemToSelection(1): "); |
michael@0 | 95 | |
michael@0 | 96 | // unselect 2nd item, 1st item gets selected automatically |
michael@0 | 97 | select.removeItemFromSelection(1); |
michael@0 | 98 | testSelectableSelection(select, [ ], |
michael@0 | 99 | "removeItemFromSelection(1): "); |
michael@0 | 100 | |
michael@0 | 101 | // doesn't change selection |
michael@0 | 102 | is(select.selectAll(), false, |
michael@0 | 103 | "No way to select all items in single selectable listbox '" + id + "'"); |
michael@0 | 104 | testSelectableSelection(select, [ ], "selectAll: "); |
michael@0 | 105 | |
michael@0 | 106 | // doesn't change selection |
michael@0 | 107 | select.unselectAll(); |
michael@0 | 108 | testSelectableSelection(select, [ ], "unselectAll: "); |
michael@0 | 109 | |
michael@0 | 110 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 111 | // select@size="4" with optgroups, single selectable |
michael@0 | 112 | |
michael@0 | 113 | id = "listbox2"; |
michael@0 | 114 | ok(isAccessible(id, [nsIAccessibleSelectable]), |
michael@0 | 115 | "No selectable accessible for " + id); |
michael@0 | 116 | |
michael@0 | 117 | select = getAccessible(id, [nsIAccessibleSelectable]); |
michael@0 | 118 | testSelectableSelection(select, [ ]); |
michael@0 | 119 | |
michael@0 | 120 | select.addItemToSelection(1); |
michael@0 | 121 | testSelectableSelection(select, [ "lb2_item2" ]); |
michael@0 | 122 | |
michael@0 | 123 | select.removeItemFromSelection(1); |
michael@0 | 124 | testSelectableSelection(select, [ ]); |
michael@0 | 125 | |
michael@0 | 126 | is(select.selectAll(), false, |
michael@0 | 127 | "No way to select all items in single selectable listbox " + id + "'"); |
michael@0 | 128 | testSelectableSelection(select, [ ]); |
michael@0 | 129 | |
michael@0 | 130 | select.unselectAll(); |
michael@0 | 131 | testSelectableSelection(select, [ ]); |
michael@0 | 132 | |
michael@0 | 133 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 134 | // select@size="4" multiselect aka listbox |
michael@0 | 135 | |
michael@0 | 136 | id = "listbox3"; |
michael@0 | 137 | ok(isAccessible(id, [nsIAccessibleSelectable]), |
michael@0 | 138 | "No selectable accessible for " + id); |
michael@0 | 139 | |
michael@0 | 140 | select = getAccessible(id, [nsIAccessibleSelectable]); |
michael@0 | 141 | testSelectableSelection(select, [ ]); |
michael@0 | 142 | |
michael@0 | 143 | select.addItemToSelection(0); |
michael@0 | 144 | testSelectableSelection(select, [ "lb3_item1" ], "addItemToSelection: "); |
michael@0 | 145 | |
michael@0 | 146 | select.removeItemFromSelection(0); |
michael@0 | 147 | testSelectableSelection(select, [ ], "removeItemFromSelection: "); |
michael@0 | 148 | |
michael@0 | 149 | is(select.selectAll(), true, |
michael@0 | 150 | "All items in listbox '" + id + "' should be selected"); |
michael@0 | 151 | testSelectableSelection(select, [ "lb3_item1", "lb3_item2"], |
michael@0 | 152 | "selectAll: "); |
michael@0 | 153 | |
michael@0 | 154 | select.unselectAll(); |
michael@0 | 155 | testSelectableSelection(select, [ ], "unselectAll: "); |
michael@0 | 156 | |
michael@0 | 157 | ////////////////////////////////////////////////////////////////////////// |
michael@0 | 158 | // select@size="4" multiselect with optgroups |
michael@0 | 159 | |
michael@0 | 160 | var id = "listbox4"; |
michael@0 | 161 | ok(isAccessible(id, [nsIAccessibleSelectable]), |
michael@0 | 162 | "No selectable accessible for " + id); |
michael@0 | 163 | |
michael@0 | 164 | select = getAccessible(id, [nsIAccessibleSelectable]); |
michael@0 | 165 | testSelectableSelection(select, [ ]); |
michael@0 | 166 | |
michael@0 | 167 | select.addItemToSelection(0); |
michael@0 | 168 | testSelectableSelection(select, [ "lb4_item1" ]); |
michael@0 | 169 | |
michael@0 | 170 | select.removeItemFromSelection(0); |
michael@0 | 171 | testSelectableSelection(select, [ ]); |
michael@0 | 172 | |
michael@0 | 173 | is(select.selectAll(), true, |
michael@0 | 174 | "All items in listbox '" + id + "' should be selected"); |
michael@0 | 175 | testSelectableSelection(select, [ "lb4_item1", "lb4_item2"]); |
michael@0 | 176 | |
michael@0 | 177 | select.unselectAll(); |
michael@0 | 178 | testSelectableSelection(select, [ ]); |
michael@0 | 179 | |
michael@0 | 180 | SimpleTest.finish(); |
michael@0 | 181 | } |
michael@0 | 182 | |
michael@0 | 183 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 184 | addA11yLoadEvent(doTest); |
michael@0 | 185 | </script> |
michael@0 | 186 | |
michael@0 | 187 | </head> |
michael@0 | 188 | |
michael@0 | 189 | <body> |
michael@0 | 190 | |
michael@0 | 191 | <a target="_blank" |
michael@0 | 192 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=530014" |
michael@0 | 193 | title="ARIA single selectable widget should implement nsIAccessibleSelectable"> |
michael@0 | 194 | Mozilla Bug 530014 |
michael@0 | 195 | </a><br> |
michael@0 | 196 | <a target="_blank" |
michael@0 | 197 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=590176" |
michael@0 | 198 | title="add pseudo SelectAccessible interface"> |
michael@0 | 199 | Mozilla Bug 590176 |
michael@0 | 200 | </a><br> |
michael@0 | 201 | <p id="display"></p> |
michael@0 | 202 | <div id="content" style="display: none"></div> |
michael@0 | 203 | <pre id="test"> |
michael@0 | 204 | </pre> |
michael@0 | 205 | |
michael@0 | 206 | <select id="combobox"> |
michael@0 | 207 | <option id="cb1_item1">option1</option> |
michael@0 | 208 | <option id="cb1_item2">option2</option> |
michael@0 | 209 | </select> |
michael@0 | 210 | |
michael@0 | 211 | <select id="combobox2"> |
michael@0 | 212 | <option id="cb2_item1">option1</option> |
michael@0 | 213 | <optgroup>optgroup |
michael@0 | 214 | <option id="cb2_item2">option2</option> |
michael@0 | 215 | </optgroup> |
michael@0 | 216 | </select> |
michael@0 | 217 | |
michael@0 | 218 | <select id="listbox" size="4"> |
michael@0 | 219 | <option id="lb1_item1">option1</option> |
michael@0 | 220 | <option id="lb1_item2">option2</option> |
michael@0 | 221 | </select> |
michael@0 | 222 | |
michael@0 | 223 | <select id="listbox2" size="4"> |
michael@0 | 224 | <option id="lb2_item1">option1</option> |
michael@0 | 225 | <optgroup>optgroup> |
michael@0 | 226 | <option id="lb2_item2">option2</option> |
michael@0 | 227 | </optgroup> |
michael@0 | 228 | </select> |
michael@0 | 229 | |
michael@0 | 230 | <select id="listbox3" size="4" multiple="true"> |
michael@0 | 231 | <option id="lb3_item1">option1</option> |
michael@0 | 232 | <option id="lb3_item2">option2</option> |
michael@0 | 233 | </select> |
michael@0 | 234 | |
michael@0 | 235 | <select id="listbox4" size="4" multiple="true"> |
michael@0 | 236 | <option id="lb4_item1">option1</option> |
michael@0 | 237 | <optgroup>optgroup> |
michael@0 | 238 | <option id="lb4_item2">option2</option> |
michael@0 | 239 | </optgroup> |
michael@0 | 240 | </select> |
michael@0 | 241 | |
michael@0 | 242 | </body> |
michael@0 | 243 | </html> |