+ 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" );
+
+
+ // scroll offset tests .scrollTop/Left
+ equals( jQuery('#scroll-1').scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" );
+ equals( jQuery('#scroll-1').scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" );
+
+ equals( jQuery('#scroll-1-1').scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" );
+ equals( jQuery('#scroll-1-1').scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" );
+
+ // equals( jQuery('body').scrollTop(), 0, "jQuery('body').scrollTop()" );
+ // equals( jQuery('body').scrollLeft(), 0, "jQuery('body').scrollTop()" );
+
+ win.name = "test";
+
+ if ( !supportsScroll ) {
+ ok( true, "Browser doesn't support scroll position." );
+ ok( true, "Browser doesn't support scroll position." );
+
+ ok( true, "Browser doesn't support scroll position." );
+ ok( true, "Browser doesn't support scroll position." );
+ } else {
+ equals( jQuery(win).scrollTop(), 1000, "jQuery(window).scrollTop()" );
+ equals( jQuery(win).scrollLeft(), 1000, "jQuery(window).scrollLeft()" );
+
+ equals( jQuery(win.document).scrollTop(), 1000, "jQuery(document).scrollTop()" );
+ equals( jQuery(win.document).scrollLeft(), 1000, "jQuery(document).scrollLeft()" );
+ }
+
+ // test jQuery using parent window/document
+ // jQuery reference here is in the iframe
+ window.scrollTo(0,0);
+ equals( jQuery(window).scrollTop(), 0, "jQuery(window).scrollTop() other window" );
+ equals( jQuery(window).scrollLeft(), 0, "jQuery(window).scrollLeft() other window" );
+ equals( jQuery(document).scrollTop(), 0, "jQuery(window).scrollTop() other document" );
+ equals( jQuery(document).scrollLeft(), 0, "jQuery(window).scrollLeft() other document" );
+});
+
+testoffset("body", function( jQuery ) {
+ expect(2);
+
+ equals( jQuery('body').offset().top, 1, "jQuery('#body').offset().top" );
+ equals( jQuery('body').offset().left, 1, "jQuery('#body').offset().left" );
+});
+
+test("Chaining offset(coords) returns jQuery object", function() {
+ expect(2);
+ var coords = { top: 1, left: 1 };
+ equals( jQuery("#absolute-1").offset(coords).selector, "#absolute-1", "offset(coords) returns jQuery object" );
+ equals( jQuery("#non-existent").offset(coords).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" );
+});
+
+test("offsetParent", function(){
+ expect(11);
+
+ var body = jQuery("body").offsetParent();
+ equals( body.length, 1, "Only one offsetParent found." );
+ equals( body[0], document.body, "The body is its own offsetParent." );
+
+ var header = jQuery("#qunit-header").offsetParent();
+ equals( header.length, 1, "Only one offsetParent found." );
+ equals( header[0], document.body, "The body is the offsetParent." );
+
+ var div = jQuery("#nothiddendivchild").offsetParent();
+ equals( div.length, 1, "Only one offsetParent found." );
+ equals( div[0], document.body, "The body is the offsetParent." );
+
+ jQuery("#nothiddendiv").css("position", "relative");
+
+ div = jQuery("#nothiddendivchild").offsetParent();
+ equals( div.length, 1, "Only one offsetParent found." );
+ equals( div[0], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );
+
+ div = jQuery("body, #nothiddendivchild").offsetParent();
+ equals( div.length, 2, "Two offsetParent found." );
+ equals( div[0], document.body, "The body is the offsetParent." );
+ equals( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );
+});
+
+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, win );
+ document.body.removeChild( iframe );
+ iframe = null;
+ }
+ }, 15 );
+ });
+
+ function loadFixture() {
+ var src = './data/offset/' + name + '.html?' + parseInt( Math.random()*1000, 10 ),
+ 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;
+ }
+}