diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2017-07-18 15:40:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-18 15:40:41 -0400 |
commit | 20cdf4e7de60f515a7acf6c70228c52668301d9b (patch) | |
tree | b4629ff31128571e1eff1479901577152062256d /test/unit/dimensions.js | |
parent | 3fcddd6e72e7e318c0b062e391d60867732318ae (diff) | |
download | jquery-20cdf4e7de60f515a7acf6c70228c52668301d9b.tar.gz jquery-20cdf4e7de60f515a7acf6c70228c52668301d9b.zip |
Support: Properly check for IE9 absolute scrollbox mishandling
Ref gh-3589
Fixes gh-3699
Fixes gh-3730
Closes gh-3729
Diffstat (limited to 'test/unit/dimensions.js')
-rw-r--r-- | test/unit/dimensions.js | 82 |
1 files changed, 48 insertions, 34 deletions
diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js index 5db465868..13cd9662b 100644 --- a/test/unit/dimensions.js +++ b/test/unit/dimensions.js @@ -545,7 +545,7 @@ QUnit.test( "width/height on an inline element with no explicitly-set dimensions } ); QUnit.test( "interaction with scrollbars (gh-3589)", function( assert ) { - assert.expect( 36 ); + assert.expect( 48 ); var i, suffix = "", @@ -561,31 +561,29 @@ QUnit.test( "interaction with scrollbars (gh-3589)", function( assert ) { borderWidth = 1, padding = 2, size = 100 + fraction, - scrollBox = { - position: "absolute", - overflow: "scroll", - width: size + "px", - height: size + "px" - }, - borderBox = { - border: borderWidth + "px solid blue", - padding: padding + "px" - }, - plainContentBox = jQuery( "<div />" ) - .css( scrollBox ) - .css( { "box-sizing": "content-box" } ) - .appendTo( parent ), - contentBox = jQuery( "<div />" ) - .css( scrollBox ) - .css( borderBox ) - .css( { "box-sizing": "content-box" } ) - .appendTo( parent ), - borderBox = jQuery( "<div />" ) - .css( scrollBox ) - .css( borderBox ) - .css( { "box-sizing": "border-box" } ) - .appendTo( parent ), - $boxes = jQuery( [ plainContentBox[ 0 ], contentBox[ 0 ], borderBox[ 0 ] ] ), + plainBox = jQuery( "<div />" ) + .css( { + "box-sizing": "content-box", + position: "absolute", + overflow: "scroll", + width: size + "px", + height: size + "px" + } ), + contentBox = plainBox + .clone() + .css( { + border: borderWidth + "px solid blue", + padding: padding + "px" + } ), + borderBox = contentBox + .clone() + .css( { "box-sizing": "border-box" } ), + relativeBorderBox = borderBox + .clone() + .css( { position: "relative" } ), + $boxes = jQuery( + [ plainBox[ 0 ], contentBox[ 0 ], borderBox[ 0 ], relativeBorderBox[ 0 ] ] + ).appendTo( parent ), // Support: IE 9 only // Computed width seems to report content width even with "box-sizing: border-box", and @@ -594,6 +592,13 @@ QUnit.test( "interaction with scrollbars (gh-3589)", function( assert ) { borderBox.clone().css( { overflow: "auto" } ).appendTo( parent )[ 0 ].offsetWidth - borderBox[ 0 ].offsetWidth; + if ( borderBoxLoss > 0 ) { + borderBox.css( { + width: ( size + borderBoxLoss ) + "px", + height: ( size + borderBoxLoss ) + "px" + } ); + } + for ( i = 0; i < 3; i++ ) { if ( i === 1 ) { suffix = " after increasing inner* by " + i; @@ -605,13 +610,13 @@ QUnit.test( "interaction with scrollbars (gh-3589)", function( assert ) { $boxes.outerWidth( updater( i ) ).outerHeight( updater( i ) ); } - assert.equal( plainContentBox.innerWidth(), size, + assert.equal( plainBox.innerWidth(), size, "plain content-box innerWidth includes scroll gutter" + suffix ); - assert.equal( plainContentBox.innerHeight(), size, + assert.equal( plainBox.innerHeight(), size, "plain content-box innerHeight includes scroll gutter" + suffix ); - assert.equal( plainContentBox.outerWidth(), size, + assert.equal( plainBox.outerWidth(), size, "plain content-box outerWidth includes scroll gutter" + suffix ); - assert.equal( plainContentBox.outerHeight(), size, + assert.equal( plainBox.outerHeight(), size, "plain content-box outerHeight includes scroll gutter" + suffix ); assert.equal( contentBox.innerWidth(), size + 2 * padding, @@ -623,14 +628,23 @@ QUnit.test( "interaction with scrollbars (gh-3589)", function( assert ) { assert.equal( contentBox.outerHeight(), size + 2 * padding + 2 * borderWidth, "content-box outerHeight includes scroll gutter" + suffix ); - assert.equal( borderBox.innerWidth(), size - borderBoxLoss - 2 * borderWidth, + assert.equal( borderBox.innerWidth(), size - 2 * borderWidth, "border-box innerWidth includes scroll gutter" + suffix ); - assert.equal( borderBox.innerHeight(), size - borderBoxLoss - 2 * borderWidth, + assert.equal( borderBox.innerHeight(), size - 2 * borderWidth, "border-box innerHeight includes scroll gutter" + suffix ); - assert.equal( borderBox.outerWidth(), size - borderBoxLoss, + assert.equal( borderBox.outerWidth(), size, "border-box outerWidth includes scroll gutter" + suffix ); - assert.equal( borderBox.outerHeight(), size - borderBoxLoss, + assert.equal( borderBox.outerHeight(), size, "border-box outerHeight includes scroll gutter" + suffix ); + + assert.equal( relativeBorderBox.innerWidth(), size - 2 * borderWidth, + "relative border-box innerWidth includes scroll gutter" + suffix ); + assert.equal( relativeBorderBox.innerHeight(), size - 2 * borderWidth, + "relative border-box innerHeight includes scroll gutter" + suffix ); + assert.equal( relativeBorderBox.outerWidth(), size, + "relative border-box outerWidth includes scroll gutter" + suffix ); + assert.equal( relativeBorderBox.outerHeight(), size, + "relative border-box outerHeight includes scroll gutter" + suffix ); } } ); |