From a2f63ffd9640ce1e13465f718b1e2c6ca87f8772 Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Thu, 11 Feb 2016 22:31:49 +0300 Subject: [PATCH] Tests: test element position outside view Ref 49833f7795d665ff1d543c4f71f29fca95b567e9 Ref gh-2828 Ref gh-2836 Fixes gh-2909 --- test/data/testsuite.css | 12 ++++++++++++ test/unit/dimensions.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/test/data/testsuite.css b/test/data/testsuite.css index 253bea998..4f2b289f4 100644 --- a/test/data/testsuite.css +++ b/test/data/testsuite.css @@ -130,3 +130,15 @@ section { background:#f0f; display:block; } .inline { display: inline; } .list-item { display: list-item; } .hidden, .none { display: none; } + +#div-gh-2836 { + position: relative; + overflow: auto; + height: 100px; +} +#div-gh-2836 div { + position: relative; + height: 100%; + padding: 0; + margin: 0; +} diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js index c681478a0..0b568dd86 100644 --- a/test/unit/dimensions.js +++ b/test/unit/dimensions.js @@ -471,4 +471,34 @@ QUnit.test( "allow modification of coordinates argument (gh-1848)", function( as "coordinates are modified (got offset.top: " + offsetTop + ")" ); } ); +QUnit.test( "outside view position (gh-2836)", function( assert ) { + + // This test ported from gh-2836 example + assert.expect( 1 ); + + var parent, + html = [ + "
", + "
", + "
", + "
", + "
", + "
", + "
" + ].join( "" ), + stop = assert.async(); + + parent = $( html ); + parent.appendTo( "#qunit-fixture" ); + + parent.one( "scroll", function() { + var pos = parent.find( "div" ).eq( 3 ).position(); + + assert.strictEqual(pos.top, -100); + stop(); + }); + + parent.scrollTop( 400 ); +} ); + } )();