aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2024-06-03 18:15:23 +0200
committerGitHub <noreply@github.com>2024-06-03 18:15:23 +0200
commit071f6dba6bd1d8db3f36ce4694aab5ff437b9e36 (patch)
tree1ab73f6ddb8e537726f515caab6bb47566b71da6
parentf2d9fde5f34c83a098fa2074ed808311086d9d23 (diff)
downloadjquery-071f6dba6bd1d8db3f36ce4694aab5ff437b9e36.tar.gz
jquery-071f6dba6bd1d8db3f36ce4694aab5ff437b9e36.zip
CSS:Tests: Fix tests & support tests under CSS Zoom
Firefox 126+ implements CSS zoom in a way it affects width computed style very slightly (`100.008px` instead of `100px`); accept that difference. Add a test for support tests resolving the same under CSS zoom & without one. That test uncovered Chrome failing the `reliableTrDimensions` support test under zoom; the test has been fixed. Fixes gh-5489 Closes gh-5495 Ref gh-5496
-rw-r--r--src/css/support.js6
-rw-r--r--test/data/support/zoom.html24
-rw-r--r--test/unit/css.js8
-rw-r--r--test/unit/support.js10
4 files changed, 43 insertions, 5 deletions
diff --git a/src/css/support.js b/src/css/support.js
index c7229e93a..93459c6b6 100644
--- a/src/css/support.js
+++ b/src/css/support.js
@@ -54,9 +54,9 @@ support.reliableTrDimensions = function() {
}
trStyle = window.getComputedStyle( tr );
- reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) +
- parseInt( trStyle.borderTopWidth, 10 ) +
- parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight;
+ reliableTrDimensionsVal = ( Math.round( parseFloat( trStyle.height ) ) +
+ Math.round( parseFloat( trStyle.borderTopWidth ) ) +
+ Math.round( parseFloat( trStyle.borderBottomWidth ) ) ) === tr.offsetHeight;
documentElement.removeChild( table );
}
diff --git a/test/data/support/zoom.html b/test/data/support/zoom.html
new file mode 100644
index 000000000..318b834ec
--- /dev/null
+++ b/test/data/support/zoom.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8" />
+ <style>
+ html {
+ zoom: 2.1;
+ }
+ </style>
+</head>
+<body>
+ <div>
+ <script src="../../jquery.js"></script>
+ <script src="../iframeTest.js"></script>
+ <script src="getComputedSupport.js"></script>
+ </div>
+ <script>
+ startIframeTest(
+ getComputedStyle( document.documentElement ),
+ getComputedSupport( jQuery.support )
+ );
+ </script>
+</body>
+</html>
diff --git a/test/unit/css.js b/test/unit/css.js
index ea3055f77..a8b7d8e89 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -1381,8 +1381,12 @@ testIframe(
"css/cssWidthBrowserZoom.html",
function( assert, jQuery, window, document, widthBeforeSet, widthAfterSet ) {
assert.expect( 2 );
- assert.strictEqual( widthBeforeSet, "100px", "elem.css('width') works correctly with browser zoom" );
- assert.strictEqual( widthAfterSet, "100px", "elem.css('width', val) works correctly with browser zoom" );
+
+ // Support: Firefox 126+
+ // Newer Firefox implements CSS zoom in a way it affects
+ // those values slightly.
+ assert.ok( /^100(?:|\.0\d*)px$/.test( widthBeforeSet ), "elem.css('width') works correctly with browser zoom" );
+ assert.ok( /^100(?:|\.0\d*)px$/.test( widthAfterSet ), "elem.css('width', val) works correctly with browser zoom" );
}
);
diff --git a/test/unit/support.js b/test/unit/support.js
index c71d90ca4..bf3f4d26d 100644
--- a/test/unit/support.js
+++ b/test/unit/support.js
@@ -66,6 +66,16 @@ testIframe(
}
);
+testIframe(
+ "Verify correctness of support tests with CSS zoom on the root element",
+ "support/zoom.html",
+ function( assert, jQuery, window, document, htmlStyle, support ) {
+ assert.expect( 1 );
+ assert.deepEqual( jQuery.extend( {}, support ), computedSupport,
+ "Same support properties" );
+ }
+);
+
( function() {
var expected, browserKey,
userAgent = window.navigator.userAgent,