diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/css/css-typed-om/stylevalue-normalization/normalize-numeric.tentative.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-typed-om/stylevalue-normalization/normalize-numeric.tentative.html')
-rw-r--r-- | testing/web-platform/tests/css/css-typed-om/stylevalue-normalization/normalize-numeric.tentative.html | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-typed-om/stylevalue-normalization/normalize-numeric.tentative.html b/testing/web-platform/tests/css/css-typed-om/stylevalue-normalization/normalize-numeric.tentative.html new file mode 100644 index 0000000000..6d1ae399d7 --- /dev/null +++ b/testing/web-platform/tests/css/css-typed-om/stylevalue-normalization/normalize-numeric.tentative.html @@ -0,0 +1,49 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Numeric normalization tests</title> +<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#normalize-numeric"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../resources/testhelper.js"></script> +<body> +<script> +'use strict'; + +function test_numeric_normalization(test, property, cssText, expected) { + assert_style_value_equals(CSSNumericValue.parse(cssText), expected); + assert_style_value_equals(CSSStyleValue.parse(property, cssText), expected); + assert_style_value_equals( + createInlineStyleMap(test, property + ': ' + cssText).get(property), + expected); +} + +test(t => { + test_numeric_normalization(t, 'line-height', '3.14', CSS.number(3.14)); +}, 'Normalizing a <number> returns a number CSSUnitValue'); + +test(t => { + test_numeric_normalization(t, 'width', '3.14%', CSS.percent(3.14)); +}, 'Normalizing a <percentage> returns a percent CSSUnitValue'); + +test(t => { + test_numeric_normalization(t, 'width', '3.14px', CSS.px(3.14)); +}, 'Normalizing a <dimension> returns a CSSUnitValue with the correct unit'); + +test(t => { + test_numeric_normalization(t, 'opacity', '0', CSS.number(0)); +}, 'Normalizing a <number> with a unitless zero returns 0'); + +test(t => { + test_numeric_normalization(t, 'width', + 'calc(1px + calc(1px) + calc(1px * 2) + 1%)', + new CSSMathSum(CSS.px(4), CSS.percent(1))); +}, 'Normalizing a <calc> returns simplified expression'); + +test(t => { + assert_style_value_equals(CSSStyleValue.parse('width', '0px'), CSS.px(0)); + assert_style_value_equals( + createInlineStyleMap(t, 'width: 0').get('width'), + CSS.px(0)); +}, 'Normalizing a <dimension> with a unitless zero returns 0px'); + +</script> |