aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/css.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/css.js')
-rw-r--r--test/unit/css.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/unit/css.js b/test/unit/css.js
index 34620d05e..9c3a186d0 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -904,6 +904,52 @@ testIframeWithCallback( "css('width') should work correctly before document read
}
);
+( function() {
+ var supportsFractionalGBCR,
+ qunitFixture = document.getElementById( "qunit-fixture" ),
+ div = document.createElement( "div" );
+ div.style.width = "3.3px";
+ qunitFixture.appendChild( div );
+ supportsFractionalGBCR = jQuery.support.gBCRDimensions() &&
+ div.getBoundingClientRect().width.toFixed(1) === "3.3";
+ qunitFixture.removeChild( div );
+
+ test( "css('width') and css('height') should return fractional values for nodes in the document", function() {
+ if ( !supportsFractionalGBCR ) {
+ expect( 1 );
+ ok( true, "This browser doesn't support fractional values in getBoundingClientRect()" );
+ return;
+ }
+
+ expect( 2 );
+
+ var el = jQuery( "<div class='test-div'></div>" ).appendTo( "#qunit-fixture" );
+ jQuery( "<style>.test-div { width: 33.3px; height: 88.8px; }</style>" ).appendTo( "#qunit-fixture" );
+
+ equal( Number( el.css( "width" ).replace( /px$/, "" ) ).toFixed( 1 ), "33.3",
+ "css('width') should return fractional values" );
+ equal( Number( el.css( "height" ).replace( /px$/, "" ) ).toFixed( 1 ), "88.8",
+ "css('height') should return fractional values" );
+ } );
+
+ test( "css('width') and css('height') should return fractional values for disconnected nodes", function() {
+ if ( !supportsFractionalGBCR ) {
+ expect( 1 );
+ ok( true, "This browser doesn't support fractional values in getBoundingClientRect()" );
+ return;
+ }
+
+ expect( 2 );
+
+ var el = jQuery( "<div style='width: 33.3px; height: 88.8px;'></div>" );
+
+ equal( Number( el.css( "width" ).replace( /px$/, "" ) ).toFixed( 1 ), "33.3",
+ "css('width') should return fractional values" );
+ equal( Number( el.css( "height" ).replace( /px$/, "" ) ).toFixed( 1 ), "88.8",
+ "css('height') should return fractional values" );
+ } );
+} )();
+
test("certain css values of 'normal' should be convertable to a number, see #8627", function() {
expect ( 3 );