B2G/gecko/testing/peptest/peptest/extension/resource/mozmill/stdlib/EventUtils.js
/**
 * Synthesize a mouse event on a target. The actual client point is determined
 * by taking the aTarget's client box and offseting it by aOffsetX and
 * aOffsetY. This allows mouse clicks to be simulated by calling this method.
 *
 * aEvent is an object which may contain the properties:
 *   shiftKey, ctrlKey, altKey, metaKey, accessKey, clickCount, button, type
 *
 * If the type is specified, an mouse event of that type is fired. Otherwise,
 * a mousedown followed by a mouse up is performed.
 *
 * aWindow is optional, and defaults to the current window object.
 */
Synthesize a mouse event on a target. The actual client point is determined
by taking the aTarget's client box and offseting it by aOffsetX and
aOffsetY. This allows mouse clicks to be simulated by calling this method.

aEvent is an object which may contain the properties:
shiftKey, ctrlKey, altKey, metaKey, accessKey, clickCount, button, type

If the type is specified, an mouse event of that type is fired. Otherwise,
a mousedown followed by a mouse up is performed.

aWindow is optional, and defaults to the current window object.
Synthesize a mouse event on a target . The actual client point is determined by taking the aTarget ' s client box and offseting it by aOffsetX and aOffsetY . This allows mouse clicks to be simulated by calling this method . aEvent is an object which may contain the properties : shiftKey ctrlKey altKey metaKey accessKey clickCount button type If the type is specified an mouse event of that type is fired . Otherwise a mousedown followed by a mouse up is performed . aWindow is optional and defaults to the current window object .
function synthesizeMouse(aTarget, aOffsetX, aOffsetY, aEvent, aWindow)
{
  if (!aWindow)
    aWindow = window;
  var utils = aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
                      getInterface(Components.interfaces.nsIDOMWindowUtils);
  if (utils) {
    var button = aEvent.button || 0;
    var clickCount = aEvent.clickCount || 1;
    var modifiers = _parseModifiers(aEvent);
    var rect = aTarget.getBoundingClientRect();
    var left = rect.left + aOffsetX;
    var top = rect.top + aOffsetY;
    if (("type" in aEvent) && aEvent.type) {
      utils.sendMouseEvent(aEvent.type, left, top, button, clickCount, modifiers);
    }
    else {
      utils.sendMouseEvent("mousedown", left, top, button, clickCount, modifiers);
      utils.sendMouseEvent("mouseup", left, top, button, clickCount, modifiers);
    }
  }
}
function synthesizeMouse ( aTarget , aOffsetX , aOffsetY , aEvent , aWindow ) { if ( ! aWindow ) aWindow = window ; var utils = aWindow . QueryInterface ( Components . interfaces . nsIInterfaceRequestor ) . getInterface ( Components . interfaces . nsIDOMWindowUtils ) ; if ( utils ) { var button = aEvent . button || 0 ; var clickCount = aEvent . clickCount || 1 ; var modifiers = _parseModifiers ( aEvent ) ; var rect = aTarget . getBoundingClientRect ( ) ; var left = rect . left + aOffsetX ; var top = rect . top + aOffsetY ; if ( ( "type" in aEvent ) && aEvent . type ) { utils . sendMouseEvent ( aEvent . type , left , top , button , clickCount , modifiers ) ; } else { utils . sendMouseEvent ( "mousedown" , left , top , button , clickCount , modifiers ) ; utils . sendMouseEvent ( "mouseup" , left , top , button , clickCount , modifiers ) ; } } }
Synthesize a mouse event on a target.
Synthesize a mouse event on a target .