Skip to content

Commit 4ab8603

Browse files
committedDec 25, 2014
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
1 parent c62486f commit 4ab8603

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed
 

Diff for: ‎test/unit/offset.js

+16-7
Original file line numberDiff line numberDiff line change
@@ -534,16 +534,25 @@ test("fractions (see #7730 and #7885)", function() {
534534
test("iframe scrollTop/Left (see gh-1945)", function() {
535535
expect( 2 );
536536

537-
// Tests scrollTop/Left with iframes
538537
var ifDoc = jQuery( "#iframe" )[ 0 ].contentDocument;
539-
jQuery( "#iframe" ).css( "width", "50px" ).css( "height", "50px" );
540-
ifDoc.write( "<div style='width: 1000px; height: 1000px;'></div>" );
541538

542-
jQuery( ifDoc ).scrollTop( 200 );
543-
jQuery( ifDoc ).scrollLeft( 500 );
539+
// iPhone resize the iframe by its content
540+
// meaning it's not possible to scroll the iframe only its parent element
541+
if ( /iphone os/i.test( navigator.userAgent ) ) {
542+
equal( true, true, "iPhone doesn't scroll the iframes" );
543+
equal( true, true, "iPhone doesn't scroll the iframes" );
544544

545-
equal( jQuery( ifDoc ).scrollTop(), 200, "$($('#iframe')[0].contentDocument).scrollTop()" );
546-
equal( jQuery( ifDoc ).scrollLeft(), 500, "$($('#iframe')[0].contentDocument).scrollLeft()" );
545+
} else {
546+
// Tests scrollTop/Left with iframes
547+
jQuery( "#iframe" ).css( "width", "50px" ).css( "height", "50px" );
548+
ifDoc.write( "<div style='width: 1000px; height: 1000px;'></div>" );
549+
550+
jQuery( ifDoc ).scrollTop( 200 );
551+
jQuery( ifDoc ).scrollLeft( 500 );
552+
553+
equal( jQuery( ifDoc ).scrollTop(), 200, "$($('#iframe')[0].contentDocument).scrollTop()" );
554+
equal( jQuery( ifDoc ).scrollLeft(), 500, "$($('#iframe')[0].contentDocument).scrollLeft()" );
555+
}
547556
});
548557

549558
})();

0 commit comments

Comments
 (0)