From 4ab8603669e2bbc8644e402927c33ce422d7aaa3 Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Thu, 25 Dec 2014 04:49:56 +0300 Subject: [PATCH] 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 62a333e0646d3011377ed13a6fcfbb08e91e2bef --- test/unit/offset.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/test/unit/offset.js b/test/unit/offset.js index 7771df17e..ab81a703d 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -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( "
" ); - 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( "
" ); + + 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.39.5