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-color/parsing/color-valid-hwb.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-color/parsing/color-valid-hwb.html')
-rw-r--r-- | testing/web-platform/tests/css/css-color/parsing/color-valid-hwb.html | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-color/parsing/color-valid-hwb.html b/testing/web-platform/tests/css/css-color/parsing/color-valid-hwb.html new file mode 100644 index 0000000000..374634c084 --- /dev/null +++ b/testing/web-platform/tests/css/css-color/parsing/color-valid-hwb.html @@ -0,0 +1,61 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Color Level 4: Parsing and serialization of colors using valid HWB notation</title> +<link rel="help" href="https://drafts.csswg.org/css-color-4/#the-hwb-notation"> +<link rel="help" href="https://drafts.csswg.org/css-color-4/#resolving-sRGB-values"> +<link rel="help" href="https://drafts.csswg.org/css-color-4/#serializing-sRGB-values"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/parsing-testcommon.js"></script> +</head> +<body> +<script> +test_valid_value("color", "hwb(120 30% 50%)", "rgb(77, 128, 77)"); +test_valid_value("color", "hwb(120 30% 50% / 0.5)", "rgba(77, 128, 77, 0.5)"); +test_valid_value("color", "hwb(none none none)", "rgb(255, 0, 0)"); +test_valid_value("color", "hwb(0 0% 0%)", "rgb(255, 0, 0)"); +test_valid_value("color", "hwb(none none none / none)", "rgba(255, 0, 0, 0)"); +test_valid_value("color", "hwb(0 0% 0% / 0)", "rgba(255, 0, 0, 0)"); +test_valid_value("color", "hwb(120 none none)", "rgb(0, 255, 0)"); +test_valid_value("color", "hwb(120 0% 0%)", "rgb(0, 255, 0)"); +test_valid_value("color", "hwb(120 80% none)", "rgb(204, 255, 204)"); +test_valid_value("color", "hwb(120 80% 0%)", "rgb(204, 255, 204)"); +test_valid_value("color", "hwb(120 none 50%)", "rgb(0, 128, 0)"); +test_valid_value("color", "hwb(120 0% 50%)", "rgb(0, 128, 0)"); +test_valid_value("color", "hwb(120 30% 50% / none)", "rgba(77, 128, 77, 0)"); +test_valid_value("color", "hwb(120 30% 50% / 0)", "rgba(77, 128, 77, 0)"); +test_valid_value("color", "hwb(none 100% 50% / none)", "rgba(170, 170, 170, 0)"); +test_valid_value("color", "hwb(0 100% 50% / 0)", "rgba(170, 170, 170, 0)"); + +// Test with number components. +test_valid_value("color", "hwb(120 30 50)", "rgb(77, 128, 77)"); +test_valid_value("color", "hwb(120 30 50 / 0.5)", "rgba(77, 128, 77, 0.5)"); +test_valid_value("color", "hwb(120 30% 50)", "rgb(77, 128, 77)"); +test_valid_value("color", "hwb(120 30% 50 / 0.5)", "rgba(77, 128, 77, 0.5)"); +test_valid_value("color", "hwb(120 30 50%)", "rgb(77, 128, 77)"); +test_valid_value("color", "hwb(120 30 50% / 0.5)", "rgba(77, 128, 77, 0.5)"); +test_valid_value("color", "hwb(120 none 50)", "rgb(0, 128, 0)"); +test_valid_value("color", "hwb(120 none 50 / 0.5)", "rgba(0, 128, 0, 0.5)"); +test_valid_value("color", "hwb(120 30 none)", "rgb(77, 255, 77)"); +test_valid_value("color", "hwb(120 30 none / 0.5)", "rgba(77, 255, 77, 0.5)"); +test_valid_value("color", "hwb(120 30 50 / none)", "rgba(77, 128, 77, 0)"); + +// Test that rounding happens properly. hwb(320deg 30% 40%) in sRGB has a blue +// channel of exactly one-half. +// 0.5 * 255 = 127.5. This value should be rounded UP to 128, not down to 127. +test_valid_value("color", "hwb(320deg 30% 40%)", "rgb(153, 77, 128)"); + +// Test non-finite values. calc(infinity) goes to upper bound while calc(-infinity) and NaN go to the lower bound. +// See: https://github.com/w3c/csswg-drafts/issues/8629 +test_valid_value("color", "hwb(calc(infinity) 20% 10%)", "rgb(230, 51, 51)"); // hwb(360 20% 10%) +test_valid_value("color", "hwb(calc(-infinity) 20% 10%)", "rgb(230, 51, 51)"); // hwb(0 20% 10%) +test_valid_value("color", "hwb(calc(0 / 0) 20% 10%)", "rgb(230, 51, 51)"); // hwb(0 20% 10%) +test_valid_value("color", "hwb(90 20% 10% / calc(infinity))", "rgb(140, 230, 51)"); // hwb(90 20% 10%) +test_valid_value("color", "hwb(90 20% 10% / calc(-infinity))", "rgba(140, 230, 51, 0)"); // hwb(90 20% 10% / 0) +test_valid_value("color", "hwb(90 20% 10% / calc(0 / 0))", "rgba(140, 230, 51, 0)"); // hwb(90 20% 10% / 0) + +</script> +</body> +</html> |