B2G/gecko/accessible/tests/mochitest/selectable.js
/**
 * Test selection getter methods of nsIAccessibleSelectable.
 *
 * @param aIdentifier        [in] selectable container accessible
 * @param aSelectedChildren  [in] array of selected children
 */
Test selection getter methods of nsIAccessibleSelectable.
@param aIdentifier        [in] selectable container accessible
@param aSelectedChildren  [in] array of selected children
Test selection getter methods of nsIAccessibleSelectable . @param aIdentifier [ in ] selectable container accessible @param aSelectedChildren [ in ] array of selected children
function testSelectableSelection(aIdentifier, aSelectedChildren, aMsg)
{
  var acc = getAccessible(aIdentifier, [nsIAccessibleSelectable]);
  if (!acc)
    return;
  var msg = aMsg ? aMsg : "";
  var len = aSelectedChildren.length;
  var selectedChildren = acc.GetSelectedChildren();
  is(selectedChildren ? selectedChildren.length : 0, len,
     msg + "getSelectedChildren: wrong selected children count for " +
     prettyName(aIdentifier));
  for (var idx = 0; idx < len; idx++) {
    var expectedAcc = getAccessible(aSelectedChildren[idx]);
    var actualAcc = selectedChildren.queryElementAt(idx, nsIAccessible);
    is(actualAcc, expectedAcc,
       msg + "getSelectedChildren: wrong selected child at index " + idx +
       " for " + prettyName(aIdentifier) + " { actual : " +
       prettyName(actualAcc) + ", expected: " + prettyName(expectedAcc) + "}");
  }
   property.
  for (var idx = 0; idx < len; idx++) {
    var expectedAcc = getAccessible(aSelectedChildren[idx]);
    is(acc.refSelection(idx), expectedAcc,
       msg + "refSelection: wrong selected child at index " + idx + " for " +
       prettyName(aIdentifier));
  }
  testIsChildSelected(acc, acc, { value: 0 }, aSelectedChildren, msg);
}
function testSelectableSelection ( aIdentifier , aSelectedChildren , aMsg ) { var acc = getAccessible ( aIdentifier , [ nsIAccessibleSelectable ] ) ; if ( ! acc ) return ; var msg = aMsg ? aMsg : "" ; var len = aSelectedChildren . length ; var selectedChildren = acc . GetSelectedChildren ( ) ; is ( selectedChildren ? selectedChildren . length : 0 , len , msg + "getSelectedChildren: wrong selected children count for " + prettyName ( aIdentifier ) ) ; for ( var idx = 0 ; idx < len ; idx ++ ) { var expectedAcc = getAccessible ( aSelectedChildren [ idx ] ) ; var actualAcc = selectedChildren . queryElementAt ( idx , nsIAccessible ) ; is ( actualAcc , expectedAcc , msg + "getSelectedChildren: wrong selected child at index " + idx + " for " + prettyName ( aIdentifier ) + " { actual : " + prettyName ( actualAcc ) + ", expected: " + prettyName ( expectedAcc ) + "}" ) ; } for ( var idx = 0 ; idx < len ; idx ++ ) { var expectedAcc = getAccessible ( aSelectedChildren [ idx ] ) ; is ( acc . refSelection ( idx ) , expectedAcc , msg + "refSelection: wrong selected child at index " + idx + " for " + prettyName ( aIdentifier ) ) ; } testIsChildSelected ( acc , acc , { value : 0 } , aSelectedChildren , msg ) ; }
Test selection getter methods of nsIAccessibleSelectable.
Test selection getter methods of nsIAccessibleSelectable .
// getSelectedChildren // selectionCount // XXX: nsIAccessibleText and nsIAccessibleSelectable both have // selectionCount property. //is(acc.selectionCount, aSelectedChildren.length, //   "selectionCount: wrong selected children count for " + prettyName(aIdentifier)); // refSelection // isChildSelected