summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-color/system-color-hightlights-vs-getSelection-001.html
blob: 12495cd7adbcffa40b27d5d874e4e1040596dd96 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>

  <meta charset="UTF-8">

  <title>CSS Color Test: system color highlights values versus getSelection().addRange(targetRange)</title>

  <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">
  <link rel="help" href="https://www.w3.org/TR/css-color-4/#css-system-colors">
  <link rel="help" href="https://www.w3.org/TR/css-pseudo-4/#highlight-styling">
  <link rel="match" href="reference/system-color-hightlights-vs-getSelection-001-ref.html">

  <!--

  Created: March 29th 2023

  Last modified: July 12th 2023

  Chromium bug report 932343 comment #c20: Issue 932343: Support text decoration properties in ::selection
  https://bugs.chromium.org/p/chromium/issues/detail?id=932343#c20

  Chromium bug report 1429019: Issue 1429019: [CSS4 Color] [CSS4 Pseudo] getSelection() color and background color should match system color highlights
  https://bugs.chromium.org/p/chromium/issues/detail?id=1429019

  WebKit Bug report 254691: [CSS4 Color] [CSS4 Pseudo] getSelection() color and background color should match system color highlights
  https://bugs.webkit.org/show_bug.cgi?id=254691

  -->

  <meta content="" name="flags">
  <meta content="This test checks that color and background color generated by window.getSelection().addRange(targetRange) correspond to system color highlights values." name="assert">

  <style>
  div
    {
      font-size: 40px;
      line-height: 1;
    }

  /*
     https://www.w3.org/TR/css-pseudo-4/#highlight-bounds
     For text, the corresponding overlay must cover at least
     the entire em box and may extend further above/below the
     em box to the line box edges.
  */

  span.system-color-highlight
    {
      background-color: Highlight;
      color: HighlightText;
    }

  /*

  Highlight
      Background of item(s) selected in a control.
  https://www.w3.org/TR/css-color-4/#valdef-system-color-highlight

  HighlightText
      Text of item(s) selected in a control.
  https://www.w3.org/TR/css-color-4/#valdef-system-color-highlighttext

  CSS4 Color Module
  5.2 System Colors
  https://www.w3.org/TR/css-color-4/#css-system-colors

  */
  </style>

  <script type="text/javascript">
  function startTest()
  {
  /* We first create an empty range */
  var targetRange = document.createRange();

  /* Then we select the node */
  targetRange.selectNode(document.getElementById("getSelection"));

  /* Finally, we now select such range of content */
  window.getSelection().addRange(targetRange);
  }

  </script>

  <body onload="startTest();">

    <div><span class="system-color-highlight">With system-color-highlight</span></div>

    <div>
      <span id="getSelection">With getSelection()</span>
    </div>