Skip to content

Commit 3d3b5dd

Browse files
committed
Position: Test for window scrollTop support and run scrolled window test
only when support is there. Should exclude mobile devices, getting the position testsuite to produce more useful results.
1 parent e72afe4 commit 3d3b5dd

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

tests/unit/position/position_core.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ test('of', function() {
139139
left: $(document).width() - 10
140140
}, 'document');
141141

142+
$(window).scrollTop(0);
143+
142144
$('#elx').position({
143145
my: 'right bottom',
144146
at: 'right bottom',
@@ -161,18 +163,24 @@ test('of', function() {
161163
left: $(window).width() - 10
162164
}, 'window');
163165

164-
$(window).scrollTop(500).scrollLeft(200);
165-
$('#elx').position({
166-
my: 'right bottom',
167-
at: 'right bottom',
168-
of: window,
169-
collision: 'none'
170-
});
171-
same($('#elx').offset(), {
172-
top: $(window).height() + 500 - 10,
173-
left: $(window).width() + 200 - 10
174-
}, 'window, scrolled');
175-
$(window).scrollTop(0).scrollLeft(0);
166+
var scrollTopSupport = (function() {
167+
$(window).scrollTop(1);
168+
return $(window).scrollTop() == 1;
169+
})();
170+
if (scrollTopSupport) {
171+
$(window).scrollTop(500).scrollLeft(200);
172+
$('#elx').position({
173+
my: 'right bottom',
174+
at: 'right bottom',
175+
of: window,
176+
collision: 'none'
177+
});
178+
same($('#elx').offset(), {
179+
top: $(window).height() + 500 - 10,
180+
left: $(window).width() + 200 - 10
181+
}, 'window, scrolled');
182+
$(window).scrollTop(0).scrollLeft(0);
183+
}
176184

177185
var event = $.extend($.Event('someEvent'), { pageX: 200, pageY: 300 });
178186
$('#elx').position({

0 commit comments

Comments
 (0)