1 /* import-globals-from common.js */
2 /* import-globals-from states.js */
5 * Test selection getter methods of nsIAccessibleSelectable.
7 * @param aIdentifier [in] selectable container accessible
8 * @param aSelectedChildren [in] array of selected children
10 function testSelectableSelection(aIdentifier, aSelectedChildren, aMsg) {
11 var acc = getAccessible(aIdentifier, [nsIAccessibleSelectable]);
16 var msg = aMsg ? aMsg : "";
17 var len = aSelectedChildren.length;
19 // getSelectedChildren
20 var selectedChildren = acc.selectedItems;
22 selectedChildren ? selectedChildren.length : 0,
25 "getSelectedChildren: wrong selected children count for " +
26 prettyName(aIdentifier)
29 for (let idx = 0; idx < len; idx++) {
30 let expectedAcc = aSelectedChildren[idx];
32 expectedAcc instanceof nsIAccessible
33 ? getAccessibleDOMNodeID(expectedAcc)
35 let actualAcc = selectedChildren.queryElementAt(idx, nsIAccessible);
36 let actualAccId = getAccessibleDOMNodeID(actualAcc);
41 "getSelectedChildren: wrong selected child at index " +
44 prettyName(aIdentifier) +
46 prettyName(actualAcc) +
48 prettyName(expectedAcc) +
55 acc.selectedItemCount,
56 aSelectedChildren.length,
57 "selectedItemCount: wrong selected children count for " +
58 prettyName(aIdentifier)
62 for (let idx = 0; idx < len; idx++) {
63 let expectedAcc = aSelectedChildren[idx];
65 expectedAcc instanceof nsIAccessible
66 ? getAccessibleDOMNodeID(expectedAcc)
69 getAccessibleDOMNodeID(acc.getSelectedItemAt(idx)),
72 "getSelectedItemAt: wrong selected child at index " +
75 prettyName(aIdentifier)
80 testIsItemSelected(acc, acc, { value: 0 }, aSelectedChildren, msg);
84 * Test isItemSelected method, helper for testSelectableSelection
86 function testIsItemSelected(
93 var childCount = aTraversedAcc.childCount;
94 for (var idx = 0; idx < childCount; idx++) {
95 var child = aTraversedAcc.getChildAt(idx);
96 var [state /* extraState */] = getStates(child);
97 if (state & STATE_SELECTABLE) {
98 var isSelected = false;
99 var len = aSelectedChildren.length;
100 for (var jdx = 0; jdx < len; jdx++) {
101 let expectedAcc = aSelectedChildren[jdx];
103 expectedAcc instanceof nsIAccessible
104 ? child == expectedAcc
105 : getAccessibleDOMNodeID(child) == expectedAcc;
115 aSelectAcc.isItemSelected(aIndexObj.value++),
118 "isItemSelected: wrong selected child " +
121 prettyName(aSelectAcc)
127 isSelected ? STATE_SELECTED : 0,
129 !isSelected ? STATE_SELECTED : 0,
136 testIsItemSelected(aSelectAcc, child, aIndexObj, aSelectedChildren);