Skip to content

Commit 26b6d70

Browse files
juangjlukeis
authored andcommitted
Improve comments and error message on scrolling_test#testScrollingAccountsForScrollbarWidths.
Partially reverts eda96a0. That commit implies that the test was scrolling exactly 26px, which is incorrect behavior; lowering the threshold to 25px defeats the purpose of the test. Signed-off-by: Luke Inman-Semerau <[email protected]>
1 parent ca1e60e commit 26b6d70

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

javascript/atoms/test/scrolling_test.html

+18-11
Original file line numberDiff line numberDiff line change
@@ -209,23 +209,30 @@
209209
bot.action.scrollIntoView(elem, new goog.math.Coordinate(75, 75));
210210
var rectAfter = bot.dom.getClientRect(elem);
211211

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+
218220
// This should fail on mobile and tablet since the scrollbars aren't shown.
219221
// This should also fail on IE6 since scrolling only happens to
220222
// exactly the scrollbar width, which is 17 by default on Windows XP.
221223
expectedFailures.expectFailureFor(
222224
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+
224227
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);
229236
});
230237
}
231238
</script>

0 commit comments

Comments
 (0)