1
1
module ( "offset" ) ;
2
2
3
+ var supportsScroll = false ;
4
+
3
5
testoffset ( "absolute" /* in iframe */ , function ( $ , iframe ) {
4
6
expect ( 4 ) ;
5
7
@@ -10,6 +12,12 @@ testoffset("absolute"/* in iframe */, function($, iframe) {
10
12
// if the offset method is using the scroll offset
11
13
// of the parent window
12
14
var forceScroll = jQuery ( '<div>' , { width : 2000 , height : 2000 } ) . appendTo ( 'body' ) ;
15
+ window . scrollTo ( 200 , 200 ) ;
16
+
17
+ if ( document . documentElement . scrollTop || document . body . scrollTop ) {
18
+ supportsScroll = true ;
19
+ }
20
+
13
21
window . scrollTo ( 1 , 1 ) ;
14
22
15
23
// get offset
@@ -256,8 +264,13 @@ testoffset("fixed", function( jQuery ) {
256
264
{ id : '#fixed-1' , top : 1001 , left : 1001 } ,
257
265
{ id : '#fixed-2' , top : 1021 , left : 1021 }
258
266
] ;
267
+
259
268
jQuery . each ( tests , function ( ) {
260
- if ( jQuery . offset . supportsFixedPosition ) {
269
+ if ( ! supportsScroll ) {
270
+ ok ( true , "Browser doesn't support scroll position." ) ;
271
+ ok ( true , "Browser doesn't support scroll position." ) ;
272
+
273
+ } else if ( jQuery . offset . supportsFixedPosition ) {
261
274
equals ( jQuery ( this . id ) . offset ( ) . top , this . top , "jQuery('" + this . id + "').offset().top" ) ;
262
275
equals ( jQuery ( this . id ) . offset ( ) . left , this . left , "jQuery('" + this . id + "').offset().left" ) ;
263
276
} else {
@@ -335,12 +348,20 @@ testoffset("scroll", function( jQuery, win ) {
335
348
// equals( jQuery('body').scrollLeft(), 0, "jQuery('body').scrollTop()" );
336
349
337
350
win . name = "test" ;
338
-
339
- equals ( jQuery ( win ) . scrollTop ( ) , 1000 , "jQuery(window).scrollTop()" ) ;
340
- equals ( jQuery ( win ) . scrollLeft ( ) , 1000 , "jQuery(window).scrollLeft()" ) ;
341
-
342
- equals ( jQuery ( win . document ) . scrollTop ( ) , 1000 , "jQuery(document).scrollTop()" ) ;
343
- equals ( jQuery ( win . document ) . scrollLeft ( ) , 1000 , "jQuery(document).scrollLeft()" ) ;
351
+
352
+ if ( ! supportsScroll ) {
353
+ ok ( true , "Browser doesn't support scroll position." ) ;
354
+ ok ( true , "Browser doesn't support scroll position." ) ;
355
+
356
+ ok ( true , "Browser doesn't support scroll position." ) ;
357
+ ok ( true , "Browser doesn't support scroll position." ) ;
358
+ } else {
359
+ equals ( jQuery ( win ) . scrollTop ( ) , 1000 , "jQuery(window).scrollTop()" ) ;
360
+ equals ( jQuery ( win ) . scrollLeft ( ) , 1000 , "jQuery(window).scrollLeft()" ) ;
361
+
362
+ equals ( jQuery ( win . document ) . scrollTop ( ) , 1000 , "jQuery(document).scrollTop()" ) ;
363
+ equals ( jQuery ( win . document ) . scrollLeft ( ) , 1000 , "jQuery(document).scrollLeft()" ) ;
364
+ }
344
365
345
366
// test jQuery using parent window/document
346
367
// jQuery reference here is in the iframe
0 commit comments