+ // IE is collapsing the top margin of 1px
+ equals( jQuery('#static-1').position().top, ie ? 5 : 6, "jQuery('#static-1').position().top" );
+ equals( jQuery('#static-1').position().left, 6, "jQuery('#static-1').position().left" );
+
+ // IE is collapsing the top margin of 1px
+ equals( jQuery('#static-1-1').position().top, ie ? 12 : 14, "jQuery('#static-1-1').position().top" );
+ equals( jQuery('#static-1-1').position().left, 14, "jQuery('#static-1-1').position().left" );
+
+ // IE is collapsing the top margin of 1px
+ equals( jQuery('#static-1-1-1').position().top, ie ? 19 : 22, "jQuery('#static-1-1-1').position().top" );
+ equals( jQuery('#static-1-1-1').position().left, 22, "jQuery('#static-1-1-1').position().left" );
+
+ // IE is collapsing the top margin of 1px
+ equals( jQuery('#static-2').position().top, ie ? 120 : 121, "jQuery('#static-2').position().top" );
+ equals( jQuery('#static-2').position().left, 6, "jQuery('#static-2').position().left" );
+});
+
+if ( jQuery.offset.supportsFixedPosition ) {
+ testoffset("fixed", function( jQuery ) {
+ equals( jQuery('#fixed-1').offset().top, 1001, "jQuery('#fixed-1').offset().top" );
+ equals( jQuery('#fixed-1').offset().left, 1001, "jQuery('#fixed-1').offset().left" );
+
+ equals( jQuery('#fixed-2').offset().top, 1021, "jQuery('#fixed-2').offset().top" );
+ equals( jQuery('#fixed-2').offset().left, 1021, "jQuery('#fixed-2').offset().left" );
+ });
+}
+
+testoffset("table", function( jQuery ) {
+ var ie = jQuery.browser.msie;
+
+ equals( jQuery('#table-1').offset().top, 6, "jQuery('#table-1').offset().top" );
+ equals( jQuery('#table-1').offset().left, 6, "jQuery('#table-1').offset().left" );
+
+ equals( jQuery('#th-1').offset().top, 10, "jQuery('#th-1').offset().top" );
+ equals( jQuery('#th-1').offset().left, 10, "jQuery('#th-1').offset().left" );
+
+ // equals( jQuery('#th-2').offset().top, 10, "jQuery('#th-2').offset().top" );
+ // equals( jQuery('#th-2').offset().left, 116, "jQuery('#th-2').offset().left" );
+ //
+ // equals( jQuery('#th-3').offset().top, 10, "jQuery('#th-3').offset().top" );
+ // equals( jQuery('#th-3').offset().left, 222, "jQuery('#th-3').offset().left" );
+
+ // equals( jQuery('#td-1').offset().top, ie ? 116 : 112, "jQuery('#td-1').offset().top" );
+ // equals( jQuery('#td-1').offset().left, 10, "jQuery('#td-1').offset().left" );
+ //
+ // equals( jQuery('#td-2').offset().top, ie ? 116 : 112, "jQuery('#td-2').offset().top" );
+ // equals( jQuery('#td-2').offset().left, 116, "jQuery('#td-2').offset().left" );
+ //
+ // equals( jQuery('#td-3').offset().top, ie ? 116 : 112, "jQuery('#td-3').offset().top" );
+ // equals( jQuery('#td-3').offset().left, 222, "jQuery('#td-3').offset().left" );
+});
+
+testoffset("scroll", function( jQuery ) {
+ var ie = jQuery.browser.msie && parseInt( jQuery.browser.version ) < 8;
+
+ // IE is collapsing the top margin of 1px
+ equals( jQuery('#scroll-1').offset().top, ie ? 6 : 7, "jQuery('#scroll-1').offset().top" );
+ equals( jQuery('#scroll-1').offset().left, 7, "jQuery('#scroll-1').offset().left" );
+
+ // IE is collapsing the top margin of 1px
+ equals( jQuery('#scroll-1-1').offset().top, ie ? 9 : 11, "jQuery('#scroll-1-1').offset().top" );
+ equals( jQuery('#scroll-1-1').offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
+});
+
+testoffset("body", function( jQuery ) {
+ equals( jQuery('body').offset().top, 1, "jQuery('#body').offset().top" );
+ equals( jQuery('body').offset().left, 1, "jQuery('#body').offset().left" );
+});
+
+
+
+function testoffset(name, fn) {
+
+ test(name, function() {
+ // pause execution for now
+ stop();
+
+ // load fixture in iframe
+ var iframe = loadFixture(),
+ win = iframe.contentWindow,
+ interval = setInterval( function() {
+ if ( win && win.jQuery && win.jQuery.isReady ) {
+ clearInterval( interval );
+ // continue
+ start();
+ // call actual tests passing the correct jQuery isntance to use
+ fn.call( this, win.jQuery );
+ document.body.removeChild( iframe );
+ iframe = null;
+ }
+ }, 15 );
+ });
+
+ function loadFixture() {
+ var src = './data/offset/' + name + '.html?' + parseInt( Math.random()*1000 ),
+ iframe = jQuery('<iframe />').css({
+ width: 500, height: 500, position: 'absolute', top: -600, left: -600, visiblity: 'hidden'
+ }).appendTo('body')[0];
+ iframe.contentWindow.location = src;
+ return iframe;
+ }
+}
\ No newline at end of file