From 13ee32b08c215737f29b80d7b7ad85de3b3ec6bd Mon Sep 17 00:00:00 2001 From: Seokho Song <0xdevssh@gmail.com> Date: Wed, 17 Feb 2021 00:06:52 -0800 Subject: [PATCH] The infinity and NaN length value must be clamped before consumed This patch is the second patch of css calc infinity and NaN implementation project and included clamping the infinity and NaN to finite for and . More details are 4th section in [2]. The Spec: [1] Design docs: [2] Feature Status: [3] Intent to prototype: [4] [1] https://drafts.csswg.org/css-values/#calc-type-checking [2] https://bit.ly/349gXjq [3] https://chromestatus.com/feature/5657825571241984 [4] https://groups.google.com/a/chromium.org/g/blink-dev/c/4cT9dMkzVXE/m/aCT8B6PDAwAJ Bug: 1133390 Change-Id: I4e8e488ea9173a82357907ebb5623619c576bd22 --- .../calc-infinity-nan-computed.html | 44 +++++++++++++++++++ css/support/computed-testcommon.js | 17 +++++++ 2 files changed, 61 insertions(+) create mode 100644 css/css-values/calc-infinity-nan-computed.html diff --git a/css/css-values/calc-infinity-nan-computed.html b/css/css-values/calc-infinity-nan-computed.html new file mode 100644 index 00000000000000..7443ddb645c5de --- /dev/null +++ b/css/css-values/calc-infinity-nan-computed.html @@ -0,0 +1,44 @@ + + + + +Infinity and NaN: calc() computed value. + + + + + + + +
+ + + diff --git a/css/support/computed-testcommon.js b/css/support/computed-testcommon.js index 43851cb87fccb7..1db50b0c10702f 100644 --- a/css/support/computed-testcommon.js +++ b/css/support/computed-testcommon.js @@ -36,6 +36,23 @@ function test_computed_value(property, specified, computed, titleExtra) { }, `Property ${property} value '${specified}'${titleExtra ? ' ' + titleExtra : ''}`); } +function test_computed_value_greater_or_lower_than(property, specified, expected, titleExtra) { + test(() => { + const target = document.getElementById('target'); + assert_true(property in getComputedStyle(target), property + " doesn't seem to be supported in the computed style"); + assert_true(CSS.supports(property, specified), "'" + specified + "' is a supported value for " + property + "."); + target.style[property] = ''; + target.style[property] = specified; + let readValue = parseFloat(getComputedStyle(target)[property]); + assert_true(isFinite(readValue), specified + " expected finite value but got " + readValue) + assert_false(isNaN(readValue), specified + " expected finite value but got " + readValue) + if (expected > 0) + assert_greater_than_equal(readValue, expected, specified); + else + assert_less_than_equal(readValue, expected, specified); + }, `Property ${property} value '${specified}'${titleExtra ? ' ' + titleExtra : ''}`); +} + function test_pseudo_computed_value(pseudo, property, specified, computed, titleExtra) { if (!computed) computed = specified;