Skip to content

Commit aac8e08

Browse files
committed
Firefox: Fixing issue #1509
1 parent 1583ef1 commit aac8e08

2 files changed

Lines changed: 27 additions & 21 deletions

File tree

javascript/atoms/mouse.js

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -298,26 +298,29 @@ bot.Mouse.prototype.releaseButton = function(opt_force, opt_count) {
298298
bot.dom.isInteractable(this.getElement());
299299
this.fireMouseEvent_(bot.events.EventType.MOUSEUP, null, null, opt_force, opt_count);
300300

301-
// TODO: Middle button can also trigger click.
302-
if (this.buttonPressed_ == bot.Mouse.Button.LEFT &&
303-
this.getElement() == this.elementPressed_) {
304-
if (!(bot.userAgent.WINDOWS_PHONE &&
305-
bot.dom.isElement(this.elementPressed_, goog.dom.TagName.OPTION))) {
306-
this.clickElement(this.clientXY_,
307-
this.getButtonValue_(bot.events.EventType.CLICK),
308-
/* opt_force */ elementInteractableBeforeMouseup);
309-
}
310-
this.maybeDoubleClickElement_();
311-
if (bot.userAgent.IE_DOC_10 &&
312-
this.buttonPressed_ == bot.Mouse.Button.LEFT &&
313-
bot.dom.isElement(this.elementPressed_, goog.dom.TagName.OPTION)) {
314-
this.fireMSPointerEvent(bot.events.EventType.MSLOSTPOINTERCAPTURE,
315-
new goog.math.Coordinate(0, 0), 0, bot.Device.MOUSE_MS_POINTER_ID,
316-
MSPointerEvent.MSPOINTER_TYPE_MOUSE, false);
301+
try { // https://github.com/SeleniumHQ/selenium/issues/1509
302+
// TODO: Middle button can also trigger click.
303+
if (this.buttonPressed_ == bot.Mouse.Button.LEFT &&
304+
this.getElement() == this.elementPressed_) {
305+
if (!(bot.userAgent.WINDOWS_PHONE &&
306+
bot.dom.isElement(this.elementPressed_, goog.dom.TagName.OPTION))) {
307+
this.clickElement(this.clientXY_,
308+
this.getButtonValue_(bot.events.EventType.CLICK),
309+
/* opt_force */ elementInteractableBeforeMouseup);
310+
}
311+
this.maybeDoubleClickElement_();
312+
if (bot.userAgent.IE_DOC_10 &&
313+
this.buttonPressed_ == bot.Mouse.Button.LEFT &&
314+
bot.dom.isElement(this.elementPressed_, goog.dom.TagName.OPTION)) {
315+
this.fireMSPointerEvent(bot.events.EventType.MSLOSTPOINTERCAPTURE,
316+
new goog.math.Coordinate(0, 0), 0, bot.Device.MOUSE_MS_POINTER_ID,
317+
MSPointerEvent.MSPOINTER_TYPE_MOUSE, false);
318+
}
319+
// TODO: In Linux, this fires after mousedown event.
320+
} else if (this.buttonPressed_ == bot.Mouse.Button.RIGHT) {
321+
this.fireMouseEvent_(bot.events.EventType.CONTEXTMENU);
317322
}
318-
// TODO: In Linux, this fires after mousedown event.
319-
} else if (this.buttonPressed_ == bot.Mouse.Button.RIGHT) {
320-
this.fireMouseEvent_(bot.events.EventType.CONTEXTMENU);
323+
} catch (ignored) {
321324
}
322325
bot.Device.clearPointerMap();
323326
this.buttonPressed_ = null;

javascript/firefox-driver/js/syntheticMouse.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,12 @@ SyntheticMouse.prototype.click = function(target) {
300300
bot.action.click(element, this.lastMousePosition, this.getMouse_(), true);
301301
}
302302

303-
if (bot.dom.isEditable(element) && element.value !== undefined) {
304-
goog.dom.selection.setCursorPosition(
303+
try { // https://github.com/SeleniumHQ/selenium/issues/1509
304+
if (bot.dom.isEditable(element) && element.value !== undefined) {
305+
goog.dom.selection.setCursorPosition(
305306
element, element.value.length);
307+
}
308+
} catch (ignored) {
306309
}
307310

308311
this.lastElement = element;

0 commit comments

Comments
 (0)