Permalink
Browse files

Offset: don't run scrollTop/scrollLeft iframe test in mobile Safari

iPhone resize the iframe by its content regardless of the width, height values,
meaning it's not possible to scroll the iframe only its parent element

Ref 62a333e
  • Loading branch information...
markelog committed Dec 25, 2014
1 parent c62486f commit 4ab8603669e2bbc8644e402927c33ce422d7aaa3
Showing with 16 additions and 7 deletions.
  1. +16 −7 test/unit/offset.js
View
@@ -534,16 +534,25 @@ test("fractions (see #7730 and #7885)", function() {
test("iframe scrollTop/Left (see gh-1945)", function() {
expect( 2 );
// Tests scrollTop/Left with iframes
var ifDoc = jQuery( "#iframe" )[ 0 ].contentDocument;
jQuery( "#iframe" ).css( "width", "50px" ).css( "height", "50px" );
ifDoc.write( "<div style='width: 1000px; height: 1000px;'></div>" );
jQuery( ifDoc ).scrollTop( 200 );
jQuery( ifDoc ).scrollLeft( 500 );
// iPhone resize the iframe by its content
// meaning it's not possible to scroll the iframe only its parent element
if ( /iphone os/i.test( navigator.userAgent ) ) {
equal( true, true, "iPhone doesn't scroll the iframes" );
equal( true, true, "iPhone doesn't scroll the iframes" );
equal( jQuery( ifDoc ).scrollTop(), 200, "$($('#iframe')[0].contentDocument).scrollTop()" );
equal( jQuery( ifDoc ).scrollLeft(), 500, "$($('#iframe')[0].contentDocument).scrollLeft()" );
} else {
// Tests scrollTop/Left with iframes
jQuery( "#iframe" ).css( "width", "50px" ).css( "height", "50px" );
ifDoc.write( "<div style='width: 1000px; height: 1000px;'></div>" );
jQuery( ifDoc ).scrollTop( 200 );
jQuery( ifDoc ).scrollLeft( 500 );
equal( jQuery( ifDoc ).scrollTop(), 200, "$($('#iframe')[0].contentDocument).scrollTop()" );
equal( jQuery( ifDoc ).scrollLeft(), 500, "$($('#iframe')[0].contentDocument).scrollLeft()" );
}
});
})();

2 comments on commit 4ab8603

@mgol

This comment has been minimized.

Show comment
Hide comment
@mgol

mgol Dec 29, 2014

Member

It seems Android 2.3 & 4.0 have the same problem: http://swarm.jquery.org/result/2238780

Member

mgol replied Dec 29, 2014

It seems Android 2.3 & 4.0 have the same problem: http://swarm.jquery.org/result/2238780

@markelog

This comment has been minimized.

Show comment
Hide comment
@markelog

markelog Dec 31, 2014

Member

Created - #1981

Will check it out

Member

markelog replied Dec 31, 2014

Created - #1981

Will check it out

Please sign in to comment.