Skip to content

Commit 071f6db

Browse files
authored
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
1 parent f2d9fde commit 071f6db

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

‎src/css/support.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ support.reliableTrDimensions = function() {
5454
}
5555

5656
trStyle = window.getComputedStyle( tr );
57-
reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) +
58-
parseInt( trStyle.borderTopWidth, 10 ) +
59-
parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight;
57+
reliableTrDimensionsVal = ( Math.round( parseFloat( trStyle.height ) ) +
58+
Math.round( parseFloat( trStyle.borderTopWidth ) ) +
59+
Math.round( parseFloat( trStyle.borderBottomWidth ) ) ) === tr.offsetHeight;
6060

6161
documentElement.removeChild( table );
6262
}

‎test/data/support/zoom.html

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<style>
6+
html {
7+
zoom: 2.1;
8+
}
9+
</style>
10+
</head>
11+
<body>
12+
<div>
13+
<script src="../../jquery.js"></script>
14+
<script src="../iframeTest.js"></script>
15+
<script src="getComputedSupport.js"></script>
16+
</div>
17+
<script>
18+
startIframeTest(
19+
getComputedStyle( document.documentElement ),
20+
getComputedSupport( jQuery.support )
21+
);
22+
</script>
23+
</body>
24+
</html>

‎test/unit/css.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1381,8 +1381,12 @@ testIframe(
13811381
"css/cssWidthBrowserZoom.html",
13821382
function( assert, jQuery, window, document, widthBeforeSet, widthAfterSet ) {
13831383
assert.expect( 2 );
1384-
assert.strictEqual( widthBeforeSet, "100px", "elem.css('width') works correctly with browser zoom" );
1385-
assert.strictEqual( widthAfterSet, "100px", "elem.css('width', val) works correctly with browser zoom" );
1384+
1385+
// Support: Firefox 126+
1386+
// Newer Firefox implements CSS zoom in a way it affects
1387+
// those values slightly.
1388+
assert.ok( /^100(?:|\.0\d*)px$/.test( widthBeforeSet ), "elem.css('width') works correctly with browser zoom" );
1389+
assert.ok( /^100(?:|\.0\d*)px$/.test( widthAfterSet ), "elem.css('width', val) works correctly with browser zoom" );
13861390
}
13871391
);
13881392

‎test/unit/support.js

+10
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ testIframe(
6666
}
6767
);
6868

69+
testIframe(
70+
"Verify correctness of support tests with CSS zoom on the root element",
71+
"support/zoom.html",
72+
function( assert, jQuery, window, document, htmlStyle, support ) {
73+
assert.expect( 1 );
74+
assert.deepEqual( jQuery.extend( {}, support ), computedSupport,
75+
"Same support properties" );
76+
}
77+
);
78+
6979
( function() {
7080
var expected, browserKey,
7181
userAgent = window.navigator.userAgent,

0 commit comments

Comments
 (0)
X