summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-color/parsing/relative-color-out-of-gamut.html
blob: 745b21a0404fd462da1b32fc2688dd26e0150a3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Color Level 5: Parsing and serialization of colors using relative color syntax that result in out-of-gamut sRGB colors</title>
<link rel="author" title="Sam Weinig" href="mailto:weinig@apple.com">
<link rel="author" title="Aaron Krajeski" href="mailto:aaronhk@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css-color-5/#relative-colors">
<link rel="help" href="https://drafts.csswg.org/css-color-5/#serial-relative-color">
<meta name="assert" content="gamut mapping works for computed value of relative color syntax">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
<script src="/css/support/color-testcommon.js"></script>
</head>
<body>
  <div id="target"></div>
</body>
<script>
  // The following tests produce colors that are outside of the srgb gamut.
  // No gamut mapping should occur and the resulting colors should be of the
  // format color(srgb ... )
  // See: https://github.com/mozilla/wg-decisions/issues/1125
  fuzzy_test_computed_color(`rgb(from color(display-p3 0 1 0) r g b / alpha)`, `color(srgb -0.511814 1.01832 -0.310726)`);
  fuzzy_test_computed_color(`rgb(from lab(100 104.3 -50.9) r g b)`, `color(srgb 1.59343 0.58802 1.40564)`);
  fuzzy_test_computed_color(`rgb(from lab(0 104.3 -50.9) r g b)`, `color(srgb 0.351376 -0.213938 0.299501)`);
  fuzzy_test_computed_color(`rgb(from lch(100 116 334) r g b)`, `color(srgb 1.59328 0.58828 1.40527)`);
  fuzzy_test_computed_color(`rgb(from lch(0 116 334) r g b)`, `color(srgb 0.351307 -0.213865 0.299236)`);
  fuzzy_test_computed_color(`rgb(from oklab(1 0.365 -0.16) r g b)`, `color(srgb 1.59295 0.360371 1.38571)`);
  fuzzy_test_computed_color(`rgb(from oklab(0 0.365 -0.16) r g b)`, `color(srgb 0.0763893 -0.0456266 0.0932598)`);
  fuzzy_test_computed_color(`rgb(from oklch(1 0.399 336.3) r g b)`, `color(srgb 1.59328 0.358736 1.38663)`);
  fuzzy_test_computed_color(`rgb(from oklch(0 0.399 336.3) r g b)`, `color(srgb 0.0765362 -0.045825 0.0937443)`);

  fuzzy_test_computed_color(`hsl(from color(display-p3 0 1 0) h s l / alpha)`, `color(srgb -0.511814 1.01832 -0.310726)`);
  fuzzy_test_computed_color(`hsl(from lab(100 104.3 -50.9) h s l)`, `color(srgb 1.59343 0.58802 1.40564)`);
  fuzzy_test_computed_color(`hsl(from lab(0 104.3 -50.9) h s l)`, `color(srgb 0.351376 -0.213938 0.299502)`);
  fuzzy_test_computed_color(`hsl(from lch(100 116 334) h s l)`, `color(srgb 1.59328 0.58828 1.40527)`);
  fuzzy_test_computed_color(`hsl(from lch(0 116 334) h s l)`, `color(srgb 0.351307 -0.213865 0.299236)`);
  fuzzy_test_computed_color(`hsl(from oklab(1 0.365 -0.16) h s l)`, `color(srgb 1.59295 0.360371 1.38571)`);
  fuzzy_test_computed_color(`hsl(from oklab(0 0.365 -0.16) h s l)`, `color(srgb 0.0763893 -0.0456266 0.0932598)`);
  fuzzy_test_computed_color(`hsl(from oklch(1 0.399 336.3) h s l)`, `color(srgb 1.59328 0.358736 1.38663)`);
  fuzzy_test_computed_color(`hsl(from oklch(0 0.399 336.3) h s l)`, `color(srgb 0.0765362 -0.045825 0.0937443)`);

  fuzzy_test_computed_color(`hwb(from color(display-p3 0 1 0) h w b / alpha)`, `color(srgb -0.511814 1.01832 -0.310726)`);
  fuzzy_test_computed_color(`hwb(from lab(100 104.3 -50.9) h w b)`, `color(srgb 1.59343 0.58802 1.40564)`);
  fuzzy_test_computed_color(`hwb(from lab(0 104.3 -50.9) h w b)`, `color(srgb 0.351376 -0.213938 0.299502)`);
  fuzzy_test_computed_color(`hwb(from lch(100 116 334) h w b)`, `color(srgb 1.59328 0.58828 1.40527)`);
  fuzzy_test_computed_color(`hwb(from lch(0 116 334) h w b)`, `color(srgb 0.351307 -0.213865 0.299236)`);
  fuzzy_test_computed_color(`hwb(from oklab(1 0.365 -0.16) h w b)`, `color(srgb 1.59295 0.360371 1.38571)`);
  fuzzy_test_computed_color(`hwb(from oklab(0 0.365 -0.16) h w b)`, `color(srgb 0.0763894 -0.0456266 0.0932598)`);
  fuzzy_test_computed_color(`hwb(from oklch(1 0.399 336.3) h w b)`, `color(srgb 1.59328 0.358736 1.38664)`);
  fuzzy_test_computed_color(`hwb(from oklch(0 0.399 336.3) h w b)`, `color(srgb 0.0765362 -0.045825 0.0937443)`);
</script>
</html>