The goog.testing.events Namespace

The goog.testing.events.Event Class

goog.events.BrowserEvent expects an Event so we provide one for JSCompiler. This clones a lot of the functionality of goog.events.Event. This used to use a mixin, but the mixin results in confusing the two types when compiled. … more

The goog.testing.events.EventMatcher Class

A matcher that verifies that an argument is a {@code goog.events.Event} of a particular type. … more

The goog.testing.events.EventObserver Class

Event observer. Implements a handleEvent interface so it may be used as a listener in listening functions and methods. … more

The goog.testing.events.OnlineHandler Class

Mock implementation of goog.events.OnlineHandler. … more

.fireBrowserEvent(event)

Simulates an event's capturing and bubbling phases.

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 {boolean}
The returnValue of the event: false if preventDefault() was called on it, true otherwise.

.fireClickEvent(target, opt_button, opt_coords, opt_eventProperties)

Simulates a click event on the given target. IE only supports click with the left mouse button.

target {EventTarget}
The target for the event.
opt_button {goog.events.BrowserEvent.MouseButton=}
Mouse button; defaults to {@code 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 {boolean}
The returnValue of the event: false if preventDefault() was called on it, true otherwise.

.fireClickSequence(target, opt_button, opt_coords, opt_eventProperties)

Simulates a mousedown, mouseup, and then click on the given event target, with the left mouse button.

target {EventTarget}
The target for the event.
opt_button {goog.events.BrowserEvent.MouseButton=}
Mouse button; defaults to {@code 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 {boolean}
The returnValue of the sequence: false if preventDefault() was called on any of the events, true otherwise.

.fireContextMenuEvent(target, opt_coords)

Simulates a contextmenu event on the given target.

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 {boolean}
The returnValue of the event: false if preventDefault() was called on it, true otherwise.

.fireContextMenuSequence(target, opt_coords)

Simulates a mousedown, contextmenu, and the mouseup on the given event target, with the right mouse button.

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 {boolean}
The returnValue of the sequence: false if preventDefault() was called on any of the events, true otherwise.

.fireDoubleClickEvent(target, opt_coords, opt_eventProperties)

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.

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 {boolean}
The returnValue of the event: false if preventDefault() was called on it, true otherwise.

.fireDoubleClickSequence(target, opt_coords, opt_eventProperties)

Simulates the sequence of events fired by the browser when the user double- clicks the given target.

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 {boolean}
The returnValue of the sequence: false if preventDefault() was called on any of the events, true otherwise.

.fireFocusEvent(target)

Simulate a focus event on the given target.

target {EventTarget}
The target for the event.
returns {boolean}
The value returned by firing the focus browser event, which returns false iff 'preventDefault' was invoked.

.fireKeySequence(target, keyCode, opt_eventProperties)

Simulates a complete keystroke (keydown, keypress, and keyup). Note that if preventDefault is called on the keydown, the keypress will not fire.

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 {boolean}
The returnValue of the sequence: false if preventDefault() was called on any of the events, true otherwise.

.fireMouseDownEvent(target, opt_button, opt_coords, opt_eventProperties)

Simulates a mousedown event on the given target.

target {EventTarget}
The target for the event.
opt_button {goog.events.BrowserEvent.MouseButton=}
Mouse button; defaults to {@code 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 {boolean}
The returnValue of the event: false if preventDefault() was called on it, true otherwise.

.fireMouseMoveEvent(target, opt_coords)

Simulates a mousemove event on the given target.

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 {boolean}
The returnValue of the event: false if preventDefault() was called on it, true otherwise.

.fireMouseOutEvent(target, relatedTarget, opt_coords)

Simulates a mouseout event on the given target.

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 {boolean}
The returnValue of the event: false if preventDefault() was called on it, true otherwise.

.fireMouseOverEvent(target, relatedTarget, opt_coords)

Simulates a mouseover event on the given target.

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 {boolean}
The returnValue of the event: false if preventDefault() was called on it, true otherwise.

.fireMouseUpEvent(target, opt_button, opt_coords, opt_eventProperties)

Simulates a mouseup event on the given target.

target {EventTarget}
The target for the event.
opt_button {goog.events.BrowserEvent.MouseButton=}
Mouse button; defaults to {@code 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 {boolean}
The returnValue of the event: false if preventDefault() was called on it, true otherwise.

.fireNonAsciiKeySequence(target, keyCode, keyPressKeyCode, opt_eventProperties)

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.

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 {boolean}
The returnValue of the sequence: false if preventDefault() was called on any of the events, true otherwise.

.firePopStateEvent(target, state)

Simulates a popstate event on the given target.

target {EventTarget}
The target for the event.
state {Object}
History state object.
returns {boolean}
The returnValue of the event: false if preventDefault() was called on it, true otherwise.