@@ -11,7 +11,7 @@ test("disconnected node", function() {
11
11
12
12
var supportsScroll = false ;
13
13
14
- testoffset ( "absolute" , function ( $ , iframe ) {
14
+ testIframe ( "offset/absolute" , "absolute" , function ( $ , iframe ) {
15
15
expect ( 4 ) ;
16
16
17
17
var doc = iframe . document , tests ;
@@ -51,7 +51,7 @@ testoffset("absolute", function($, iframe) {
51
51
forceScroll . remove ( ) ;
52
52
} ) ;
53
53
54
- testoffset ( "absolute" , function ( jQuery ) {
54
+ testIframe ( "offset/absolute" , "absolute" , function ( jQuery ) {
55
55
expect ( 178 ) ;
56
56
57
57
// get offset tests
@@ -136,7 +136,7 @@ testoffset("absolute", function( jQuery ) {
136
136
} ) ;
137
137
} ) ;
138
138
139
- testoffset ( "relative" , function ( jQuery ) {
139
+ testIframe ( "offset/relative" , "relative" , function ( jQuery ) {
140
140
expect ( 60 ) ;
141
141
142
142
// IE is collapsing the top margin of 1px
@@ -197,7 +197,7 @@ testoffset("relative", function( jQuery ) {
197
197
} ) ;
198
198
} ) ;
199
199
200
- testoffset ( "static" , function ( jQuery ) {
200
+ testIframe ( "offset/static" , "static" , function ( jQuery ) {
201
201
expect ( 80 ) ;
202
202
203
203
// IE is collapsing the top margin of 1px
@@ -264,7 +264,7 @@ testoffset("static", function( jQuery ) {
264
264
} ) ;
265
265
} ) ;
266
266
267
- testoffset ( "fixed" , function ( jQuery ) {
267
+ testIframe ( "offset/fixed" , "fixed" , function ( jQuery ) {
268
268
expect ( 30 ) ;
269
269
270
270
var tests = [
@@ -331,7 +331,7 @@ testoffset("fixed", function( jQuery ) {
331
331
}
332
332
} ) ;
333
333
334
- testoffset ( "table" , function ( jQuery ) {
334
+ testIframe ( "offset/table" , "table" , function ( jQuery ) {
335
335
expect ( 4 ) ;
336
336
337
337
equal ( jQuery ( "#table-1" ) . offset ( ) . top , 6 , "jQuery('#table-1').offset().top" ) ;
@@ -341,7 +341,7 @@ testoffset("table", function( jQuery ) {
341
341
equal ( jQuery ( "#th-1" ) . offset ( ) . left , 10 , "jQuery('#th-1').offset().left" ) ;
342
342
} ) ;
343
343
344
- testoffset ( "scroll" , function ( jQuery , win ) {
344
+ testIframe ( "offset/scroll" , "scroll" , function ( jQuery , win ) {
345
345
expect ( 24 ) ;
346
346
347
347
var ie = jQuery . browser . msie && parseInt ( jQuery . browser . version , 10 ) < 8 ;
@@ -399,7 +399,7 @@ testoffset("scroll", function( jQuery, win ) {
399
399
strictEqual ( jQuery ( ) . scrollLeft ( ) , null , "jQuery().scrollLeft(100) testing setter on empty jquery object" ) ;
400
400
} ) ;
401
401
402
- testoffset ( "body" , function ( jQuery ) {
402
+ testIframe ( "offset/body" , "body" , function ( jQuery ) {
403
403
expect ( 2 ) ;
404
404
405
405
equal ( jQuery ( "body" ) . offset ( ) . top , 1 , "jQuery('#body').offset().top" ) ;
@@ -466,35 +466,3 @@ test("fractions (see #7730 and #7885)", function() {
466
466
467
467
div . remove ( ) ;
468
468
} ) ;
469
-
470
- function testoffset ( name , fn ) {
471
-
472
- test ( name , function ( ) {
473
- // pause execution for now
474
- stop ( ) ;
475
-
476
- // load fixture in iframe
477
- var iframe = loadFixture ( ) ,
478
- win = iframe . contentWindow ,
479
- interval = setInterval ( function ( ) {
480
- if ( win && win . jQuery && win . jQuery . isReady ) {
481
- clearInterval ( interval ) ;
482
- // continue
483
- start ( ) ;
484
- // call actual tests passing the correct jQuery isntance to use
485
- fn . call ( this , win . jQuery , win ) ;
486
- document . body . removeChild ( iframe ) ;
487
- iframe = null ;
488
- }
489
- } , 15 ) ;
490
- } ) ;
491
-
492
- function loadFixture ( ) {
493
- var src = "./data/offset/" + name + ".html?" + parseInt ( Math . random ( ) * 1000 , 10 ) ,
494
- iframe = jQuery ( "<iframe />" ) . css ( {
495
- width : 500 , height : 500 , position : "absolute" , top : - 600 , left : - 600 , visibility : "hidden"
496
- } ) . appendTo ( "body" ) [ 0 ] ;
497
- iframe . contentWindow . location = src ;
498
- return iframe ;
499
- }
500
- }
0 commit comments