diff options
Diffstat (limited to 'testing/web-platform/tests/css/css-color/parsing/color-computed-color-contrast-function.html')
-rw-r--r-- | testing/web-platform/tests/css/css-color/parsing/color-computed-color-contrast-function.html | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-color/parsing/color-computed-color-contrast-function.html b/testing/web-platform/tests/css/css-color/parsing/color-computed-color-contrast-function.html new file mode 100644 index 0000000000..74be5ced37 --- /dev/null +++ b/testing/web-platform/tests/css/css-color/parsing/color-computed-color-contrast-function.html @@ -0,0 +1,51 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>CSS Color Level 6: Computation of colors using color-contrast() function syntax</title> +<link rel="author" title="Sam Weinig" href="mailto:weinig@apple.com"> +<link rel="help" href="https://drafts.csswg.org/css-color-6/#colorcontrast"> +<link rel="help" href="https://drafts.csswg.org/css-color-6/#resolving-contrast"> +<link rel="help" href="https://drafts.csswg.org/css-color-6/#serial-color-contrast"> +<meta name="assert" content="computed value of color-contrast() matches expected values"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/css/support/computed-testcommon.js"></script> +</head> +<body> +<div id="target"></div> +<script> + // Test with no specified target contrast + test_computed_value(`color`, `color-contrast(white vs red, blue)`, `rgb(0, 0, 255)`); + test_computed_value(`color`, `color-contrast(white vs blue, red)`, `rgb(0, 0, 255)`); + test_computed_value(`color`, `color-contrast(white vs red, blue, green)`, `rgb(0, 0, 255)`); + test_computed_value(`color`, `color-contrast(white vs white, white)`, `rgb(255, 255, 255)`); + test_computed_value(`color`, `color-contrast(blue vs red, white)`, `rgb(255, 255, 255)`); + test_computed_value(`color`, `color-contrast(red vs blue, white, red)`, `rgb(255, 255, 255)`); + test_computed_value(`color`, `color-contrast(black vs red, blue)`, `rgb(255, 0, 0)`); + test_computed_value(`color`, `color-contrast(black vs blue, red)`, `rgb(255, 0, 0)`); + test_computed_value(`color`, `color-contrast(black vs white, white)`, `rgb(255, 255, 255)`); + test_computed_value(`color`, `color-contrast(red vs blue, rgb(255, 255, 255, .5))`, `rgba(255, 255, 255, 0.5)`); + + // Test with specified target contrast. + test_computed_value(`color`, `color-contrast(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to AA)`, `rgb(0, 100, 0)`); // darkgreen + test_computed_value(`color`, `color-contrast(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to AA-large)`, `rgb(128, 128, 0)`); // olive + test_computed_value(`color`, `color-contrast(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to AAA)`, `rgb(128, 0, 0)`); // maroon + test_computed_value(`color`, `color-contrast(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to AAA-large)`, `rgb(0, 100, 0)`); // darkgreen + test_computed_value(`color`, `color-contrast(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to 5.8)`, `rgb(128, 0, 0)`); // maroon + + // Test with specified target contrast that none meet. + test_computed_value(`color`, `color-contrast(wheat vs bisque, darkgoldenrod, olive to 100)`, `rgb(0, 0, 0)`); // black + test_computed_value(`color`, `color-contrast(green vs bisque, darkgoldenrod, olive to 100)`, `rgb(255, 255, 255)`); // white + + // Test non-sRGB colors. + test_computed_value(`color`, `color-contrast(green vs color(display-p3 0 1 0), color(display-p3 0 0 1))`, `color(display-p3 0 1 0)`); + test_computed_value(`color`, `color-contrast(color(display-p3 1 1 0) vs color(display-p3 0 1 0), color(display-p3 0 0 1))`, `color(display-p3 0 0 1)`); + test_computed_value(`color`, `color-contrast(green vs lab(50% -160 160), lch(0.2 50 20deg))`, `lch(0.2 50 20)`); + test_computed_value(`color`, `color-contrast(lab(50% -160 160) vs green, lch(0.2 50 20deg))`, `lch(0.2 50 20)`); + + // Test with extra whitespace + test_computed_value(`color`, `color-contrast( white vs red, blue )`, `rgb(0, 0, 255)`); +</script> +</body> +</html> |