Bug 1527281 [wpt PR 15337] - decimal points in numbers, a=testonly

Automatic update from web-platform-tests
decimal points in numbers

Tests that decimal points are allowed *before* digits (like `.1`) and *between* digits (like `0.1`), but not *after* digits (like `1.`).

Tests <https://github.com/w3c/csswg-drafts/issues/3599>
--
fix whitespace for lint
--
Name all tests uniquely
--
Merge pull request #15337 from web-platform-tests/tabatkins-patch-2

decimal points in numbers
--

wpt-commits: 5fdd036dbd18fa6d2e7cf235bd9acc625a6df22e, f17e215eaa37316f1489a7b62ab103d2a58a0d89, 31e1a1bb5fadb08749e4b8070ad0f19ec5ea1088, e2eb25aaa6dd3c512b172588f3400f9c25a410c3
wpt-pr: 15337
This commit is contained in:
Tab Atkins Jr 2019-02-19 14:39:27 +00:00 коммит произвёл James Graham
Родитель 543bdae964
Коммит 27a492ca22
1 изменённых файлов: 56 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,56 @@
<!doctype html>
<title>decimal points in numbers</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<meta name=author title="Tab Atkins-Bittner">
<link rel=help href="https://drafts.csswg.org/css-syntax/#consume-number">
<style>
.foo {}
</style>
<script>
function roundTripNumber(input) {
const rule = document.styleSheets[0].cssRules[0].style;
const fallback = "0";
rule.setProperty("line-height", fallback);
rule.setProperty("line-height", input);
const value = rule.getPropertyValue("line-height");
if(value == fallback) return false;
return value;
}
test(()=>{
assert_equals(roundTripNumber("1.0"), "1");
}, "decimal point between digits is valid in a number");
test(()=>{
assert_equals(roundTripNumber(".1"), "0.1");
}, "decimal point before digits is valid in a number");
test(()=>{
assert_not_equals(roundTripNumber("1."), "1");
}, "decimal point after digits is invalid in a number");
function roundTripDimension(input) {
const rule = document.styleSheets[0].cssRules[0].style;
const fallback = "0px";
rule.setProperty("width", fallback);
rule.setProperty("width", input);
const value = rule.getPropertyValue("width");
if(value == fallback) return false;
return value;
}
test(()=>{
assert_equals(roundTripDimension("1.0px"), "1px");
}, "decimal point between digits is valid in a dimension");
test(()=>{
assert_equals(roundTripDimension(".1px"), "0.1px");
}, "decimal point before digits is valid in a dimension");
test(()=>{
assert_not_equals(roundTripDimension("1.px"), "1px");
}, "decimal point after digits is invalid in a dimension");
</script>