B2G/gecko/accessible/tests/mochitest/pivot.js
/**
 * A checker for virtual cursor changed events.
 */
A checker for virtual cursor changed events.
A checker for virtual cursor changed events .
function VCChangedChecker(aDocAcc, aIdOrNameOrAcc, aTextOffsets, aPivotMoveMethod)
{
  this.__proto__ = new invokerChecker(EVENT_VIRTUALCURSOR_CHANGED, aDocAcc);
  this.check = function VCChangedChecker_check(aEvent)
  {
    SimpleTest.info("VCChangedChecker_check");
    var event = null;
    try {
      event = aEvent.QueryInterface(nsIAccessibleVirtualCursorChangeEvent);
    } catch (e) {
      SimpleTest.ok(false, "Does not support correct interface: " + e);
    }
    SimpleTest.is(
      event.reason,
      VCChangedChecker.methodReasonMap[aPivotMoveMethod],
      'wrong move reason');
    var position = aDocAcc.virtualCursor.position;
    var idMatches = position && position.DOMNode.id == aIdOrNameOrAcc;
    var nameMatches = position && position.name == aIdOrNameOrAcc;
    var accMatches = position == aIdOrNameOrAcc;
    SimpleTest.ok(idMatches || nameMatches || accMatches, "id or name matches",
                  "expecting " + aIdOrNameOrAcc + ", got '" +
                  prettyName(position));
    if (aTextOffsets) {
      SimpleTest.is(aDocAcc.virtualCursor.startOffset, aTextOffsets[0],
                    "wrong start offset");
      SimpleTest.is(aDocAcc.virtualCursor.endOffset, aTextOffsets[1],
                    "wrong end offset");
    }
    var prevPosAndOffset = VCChangedChecker.
      getPreviousPosAndOffset(aDocAcc.virtualCursor);
    if (prevPosAndOffset) {
      SimpleTest.is(event.oldAccessible, prevPosAndOffset.position,
                    "previous position does not match");
      SimpleTest.is(event.oldStartOffset, prevPosAndOffset.startOffset,
                    "previous start offset does not match");
      SimpleTest.is(event.oldEndOffset, prevPosAndOffset.endOffset,
                    "previous end offset does not match");
    }
  };
}
function VCChangedChecker ( aDocAcc , aIdOrNameOrAcc , aTextOffsets , aPivotMoveMethod ) { this . __proto__ = new invokerChecker ( EVENT_VIRTUALCURSOR_CHANGED , aDocAcc ) ; this . check = function VCChangedChecker_check ( aEvent ) { SimpleTest . info ( "VCChangedChecker_check" ) ; var event = null ; try { event = aEvent . QueryInterface ( nsIAccessibleVirtualCursorChangeEvent ) ; } catch ( e ) { SimpleTest . ok ( false , "Does not support correct interface: " + e ) ; } SimpleTest . is ( event . reason , VCChangedChecker . methodReasonMap [ aPivotMoveMethod ] , 'wrong move reason' ) ; var position = aDocAcc . virtualCursor . position ; var idMatches = position && position . DOMNode . id == aIdOrNameOrAcc ; var nameMatches = position && position . name == aIdOrNameOrAcc ; var accMatches = position == aIdOrNameOrAcc ; SimpleTest . ok ( idMatches || nameMatches || accMatches , "id or name matches" , "expecting " + aIdOrNameOrAcc + ", got '" + prettyName ( position ) ) ; if ( aTextOffsets ) { SimpleTest . is ( aDocAcc . virtualCursor . startOffset , aTextOffsets [ 0 ] , "wrong start offset" ) ; SimpleTest . is ( aDocAcc . virtualCursor . endOffset , aTextOffsets [ 1 ] , "wrong end offset" ) ; } var prevPosAndOffset = VCChangedChecker . getPreviousPosAndOffset ( aDocAcc . virtualCursor ) ; if ( prevPosAndOffset ) { SimpleTest . is ( event . oldAccessible , prevPosAndOffset . position , "previous position does not match" ) ; SimpleTest . is ( event . oldStartOffset , prevPosAndOffset . startOffset , "previous start offset does not match" ) ; SimpleTest . is ( event . oldEndOffset , prevPosAndOffset . endOffset , "previous end offset does not match" ) ; } } ; }
A checker for virtual cursor changed events.
A checker for virtual cursor changed events .