Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Allow the IeMouseEventSequenceSimulator to use pointer events as well.
Browse files Browse the repository at this point in the history
cl/192146770 (6ea4f12) (6ea4f12) introduced pointer event support for goog.ui.Component and Control, but only wired it up to the main mouse handling flow. This just does the same for the IeMouseEventSequenceSimulator. Without this, controls that are opted into pointer events would receive an out-of-flow/order set of mouse events in addition to the pointer events.

RELNOTES: Ensure that IE mouse event sequence handling works well with pointer events if control mouse handling is set to use pointer events.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=262134795
  • Loading branch information
shicks committed Aug 13, 2019
1 parent 083c1cc commit 9ba0042
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
7 changes: 4 additions & 3 deletions closure/goog/ui/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -1494,9 +1494,10 @@ goog.ui.Control.IeMouseEventSequenceSimulator_ = function(control) {
this.registerDisposable(this.handler_);

var element = this.control_.getElementStrict();
this.handler_
.listen(element, goog.events.EventType.MOUSEDOWN, this.handleMouseDown_)
.listen(element, goog.events.EventType.MOUSEUP, this.handleMouseUp_)
var MouseEventType = goog.ui.ComponentUtil.getMouseEventType(control);

this.handler_.listen(element, MouseEventType.MOUSEDOWN, this.handleMouseDown_)
.listen(element, MouseEventType.MOUSEUP, this.handleMouseUp_)
.listen(element, goog.events.EventType.CLICK, this.handleClick_);
};
goog.inherits(goog.ui.Control.IeMouseEventSequenceSimulator_, goog.Disposable);
Expand Down
28 changes: 28 additions & 0 deletions closure/goog/ui/control_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2761,6 +2761,34 @@ function testIeMouseEventSequenceSimulator() {
'an isolated click ');
}

function testIeMouseEventSequenceSimulator_withPointerEvents() {
control.setPointerEventsEnabled(true);
control.render(sandbox);

if (goog.userAgent.IE) {
// For some reason in IE8 and perhaps earlier, isolated clicks do not result
// a detectable dispatch of an ACTION event, so we'll only assert the
// desired handling of isolated clicks in IE9 and higher.
if (goog.userAgent.isVersionOrHigher(9)) {
assertIsolatedClickFires(
'ACTION event expected after an isolated click immediately ' +
'following a click sequence');
assertIsolatedClickFires(
'ACTION event expected after second consecutive isolated click');
} else {
// For IE8-and-lower, fire an isolated click event in preparation for our
// final assertion.
goog.testing.events.fireClickEvent(control.getKeyEventTarget());
}
} else {
assertIsolatedClickDoesNotFire(
'No ACTION event expected after an isolated click immediately ' +
'following a click sequence');
assertIsolatedClickDoesNotFire(
'No ACTION event expected after second consecutive isolated click');
}
}

function testIeMouseEventSequenceSimulatorStrictMode() {
if (!document.createEvent) {
return;
Expand Down

0 comments on commit 9ba0042

Please sign in to comment.