@@ -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 ;
0 commit comments