|
32 | 32 | var SUBPIXEL_PRECISION_SUPPORTED = !CLICKING_WITH_COORDINATES_BROKEN &&
|
33 | 33 | !goog.userAgent.product.CHROME && !goog.userAgent.product.FIREFOX;
|
34 | 34 |
|
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 | + |
36 | 45 | if (SUBPIXEL_PRECISION_SUPPORTED) {
|
37 |
| - return num; |
| 46 | + return elementTopLeftCorner + offset; |
38 | 47 | } else {
|
39 | 48 | // When browser doesn't support subpixel (for event coords) it truncates to integers.
|
40 |
| - return Math.floor(num); |
| 49 | + return Math.floor(elementTopLeftCorner + offset); |
41 | 50 | }
|
42 | 51 | }
|
43 | 52 |
|
|
96 | 105 | 'id=location', 'mouseup', offsetX + ',' + offsetY);
|
97 | 106 |
|
98 | 107 | 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); |
101 | 110 | }
|
102 | 111 |
|
103 | 112 | function testFiringEventsAtAParticularLocationWillDefaultToTopLeft() {
|
|
118 | 127 | core.events.fireAt('id=location', goog.events.EventType.MOUSEUP);
|
119 | 128 |
|
120 | 129 | 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); |
123 | 132 | }
|
124 | 133 |
|
125 | 134 | function testCanOverrideTheValueOfAnInputElement() {
|
|
0 commit comments