Test fractional border width rounding

This commit is contained in:
Basilisk-Dev 2026-05-09 13:14:04 -04:00 committed by wuggy
commit 6c7e6095b5
2 changed files with 52 additions and 0 deletions

View file

@ -76,6 +76,7 @@ support-files = file_animations_with_disabled_properties.html
[test_nesting_flattening_parser_edges.html]
[test_nesting_flattening_recovery.html]
[test_box_size_keywords.html]
[test_border_width_rounding.html]
[test_bug73586.html]
[test_css_math_functions.html]
[test_bug74880.html]

View file

@ -0,0 +1,51 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test fractional border and outline width rounding</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<div id="display"></div>
<pre id="test">
<script class="testbody" type="text/javascript">
var display = document.getElementById("display");
var tests = [
["0px", "0px"],
["0.1px", "1px"],
["0.25px", "1px"],
["0.5px", "1px"],
["0.9px", "1px"],
["1px", "1px"],
["1.25px", "1px"],
["1.5px", "1px"],
["2px", "2px"],
["2.75px", "2px"],
["2.999px", "2px"],
];
function checkWidth(property, setupProperty, setupValue) {
tests.forEach(function(test) {
var specified = test[0];
var expected = test[1];
var div = document.createElement("div");
div.style[setupProperty] = setupValue;
div.style[property] = specified;
display.appendChild(div);
is(document.defaultView.getComputedStyle(div, "")[property], expected,
property + " computes " + specified + " as " + expected);
display.removeChild(div);
});
}
checkWidth("borderWidth", "borderStyle", "solid");
checkWidth("outlineWidth", "outlineStyle", "solid");
</script>
</pre>
</body>
</html>