Namespace goog.testing.events code » Show: Public Protected Private
Global Functions Asserts an event target exists. This will fail if target is not defined.
TODO(nnaze): Gradually add this to the methods in this file, and eventually
update the method signatures to not take nullables. See http://b/8961907
Parameters target: EventTarget
A target to assert. Returns The target, guaranteed to exist.
Simulate a blur event on the given target.
Parameters target: EventTarget
The target for the event. Returns The value returned by firing the blur browser event,
which returns false iff 'preventDefault' was invoked.
Simulates an event's capturing and bubbling phases.
Parameters event: Event
A simulated native event. It will be wrapped in a
normalized BrowserEvent and dispatched to Closure listeners on all
ancestors of its target (inclusive). Returns The returnValue of the event: false if preventDefault() was
called on it, true otherwise.
Simulates a click event on the given target. IE only supports click with
the left mouse button.
Parameters target: EventTarget
The target for the event. opt_button: goog.events.BrowserEvent.MouseButton =
Mouse button;
defaults to goog.events.BrowserEvent.MouseButton.LEFT
. opt_coords: goog.math.Coordinate =
Mouse position. Defaults to event's
target's position (if available), otherwise (0, 0). opt_eventProperties: Object =
Event properties to be mixed into the
BrowserEvent. Returns The returnValue of the event: false if preventDefault() was
called on it, true otherwise.
Simulates a mousedown, mouseup, and then click on the given event target,
with the left mouse button.
Parameters target: EventTarget
The target for the event. opt_button: goog.events.BrowserEvent.MouseButton =
Mouse button;
defaults to goog.events.BrowserEvent.MouseButton.LEFT
. opt_coords: goog.math.Coordinate =
Mouse position. Defaults to event's
target's position (if available), otherwise (0, 0). opt_eventProperties: Object =
Event properties to be mixed into the
BrowserEvent. Returns The returnValue of the sequence: false if preventDefault()
was called on any of the events, true otherwise.
Simulates a contextmenu event on the given target.
Parameters target: EventTarget
The target for the event. opt_coords: goog.math.Coordinate =
Mouse position. Defaults to event's
target's position (if available), otherwise (0, 0). Returns The returnValue of the event: false if preventDefault() was
called on it, true otherwise.
Simulates a mousedown, contextmenu, and the mouseup on the given event
target, with the right mouse button.
Parameters target: EventTarget
The target for the event. opt_coords: goog.math.Coordinate =
Mouse position. Defaults to event's
target's position (if available), otherwise (0, 0). Returns The returnValue of the sequence: false if preventDefault()
was called on any of the events, true otherwise.
Simulates a double-click event on the given target. Always double-clicks
with the left mouse button since no browser supports double-clicking with
any other buttons.
Parameters target: EventTarget
The target for the event. opt_coords: goog.math.Coordinate =
Mouse position. Defaults to event's
target's position (if available), otherwise (0, 0). opt_eventProperties: Object =
Event properties to be mixed into the
BrowserEvent. Returns The returnValue of the event: false if preventDefault() was
called on it, true otherwise.
Simulates the sequence of events fired by the browser when the user double-
clicks the given target.
Parameters target: EventTarget
The target for the event. opt_coords: goog.math.Coordinate =
Mouse position. Defaults to event's
target's position (if available), otherwise (0, 0). opt_eventProperties: Object =
Event properties to be mixed into the
BrowserEvent. Returns The returnValue of the sequence: false if preventDefault()
was called on any of the events, true otherwise.
Simulate a focus event on the given target.
Parameters target: EventTarget
The target for the event. Returns The value returned by firing the focus browser event,
which returns false iff 'preventDefault' was invoked.
Simulates a complete keystroke (keydown, keypress, and keyup). Note that
if preventDefault is called on the keydown, the keypress will not fire.
Parameters target: EventTarget
The target for the event. keyCode: number
The keycode of the key pressed. opt_eventProperties: Object =
Event properties to be mixed into the
BrowserEvent. Returns The returnValue of the sequence: false if preventDefault()
was called on any of the events, true otherwise.
Helper function to fire a mouse event.
with the left mouse button since no browser supports double-clicking with
any other buttons.
Parameters type: string
The event type. target: EventTarget
The target for the event. opt_button: number =
Mouse button; defaults to
goog.events.BrowserEvent.MouseButton.LEFT
. opt_coords: goog.math.Coordinate =
Mouse position. Defaults to event's
target's position (if available), otherwise (0, 0). opt_eventProperties: Object =
Event properties to be mixed into the
BrowserEvent. Returns The returnValue of the event: false if preventDefault() was
called on it, true otherwise.
Simulates a mousedown event on the given target.
Parameters target: EventTarget
The target for the event. opt_button: goog.events.BrowserEvent.MouseButton =
Mouse button;
defaults to goog.events.BrowserEvent.MouseButton.LEFT
. opt_coords: goog.math.Coordinate =
Mouse position. Defaults to event's
target's position (if available), otherwise (0, 0). opt_eventProperties: Object =
Event properties to be mixed into the
BrowserEvent. Returns The returnValue of the event: false if preventDefault() was
called on it, true otherwise.
Simulates a mousemove event on the given target.
Parameters target: EventTarget
The target for the event. opt_coords: goog.math.Coordinate =
Mouse position. Defaults to event's
target's position (if available), otherwise (0, 0). Returns The returnValue of the event: false if preventDefault() was
called on it, true otherwise.
Simulates a mouseout event on the given target.
Parameters target: EventTarget
The target for the event. relatedTarget: EventTarget
The related target for the event (e.g.,
the node that the mouse is being moved into). opt_coords: goog.math.Coordinate =
Mouse position. Defaults to event's
target's position (if available), otherwise (0, 0). Returns The returnValue of the event: false if preventDefault() was
called on it, true otherwise.
Simulates a mouseover event on the given target.
Parameters target: EventTarget
The target for the event. relatedTarget: EventTarget
The related target for the event (e.g.,
the node that the mouse is being moved out of). opt_coords: goog.math.Coordinate =
Mouse position. Defaults to event's
target's position (if available), otherwise (0, 0). Returns The returnValue of the event: false if preventDefault() was
called on it, true otherwise.
Simulates a mouseup event on the given target.
Parameters target: EventTarget
The target for the event. opt_button: goog.events.BrowserEvent.MouseButton =
Mouse button;
defaults to goog.events.BrowserEvent.MouseButton.LEFT
. opt_coords: goog.math.Coordinate =
Mouse position. Defaults to event's
target's position (if available), otherwise (0, 0). opt_eventProperties: Object =
Event properties to be mixed into the
BrowserEvent. Returns The returnValue of the event: false if preventDefault() was
called on it, true otherwise.
Simulates a complete keystroke (keydown, keypress, and keyup) when typing
a non-ASCII character. Same as fireKeySequence, the keypress will not fire
if preventDefault is called on the keydown.
Parameters target: EventTarget
The target for the event. keyCode: number
The keycode of the keydown and keyup events. keyPressKeyCode: number
The keycode of the keypress event. opt_eventProperties: Object =
Event properties to be mixed into the
BrowserEvent. Returns The returnValue of the sequence: false if preventDefault()
was called on any of the events, true otherwise.
Simulates a popstate event on the given target.
Parameters target: EventTarget
The target for the event. state: Object
History state object. Returns The returnValue of the event: false if preventDefault() was
called on it, true otherwise.
Simulates a touchend event on the given target.
Parameters target: EventTarget
The target for the event. opt_coords: goog.math.Coordinate =
Touch position. Defaults to event's
target's position (if available), otherwise (0, 0). opt_eventProperties: Object =
Event properties to be mixed into the
BrowserEvent. Returns The returnValue of the event: false if preventDefault() was
called on it, true otherwise.
Simulates a touchmove event on the given target.
Parameters target: EventTarget
The target for the event. opt_coords: goog.math.Coordinate =
Touch position. Defaults to event's
target's position (if available), otherwise (0, 0). opt_eventProperties: Object =
Event properties to be mixed into the
BrowserEvent. Returns The returnValue of the event: false if preventDefault() was
called on it, true otherwise.
Simulates a simple touch sequence on the given target.
Parameters target: EventTarget
The target for the event. opt_coords: goog.math.Coordinate =
Touch position. Defaults to event
target's position (if available), otherwise (0, 0). opt_eventProperties: Object =
Event properties to be mixed into the
BrowserEvent. Returns The returnValue of the sequence: false if preventDefault()
was called on any of the events, true otherwise.
Simulates a touchstart event on the given target.
Parameters target: EventTarget
The target for the event. opt_coords: goog.math.Coordinate =
Touch position. Defaults to event's
target's position (if available), otherwise (0, 0). opt_eventProperties: Object =
Event properties to be mixed into the
BrowserEvent. Returns The returnValue of the event: false if preventDefault() was
called on it, true otherwise.
Parameters e: goog.testing.events.Event
The event. Returns Whether this is the Gecko/Mac's Meta-C/V/X, which
is broken and requires special handling.
Mixins a listenable into the given object. This turns the object
into a goog.events.Listenable. This is useful, for example, when
you need to mock a implementation of listenable and still want it
to work with goog.events.
Parameters obj: !Object
The object to mixin into.
A static helper function that sets the mouse position to the event.
Parameters event: Event
A simulated native event. opt_coords: goog.math.Coordinate =
Mouse position. Defaults to event's
target's position (if available), otherwise (0, 0).
Overview Types Loading
Modules Loading
Files Loading
License