|
209 | 209 | bot.action.scrollIntoView(elem, new goog.math.Coordinate(75, 75));
|
210 | 210 | var rectAfter = bot.dom.getClientRect(elem);
|
211 | 211 |
|
212 |
| - // Seems like chrome on MacOs is stealing a pixel |
213 |
| - var expected = goog.labs.userAgent.browser.isChrome() && goog.labs.userAgent.platform.isMacintosh() ? |
214 |
| - 25 : 26; |
215 |
| - |
216 |
| - // If the scrollbar isn't taken into account, the minimum scrolling |
217 |
| - // needed would be 26 pixels, to bring the full pixel into view. |
| 212 | + var horizontalScroll = rectBefore.left - rectAfter.left; |
| 213 | + var verticalScroll = rectBefore.top - rectAfter.top; |
| 214 | + |
| 215 | + // In the absence of a scrollbar, the minimum scrolling needed to bring |
| 216 | + // the full pixel into view would be 26 pixels. There is a scrollbar, |
| 217 | + // however; scrollIntoView should scroll 26px plus the scrollbar |
| 218 | + // width/height. |
| 219 | + |
218 | 220 | // This should fail on mobile and tablet since the scrollbars aren't shown.
|
219 | 221 | // This should also fail on IE6 since scrolling only happens to
|
220 | 222 | // exactly the scrollbar width, which is 17 by default on Windows XP.
|
221 | 223 | expectedFailures.expectFailureFor(
|
222 | 224 | goog.labs.userAgent.device.isMobile() || goog.labs.userAgent.device.isTablet() ||
|
223 |
| - (goog.userAgent.IE && !goog.userAgent.isVersion(7))); |
| 225 | + (goog.userAgent.IE && !goog.userAgent.isVersion(7))); |
| 226 | + |
224 | 227 | expectedFailures.run(function() {
|
225 |
| - assertTrue('horizontal scroll did not account for scrollbar' + (rectBefore.left - rectAfter.left), |
226 |
| - rectBefore.left - rectAfter.left > expected); |
227 |
| - assertTrue('vertical scroll did not account for scrollbar', |
228 |
| - rectBefore.top - rectAfter.top > 26); |
| 228 | + assertTrue('Horizontal scroll did not account for scrollbar. ' + |
| 229 | + 'It scrolled ' + horizontalScroll + 'px, but should have ' + |
| 230 | + 'scrolled at least 26px plus the scrollbar width.', |
| 231 | + horizontalScroll > 26); |
| 232 | + assertTrue('Vertical scroll did not account for scrollbar. ' + |
| 233 | + 'It scrolled ' + verticalScroll + 'px, but should have ' + |
| 234 | + 'scrolled at least 26px plus the scrollbar height.', |
| 235 | + verticalScroll > 26); |
229 | 236 | });
|
230 | 237 | }
|
231 | 238 | </script>
|
|
0 commit comments