blob: 1594a77df298921f28c6935f3a98223d872a76b3 [file] [log] [blame]
Test the computed style of the color() function.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
TEST: Basic sRGB white --> color(srgb 1 1 1)
PASS declaration.getPropertyValue('color') is 'color(srgb 1 1 1)'
TEST: White with lots of space --> color( srgb 1 1 1 )
PASS declaration.getPropertyValue('color') is 'color(srgb 1 1 1)'
TEST: sRGB color --> color(srgb 0.25 0.5 0.75)
PASS declaration.getPropertyValue('color') is 'color(srgb 0.25 0.5 0.75)'
TEST: Different case for sRGB --> color(SrGb 0.25 0.5 0.75)
PASS declaration.getPropertyValue('color') is 'color(srgb 0.25 0.5 0.75)'
TEST: sRGB color with unnecessary decimals --> color(srgb 1.00000 0.500000 0.20)
PASS declaration.getPropertyValue('color') is 'color(srgb 1 0.5 0.2)'
TEST: sRGB white with 0.5 alpha --> color(srgb 1 1 1 / 0.5)
PASS declaration.getPropertyValue('color') is 'color(srgb 1 1 1 / 0.5)'
TEST: sRGB white with 0 alpha --> color(srgb 1 1 1 / 0)
PASS declaration.getPropertyValue('color') is 'color(srgb 1 1 1 / 0)'
TEST: sRGB white with 50% alpha --> color(srgb 1 1 1 / 50%)
PASS declaration.getPropertyValue('color') is 'color(srgb 1 1 1 / 0.5)'
TEST: sRGB white with 0% alpha --> color(srgb 1 1 1 / 0%)
PASS declaration.getPropertyValue('color') is 'color(srgb 1 1 1 / 0)'
TEST: One missing component is 0 --> color(srgb 1 1)
PASS declaration.getPropertyValue('color') is 'color(srgb 1 1 0)'
TEST: Two missing components are 0 --> color(srgb 1)
PASS declaration.getPropertyValue('color') is 'color(srgb 1 0 0)'
TEST: All components missing --> color(srgb)
PASS declaration.getPropertyValue('color') is 'color(srgb 0 0 0)'
TEST: Display P3 color --> color(display-p3 0.6 0.7 0.8)
PASS declaration.getPropertyValue('color') is 'color(display-p3 0.6 0.7 0.8)'
TEST: Different case for Display P3 --> color(dIspLaY-P3 0.6 0.7 0.8)
PASS declaration.getPropertyValue('color') is 'color(display-p3 0.6 0.7 0.8)'
Fallback tests.
TEST: Unknown color space should fallback --> color(unknown 1 2 3, red)
FAIL declaration.getPropertyValue('color') should be color(unknown 1 2 3, red). Was rgb(0, 0, 0).
Clamping tests.
TEST: sRGB color with negative component should clamp to 0 --> color(srgb -0.25 0.5 0.75)
PASS declaration.getPropertyValue('color') is 'color(srgb 0 0.5 0.75)'
TEST: sRGB color with component > 1 should clamp --> color(srgb 0.25 1.5 0.75)
PASS declaration.getPropertyValue('color') is 'color(srgb 0.25 1 0.75)'
TEST: Display P3 color with negative component should clamp to 0 --> color(display-p3 0.5 -199 0.75)
PASS declaration.getPropertyValue('color') is 'color(display-p3 0.5 0 0.75)'
TEST: Display P3 color with component > 1 should clamp --> color(display-p3 184 1.00001 2347329746587)
PASS declaration.getPropertyValue('color') is 'color(display-p3 1 1 1)'
TEST: Alpha > 1 should clamp --> color(srgb 0.1 0.2 0.3 / 1.9)
PASS declaration.getPropertyValue('color') is 'color(srgb 0.1 0.2 0.3)'
TEST: Negative alpha should clamp --> color(srgb 1 1 1 / -0.2)
PASS declaration.getPropertyValue('color') is 'color(srgb 1 1 1 / 0)'
Invalid property value tests.
TEST: Empty --> color()
PASS declaration.getPropertyValue('color') is 'rgb(0, 0, 0)'
TEST: Bad color space --> color(banana 1 1 1)
PASS declaration.getPropertyValue('color') is 'rgb(0, 0, 0)'
TEST: Bad Display P3 color space --> color(displayp3 1 1 1)
PASS declaration.getPropertyValue('color') is 'rgb(0, 0, 0)'
TEST: No color space --> color(1 1 1)
PASS declaration.getPropertyValue('color') is 'rgb(0, 0, 0)'
TEST: Too many parameters --> color(srgb 1 1 1 1)
PASS declaration.getPropertyValue('color') is 'rgb(0, 0, 0)'
TEST: Way too many parameters --> color(srgb 1 1 1 1 1)
PASS declaration.getPropertyValue('color') is 'rgb(0, 0, 0)'
TEST: Bad parameters --> color(srgb 1 eggs 1)
PASS declaration.getPropertyValue('color') is 'rgb(0, 0, 0)'
TEST: Bad alpha --> color(srgb 1 1 1 / bacon)
PASS declaration.getPropertyValue('color') is 'rgb(0, 0, 0)'
TEST: Junk after alpha --> color(srgb 1 1 1 / 1 cucumber)
PASS declaration.getPropertyValue('color') is 'rgb(0, 0, 0)'
PASS successfullyParsed is true
TEST COMPLETE