diff options
Diffstat (limited to 'testing/web-platform/tests/css/css-color/parsing/color-valid-hsl.html')
-rw-r--r-- | testing/web-platform/tests/css/css-color/parsing/color-valid-hsl.html | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-color/parsing/color-valid-hsl.html b/testing/web-platform/tests/css/css-color/parsing/color-valid-hsl.html new file mode 100644 index 0000000000..7ab1274176 --- /dev/null +++ b/testing/web-platform/tests/css/css-color/parsing/color-valid-hsl.html @@ -0,0 +1,59 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Color Level 4: Parsing and serialization of colors using valid HSL notation</title> +<link rel="help" href="https://drafts.csswg.org/css-color-4/#the-hsl-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", "hsl(120 30% 50%)", "rgb(89, 166, 89)"); +test_valid_value("color", "hsl(120 30% 50% / 0.5)", "rgba(89, 166, 89, 0.5)"); +test_valid_value("color", "hsl(none none none)", "rgb(0, 0, 0)"); +test_valid_value("color", "hsl(0 0% 0%)", "rgb(0, 0, 0)"); +test_valid_value("color", "hsl(none none none / none)", "rgba(0, 0, 0, 0)"); +test_valid_value("color", "hsl(0 0% 0% / 0)", "rgba(0, 0, 0, 0)"); +test_valid_value("color", "hsla(none none none)", "rgb(0, 0, 0)"); +test_valid_value("color", "hsla(0 0% 0%)", "rgb(0, 0, 0)"); +test_valid_value("color", "hsla(none none none / none)", "rgba(0, 0, 0, 0)"); +test_valid_value("color", "hsla(0 0% 0% / 0)", "rgba(0, 0, 0, 0)"); +test_valid_value("color", "hsl(120 none none)", "rgb(0, 0, 0)"); +test_valid_value("color", "hsl(120 0% 0%)", "rgb(0, 0, 0)"); +test_valid_value("color", "hsl(120 80% none)", "rgb(0, 0, 0)"); +test_valid_value("color", "hsl(120 80% 0%)", "rgb(0, 0, 0)"); +test_valid_value("color", "hsl(120 none 50%)", "rgb(128, 128, 128)"); +test_valid_value("color", "hsl(120 0% 50%)", "rgb(128, 128, 128)"); +test_valid_value("color", "hsl(120 100% 50% / none)", "rgba(0, 255, 0, 0)"); +test_valid_value("color", "hsl(120 100% 50% / 0)", "rgba(0, 255, 0, 0)"); +test_valid_value("color", "hsl(none 100% 50%)", "rgb(255, 0, 0)"); +test_valid_value("color", "hsl(0 100% 50%)", "rgb(255, 0, 0)"); + +// Test with number components. +test_valid_value("color", "hsl(120 30 50)", "rgb(89, 166, 89)"); +test_valid_value("color", "hsl(120 30 50 / 0.5)", "rgba(89, 166, 89, 0.5)"); +test_valid_value("color", "hsl(120 30% 50)", "rgb(89, 166, 89)"); +test_valid_value("color", "hsl(120 30% 50 / 0.5)", "rgba(89, 166, 89, 0.5)"); +test_valid_value("color", "hsl(120 30 50%)", "rgb(89, 166, 89)"); +test_valid_value("color", "hsl(120 30 50% / 0.5)", "rgba(89, 166, 89, 0.5)"); +test_valid_value("color", "hsl(120 none 50)", "rgb(128, 128, 128)"); +test_valid_value("color", "hsl(120 none 50 / 0.5)", "rgba(128, 128, 128, 0.5)"); +test_valid_value("color", "hsl(120 30 none)", "rgb(0, 0, 0)"); +test_valid_value("color", "hsl(120 30 none / 0.5)", "rgba(0, 0, 0, 0.5)"); +test_valid_value("color", "hsl(120 30 50 / none)", "rgba(89, 166, 89, 0)"); + +// 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", "hsl(calc(infinity) 100% 50%)", "rgb(255, 0, 0)"); // hsl(360 100% 50%) +test_valid_value("color", "hsl(calc(-infinity) 100% 50%)", "rgb(255, 0, 0)"); // hsl(0 100% 50%) +test_valid_value("color", "hsl(calc(0 / 0) 100% 50%)", "rgb(255, 0, 0)"); // hsl(0 100% 50%) +test_valid_value("color", "hsl(90 50% 50% / calc(infinity))", "rgb(128, 191, 64)"); // hsl(90 50% 50%) +test_valid_value("color", "hsl(90 50% 50% / calc(-infinity))", "rgba(128, 191, 64, 0)"); // hsl(90 50% 50% / 0) +test_valid_value("color", "hsl(90 50% 50% / calc(0 / 0))", "rgba(128, 191, 64, 0)"); // hsl(90 50% 50% / 0) +</script> +</body> +</html> |