blob: 8028158eacef9b61cceddae84ac8bd5a160b9dd6 [file] [log] [blame]
Test the parsing of CSS Color 5 color-contrast().
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
color-contrast(... vs ..., ... [to ...])
Test with no specified target contrast
PASS computedStyle("background-color", "color-contrast(white vs red, blue)") is "rgb(0, 0, 255)"
PASS computedStyle("background-color", "color-contrast(white vs blue, red)") is "rgb(0, 0, 255)"
PASS computedStyle("background-color", "color-contrast(white vs red, blue, green)") is "rgb(0, 0, 255)"
PASS computedStyle("background-color", "color-contrast(white vs white, white)") is "rgb(255, 255, 255)"
PASS computedStyle("background-color", "color-contrast(blue vs red, white)") is "rgb(255, 255, 255)"
PASS computedStyle("background-color", "color-contrast(red vs blue, white, red)") is "rgb(255, 255, 255)"
PASS computedStyle("background-color", "color-contrast(black vs red, blue)") is "rgb(255, 0, 0)"
PASS computedStyle("background-color", "color-contrast(black vs blue, red)") is "rgb(255, 0, 0)"
PASS computedStyle("background-color", "color-contrast(black vs white, white)") is "rgb(255, 255, 255)"
PASS computedStyle("background-color", "color-contrast(red vs blue, rgb(255, 255, 255, .5))") is "rgba(255, 255, 255, 0.5)"
Test with specified target contrast
PASS computedStyle("background-color", "color-contrast(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to AA)") is "rgb(0, 100, 0)"
PASS computedStyle("background-color", "color-contrast(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to AA-large)") is "rgb(128, 128, 0)"
PASS computedStyle("background-color", "color-contrast(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to AAA)") is "rgb(128, 0, 0)"
PASS computedStyle("background-color", "color-contrast(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to AAA-large)") is "rgb(0, 100, 0)"
PASS computedStyle("background-color", "color-contrast(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to 5.8)") is "rgb(128, 0, 0)"
Test with specified target contrast that none meet
PASS computedStyle("background-color", "color-contrast(wheat vs bisque, darkgoldenrod, olive to 100)") is "rgb(0, 0, 0)"
PASS computedStyle("background-color", "color-contrast(green vs bisque, darkgoldenrod, olive to 100)") is "rgb(255, 255, 255)"
Test non-sRGB colors
PASS computedStyle("background-color", "color-contrast(green vs color(display-p3 0 1 0), color(display-p3 0 0 1))") is "color(display-p3 0 1 0)"
PASS computedStyle("background-color", "color-contrast(color(display-p3 1 1 0) vs color(display-p3 0 1 0), color(display-p3 0 0 1))") is "color(display-p3 0 0 1)"
PASS computedStyle("background-color", "color-contrast(green vs lab(50% -160 160), lch(20% 50 20deg))") is "lch(20% 50 20)"
PASS computedStyle("background-color", "color-contrast(lab(50% -160 160) vs green, lch(20% 50 20deg))") is "lch(20% 50 20)"
Test invalid values
PASS computedStyle("background-color", "color-contrast(white vs red)") is "rgba(0, 0, 0, 0)"
PASS computedStyle("background-color", "color-contrast(white vs red,)") is "rgba(0, 0, 0, 0)"
PASS computedStyle("background-color", "color-contrast(white vs )") is "rgba(0, 0, 0, 0)"
PASS computedStyle("background-color", "color-contrast(white)") is "rgba(0, 0, 0, 0)"
PASS computedStyle("background-color", "color-contrast(white vs red green)") is "rgba(0, 0, 0, 0)"
PASS computedStyle("background-color", "color-contrast(white vs red, green to)") is "rgba(0, 0, 0, 0)"
PASS computedStyle("background-color", "color-contrast(white vs red, green to invalid)") is "rgba(0, 0, 0, 0)"
PASS computedStyle("background-color", "color-contrast(white vs red to AA)") is "rgba(0, 0, 0, 0)"
PASS successfullyParsed is true
TEST COMPLETE