B2G/gecko/accessible/tests/mochitest/events.js
/**
 * Text inserted/removed events checker.
 * @param aFromUser  [in, optional] kNotFromUserInput or kFromUserInput
 */
Text inserted/removed events checker.
Text inserted / removed events checker .
function textChangeChecker(aID, aStart, aEnd, aTextOrFunc, aIsInserted, aFromUser)
{
  this.target = getNode(aID);
  this.type = aIsInserted ? EVENT_TEXT_INSERTED : EVENT_TEXT_REMOVED;
  this.check = function textChangeChecker_check(aEvent)
  {
    aEvent.QueryInterface(nsIAccessibleTextChangeEvent);
    var modifiedText = (typeof aTextOrFunc == "function") ?
      aTextOrFunc() : aTextOrFunc;
    var modifiedTextLen = (aEnd == -1) ? modifiedText.length : aEnd - aStart;
    is(aEvent.start, aStart, "Wrong start offset for " + prettyName(aID));
    is(aEvent.length, modifiedTextLen, "Wrong length for " + prettyName(aID));
    var changeInfo = (aIsInserted ? "inserted" : "removed");
    is(aEvent.isInserted(), aIsInserted,
       "Text was " + changeInfo + " for " + prettyName(aID));
    is(aEvent.modifiedText, modifiedText,
       "Wrong " + changeInfo + " text for " + prettyName(aID));
    if (typeof aFromUser != "undefined")
      is(aEvent.isFromUserInput, aFromUser,
         "wrong value of isFromUserInput() for " + prettyName(aID));
  }
}
function textChangeChecker ( aID , aStart , aEnd , aTextOrFunc , aIsInserted , aFromUser ) { this . target = getNode ( aID ) ; this . type = aIsInserted ? EVENT_TEXT_INSERTED : EVENT_TEXT_REMOVED ; this . check = function textChangeChecker_check ( aEvent ) { aEvent . QueryInterface ( nsIAccessibleTextChangeEvent ) ; var modifiedText = ( typeof aTextOrFunc == "function" ) ? aTextOrFunc ( ) : aTextOrFunc ; var modifiedTextLen = ( aEnd == - 1 ) ? modifiedText . length : aEnd - aStart ; is ( aEvent . start , aStart , "Wrong start offset for " + prettyName ( aID ) ) ; is ( aEvent . length , modifiedTextLen , "Wrong length for " + prettyName ( aID ) ) ; var changeInfo = ( aIsInserted ? "inserted" : "removed" ) ; is ( aEvent . isInserted ( ) , aIsInserted , "Text was " + changeInfo + " for " + prettyName ( aID ) ) ; is ( aEvent . modifiedText , modifiedText , "Wrong " + changeInfo + " text for " + prettyName ( aID ) ) ; if ( typeof aFromUser != "undefined" ) is ( aEvent . isFromUserInput , aFromUser , "wrong value of isFromUserInput() for " + prettyName ( aID ) ) ; } }
Text inserted/removed events checker.
Text inserted / removed events checker .