B2G/gecko/testing/peptest/peptest/extension/resource/mozmill/stdlib/EventUtils.js
/**
 * Indicate that an event with an original target of aExpectedTarget and
 * a type of aExpectedEvent is expected to be fired, or not expected to
 * be fired.
 */
Indicate that an event with an original target of aExpectedTarget and
a type of aExpectedEvent is expected to be fired, or not expected to
be fired.
Indicate that an event with an original target of aExpectedTarget and a type of aExpectedEvent is expected to be fired or not expected to be fired .
function _expectEvent(aExpectedTarget, aExpectedEvent, aTestName)
{
  if (!aExpectedTarget || !aExpectedEvent)
    return null;
  _gSeenEvent = false;
  var type = (aExpectedEvent.charAt(0) == "!") ?
             aExpectedEvent.substring(1) : aExpectedEvent;
  var eventHandler = function(event) {
    var epassed = (!_gSeenEvent && event.originalTarget == aExpectedTarget &&
                   event.type == type);
    if (!epassed)
      throw new Error(aTestName + " " + type + " event target " +
                      (_gSeenEvent ? "twice" : ""));
    _gSeenEvent = true;
  };
  aExpectedTarget.addEventListener(type, eventHandler, false);
  return eventHandler;
}
function _expectEvent ( aExpectedTarget , aExpectedEvent , aTestName ) { if ( ! aExpectedTarget || ! aExpectedEvent ) return null ; _gSeenEvent = false ; var type = ( aExpectedEvent . charAt ( 0 ) == "!" ) ? aExpectedEvent . substring ( 1 ) : aExpectedEvent ; var eventHandler = function ( event ) { var epassed = ( ! _gSeenEvent && event . originalTarget == aExpectedTarget && event . type == type ) ; if ( ! epassed ) throw new Error ( aTestName + " " + type + " event target " + ( _gSeenEvent ? "twice" : "" ) ) ; _gSeenEvent = true ; } ; aExpectedTarget . addEventListener ( type , eventHandler , false ) ; return eventHandler ; }
Indicate that an event with an original target of aExpectedTarget and
 a type of aExpectedEvent is expected to be fired, or not expected to
 be fired.
Indicate that an event with an original target of aExpectedTarget and a type of aExpectedEvent is expected to be fired or not expected to be fired .