B2G/gecko/accessible/tests/mochitest/states.js
/**
 * Tests an acessible and its sub tree for the passed in state bits.
 * Used to make sure that states are propagated to descendants, for example the
 * STATE_UNAVAILABLE from a container to its children.
 *
 * @param aAccOrElmOrID  The accessible, DOM element or ID to be tested.
 * @param aState         The state bits that are wanted.
 * @param aExtraState    The extra state bits that are wanted.
 * @param aAbsentState   State bits that are not wanted.
 */
Tests an acessible and its sub tree for the passed in state bits.
Used to make sure that states are propagated to descendants, for example the
STATE_UNAVAILABLE from a container to its children.

@param aAccOrElmOrID  The accessible, DOM element or ID to be tested.
@param aState         The state bits that are wanted.
@param aExtraState    The extra state bits that are wanted.
@param aAbsentState   State bits that are not wanted.
Tests an acessible and its sub tree for the passed in state bits . Used to make sure that states are propagated to descendants for example the STATE_UNAVAILABLE from a container to its children . @param aAccOrElmOrID The accessible DOM element or ID to be tested . @param aState The state bits that are wanted . @param aExtraState The extra state bits that are wanted . @param aAbsentState State bits that are not wanted .
function testStatesInSubtree(aAccOrElmOrID, aState, aExtraState, aAbsentState)
{
  var acc = getAccessible(aAccOrElmOrID);
  if (!acc)
    return;
  if (getRole(acc) != ROLE_TEXT_LEAF)
    testStates(acc, aState, aExtraState, aAbsentState);
  var children = null;
  try {
    children = acc.children;
  } catch(e) {}
  ok(children, "Could not get children for " + aAccOrElmOrID +"!");
  if (children) {
    for (var i = 0; i < children.length; i++) {
      var childAcc = children.queryElementAt(i, nsIAccessible);
      testStatesInSubtree(childAcc, aState, aExtraState, aAbsentState);
    }
  }
}
function testStatesInSubtree ( aAccOrElmOrID , aState , aExtraState , aAbsentState ) { var acc = getAccessible ( aAccOrElmOrID ) ; if ( ! acc ) return ; if ( getRole ( acc ) != ROLE_TEXT_LEAF ) testStates ( acc , aState , aExtraState , aAbsentState ) ; var children = null ; try { children = acc . children ; } catch ( e ) { } ok ( children , "Could not get children for " + aAccOrElmOrID + "!" ) ; if ( children ) { for ( var i = 0 ; i < children . length ; i ++ ) { var childAcc = children . queryElementAt ( i , nsIAccessible ) ; testStatesInSubtree ( childAcc , aState , aExtraState , aAbsentState ) ; } } }
Tests an acessible and its sub tree for the passed in state bits.
Tests an acessible and its sub tree for the passed in state bits .
// test accessible and its subtree for propagated states. // Right now, text leafs don't get tested because the states are not being // propagated. // Iterate over its children to see if the state got propagated.