aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2014-12-25 00:49:46 +0300
committerOleg Gaidarenko <markelog@gmail.com>2014-12-25 00:55:15 +0300
commit62a333e0646d3011377ed13a6fcfbb08e91e2bef (patch)
treeaf07af6361df142dea2248860192a728173a7ecc /test/unit
parentd632699c6b2b1b06dd7cbdec982d930f59fd8119 (diff)
downloadjquery-62a333e0646d3011377ed13a6fcfbb08e91e2bef.tar.gz
jquery-62a333e0646d3011377ed13a6fcfbb08e91e2bef.zip
Offset: fix iframe scrollTop/Left test for IE8 and iPhone
* IE8 need a doctype, otherwise IE will scroll it, but will still show old values. It wasn't noticable before, since IE8 will update values if in the dev tools you swtich to "Quirks mode" and then back again, then this tab will always show the correct values even if you update it * 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 ae30fb6c27a2121578d3ce7ca6e2ba1d205545b8
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/offset.js30
1 files changed, 22 insertions, 8 deletions
diff --git a/test/unit/offset.js b/test/unit/offset.js
index 2692f7ad2..bede34a75 100644
--- a/test/unit/offset.js
+++ b/test/unit/offset.js
@@ -550,17 +550,31 @@ 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>" );
- ifDoc.close();
- 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" );
+
+ // Support: IE8
+ // Need a doctype, otherwise IE will scroll it but will still show old values
+ ifDoc.write( "<!DOCTYPE><div style='width: 1000px; height: 1000px;'></div>" );
+
+ // Support: IE8
+ ifDoc.close();
+
+ 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()" );
+ }
});
})();