Skip to content

Commit

Permalink
Firefox: Fixing issue SeleniumHQ#1509
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Jan 31, 2016
1 parent 1583ef1 commit aac8e08
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
41 changes: 22 additions & 19 deletions javascript/atoms/mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,26 +298,29 @@ bot.Mouse.prototype.releaseButton = function(opt_force, opt_count) {
bot.dom.isInteractable(this.getElement());
this.fireMouseEvent_(bot.events.EventType.MOUSEUP, null, null, opt_force, opt_count);

// TODO: Middle button can also trigger click.
if (this.buttonPressed_ == bot.Mouse.Button.LEFT &&
this.getElement() == this.elementPressed_) {
if (!(bot.userAgent.WINDOWS_PHONE &&
bot.dom.isElement(this.elementPressed_, goog.dom.TagName.OPTION))) {
this.clickElement(this.clientXY_,
this.getButtonValue_(bot.events.EventType.CLICK),
/* opt_force */ elementInteractableBeforeMouseup);
}
this.maybeDoubleClickElement_();
if (bot.userAgent.IE_DOC_10 &&
this.buttonPressed_ == bot.Mouse.Button.LEFT &&
bot.dom.isElement(this.elementPressed_, goog.dom.TagName.OPTION)) {
this.fireMSPointerEvent(bot.events.EventType.MSLOSTPOINTERCAPTURE,
new goog.math.Coordinate(0, 0), 0, bot.Device.MOUSE_MS_POINTER_ID,
MSPointerEvent.MSPOINTER_TYPE_MOUSE, false);
try { // https://github.com/SeleniumHQ/selenium/issues/1509
// TODO: Middle button can also trigger click.
if (this.buttonPressed_ == bot.Mouse.Button.LEFT &&
this.getElement() == this.elementPressed_) {
if (!(bot.userAgent.WINDOWS_PHONE &&
bot.dom.isElement(this.elementPressed_, goog.dom.TagName.OPTION))) {
this.clickElement(this.clientXY_,
this.getButtonValue_(bot.events.EventType.CLICK),
/* opt_force */ elementInteractableBeforeMouseup);
}
this.maybeDoubleClickElement_();
if (bot.userAgent.IE_DOC_10 &&
this.buttonPressed_ == bot.Mouse.Button.LEFT &&
bot.dom.isElement(this.elementPressed_, goog.dom.TagName.OPTION)) {
this.fireMSPointerEvent(bot.events.EventType.MSLOSTPOINTERCAPTURE,
new goog.math.Coordinate(0, 0), 0, bot.Device.MOUSE_MS_POINTER_ID,
MSPointerEvent.MSPOINTER_TYPE_MOUSE, false);
}
// TODO: In Linux, this fires after mousedown event.
} else if (this.buttonPressed_ == bot.Mouse.Button.RIGHT) {
this.fireMouseEvent_(bot.events.EventType.CONTEXTMENU);
}
// TODO: In Linux, this fires after mousedown event.
} else if (this.buttonPressed_ == bot.Mouse.Button.RIGHT) {
this.fireMouseEvent_(bot.events.EventType.CONTEXTMENU);
} catch (ignored) {
}
bot.Device.clearPointerMap();
this.buttonPressed_ = null;
Expand Down
7 changes: 5 additions & 2 deletions javascript/firefox-driver/js/syntheticMouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,12 @@ SyntheticMouse.prototype.click = function(target) {
bot.action.click(element, this.lastMousePosition, this.getMouse_(), true);
}

if (bot.dom.isEditable(element) && element.value !== undefined) {
goog.dom.selection.setCursorPosition(
try { // https://github.com/SeleniumHQ/selenium/issues/1509
if (bot.dom.isEditable(element) && element.value !== undefined) {
goog.dom.selection.setCursorPosition(
element, element.value.length);
}
} catch (ignored) {
}

this.lastElement = element;
Expand Down

0 comments on commit aac8e08

Please sign in to comment.