Skip to content

Commit 1a59f58

Browse files
committed
Make event_firing_test.html pass in Firefox 24 ESR.
Moving asserts to tests' main flow in 03feed0 revealed the fact that it never passed in Firefox 24 ESR (apparently it swallows exceptions thrown from the event handlers?).
1 parent 654bf24 commit 1a59f58

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

javascript/selenium-atoms/test/event_firing_test.html

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,21 @@
3232
var SUBPIXEL_PRECISION_SUPPORTED = !CLICKING_WITH_COORDINATES_BROKEN &&
3333
!goog.userAgent.product.CHROME && !goog.userAgent.product.FIREFOX;
3434

35-
function expectedCoordinate(num) {
35+
function expectedEventCoordinate(elementTopLeftCorner, offset) {
36+
// TODO: Delete next 'if' statement when Selenium stops supporting Firefox 24 ESR.
37+
if (goog.userAgent.product.FIREFOX &&
38+
bot.userAgent.isProductVersion(24) &&
39+
!bot.userAgent.isProductVersion(25)) {
40+
// Firefox 24 ESR events have coordinates of the offset
41+
// (relative to top-left corner of the element; not of the viewport).
42+
return offset;
43+
}
44+
3645
if (SUBPIXEL_PRECISION_SUPPORTED) {
37-
return num;
46+
return elementTopLeftCorner + offset;
3847
} else {
3948
// When browser doesn't support subpixel (for event coords) it truncates to integers.
40-
return Math.floor(num);
49+
return Math.floor(elementTopLeftCorner + offset);
4150
}
4251
}
4352

@@ -96,8 +105,8 @@
96105
'id=location', 'mouseup', offsetX + ',' + offsetY);
97106

98107
assertTrue(fired);
99-
assertEquals(expectedCoordinate(clickLocation.left + offsetX), eventClientX);
100-
assertEquals(expectedCoordinate(clickLocation.top + offsetY), eventClientY);
108+
assertEquals(expectedEventCoordinate(clickLocation.left, offsetX), eventClientX);
109+
assertEquals(expectedEventCoordinate(clickLocation.top, offsetY), eventClientY);
101110
}
102111

103112
function testFiringEventsAtAParticularLocationWillDefaultToTopLeft() {
@@ -118,8 +127,8 @@
118127
core.events.fireAt('id=location', goog.events.EventType.MOUSEUP);
119128

120129
assertTrue(fired);
121-
assertEquals(expectedCoordinate(clickLocation.left), eventClientX);
122-
assertEquals(expectedCoordinate(clickLocation.top), eventClientY);
130+
assertEquals(expectedEventCoordinate(clickLocation.left, 0), eventClientX);
131+
assertEquals(expectedEventCoordinate(clickLocation.top, 0), eventClientY);
123132
}
124133

125134
function testCanOverrideTheValueOfAnInputElement() {

0 commit comments

Comments
 (0)