B2G/gecko/accessible/tests/mochitest/events.js
/**
 * Change the current item when the widget doesn't have a focus.
 */
Change the current item when the widget doesn't have a focus.
Change the current item when the widget doesn ' t have a focus .
function changeCurrentItem(aID, aItemID)
{
  this.eventSeq = [ new nofocusChecker() ];
  this.invoke = function changeCurrentItem_invoke()
  {
    var controlNode = getNode(aID);
    var itemNode = getNode(aItemID);
    if (controlNode.localName == "input") {
      if (controlNode.checked)
        this.reportError();
      controlNode.checked = true;
      return;
    }
    if (controlNode.localName == "select") {
      if (controlNode.selectedIndex == itemNode.index)
        this.reportError();
      controlNode.selectedIndex = itemNode.index;
      return;
    }
    if (controlNode.localName == "tree") {
      if (controlNode.currentIndex == aItemID)
        this.reportError();
      controlNode.currentIndex = aItemID;
      return;
    }
    if (controlNode.localName == "menulist") {
      if (controlNode.selectedItem == itemNode)
        this.reportError();
      controlNode.selectedItem = itemNode;
      return;
    }
    if (controlNode.currentItem == itemNode)
      ok(false, "Error in test: proposed current item is already current" + prettyName(aID));
    controlNode.currentItem = itemNode;
  }
  this.getID = function changeCurrentItem_getID()
  {
    return "current item change for " + prettyName(aID);
  }
  this.reportError = function changeCurrentItem_reportError()
  {
    ok(false,
       "Error in test: proposed current item '" + aItemID + "' is already current");
  }
}
function changeCurrentItem ( aID , aItemID ) { this . eventSeq = [ new nofocusChecker ( ) ] ; this . invoke = function changeCurrentItem_invoke ( ) { var controlNode = getNode ( aID ) ; var itemNode = getNode ( aItemID ) ; if ( controlNode . localName == "input" ) { if ( controlNode . checked ) this . reportError ( ) ; controlNode . checked = true ; return ; } if ( controlNode . localName == "select" ) { if ( controlNode . selectedIndex == itemNode . index ) this . reportError ( ) ; controlNode . selectedIndex = itemNode . index ; return ; } if ( controlNode . localName == "tree" ) { if ( controlNode . currentIndex == aItemID ) this . reportError ( ) ; controlNode . currentIndex = aItemID ; return ; } if ( controlNode . localName == "menulist" ) { if ( controlNode . selectedItem == itemNode ) this . reportError ( ) ; controlNode . selectedItem = itemNode ; return ; } if ( controlNode . currentItem == itemNode ) ok ( false , "Error in test: proposed current item is already current" + prettyName ( aID ) ) ; controlNode . currentItem = itemNode ; } this . getID = function changeCurrentItem_getID ( ) { return "current item change for " + prettyName ( aID ) ; } this . reportError = function changeCurrentItem_reportError ( ) { ok ( false , "Error in test: proposed current item '" + aItemID + "' is already current" ) ; } }
Change the current item when the widget doesn't have a focus.
Change the current item when the widget doesn ' t have a focus .
// HTML // XUL