summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-text-decor/text-decoration-color-selection-002.html
blob: 1ee903c08a45decef3206668b24726e064aa3369 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<html>
    <head>
        <title>CSS Test: CSS3 text-decoration-color when |::selection| exists</title>
        <link rel="help" href="https://www.w3.org/TR/css-text-decor-3/#text-decoration-color-property">
        <link rel="help" href="https://www.w3.org/TR/css-pseudo-4/#highlight-styling">
        <style>
            .first-underline {
                text-decoration: underline;
                text-decoration-color: blue;
            }
            .second-underline {
                text-decoration: underline;
                text-decoration-color: gold;
            }
            .third-underline {
                text-decoration: underline;
                text-decoration-color: green;
            }
            .first-underline::selection {
                text-decoration: underline;
                text-decoration-color: pink;
            }
            .second-underline::selection {
                text-decoration: underline;
                text-decoration-color: violet;
            }
            .third-underline::selection {
                text-decoration: underline;
                text-decoration-color: skyblue;
            }

            .blue-underline {
                text-decoration: underline;
                text-decoration-color: blue;
            }
            .gold-overline {
                text-decoration: overline;
                text-decoration-color: gold;
            }
            .green-line-through {
                text-decoration: line-through;
                text-decoration-color: green;
            }
            .blue-underline::selection {
                text-decoration: underline;
                text-decoration-color: pink;
            }
            .gold-overline::selection {
                text-decoration: overline;
                text-decoration-color: violet;
            }
            .green-line-through::selection {
                text-decoration: line-through;
                text-decoration-color: skyblue;
            }
        </style>
         <script>
            function startTest() {
                var targetRange = document.createRange();
                /* We first create an empty range */
                targetRange.selectNodeContents(document.getElementById("wrapper"));
                /* Then we set the range boundaries to the children of div#wrapper */
                window.getSelection().addRange(targetRange);
                /* Finally, we now select such range of content */
            }
        </script>
    </head>
    <body onload="startTest();">
        <div id="wrapper">
            <h3>Each line of this test should match its text decoration color description:</h3>

            <!-- Nested same text-decoration-line with different text-decoration-color.
                 It should be affected by their parent |::selection| -->
            <div>
                <span class="first-underline">
                    First pink underline
                    <span class="second-underline">
                        Second violet underline
                        <span class="third-underline">Third skyblue underline</span>
                    </span>
                </span>
            </div><br/>

            <!-- Mix of underline, overline and line-through with different colors for each.
                 It should be affected by their parent |::selection| -->
            <div>
                <span class="blue-underline">
                    pink underline
                    <span class="green-line-through">
                        blue underline, skyblue line-through
                        <span class="gold-overline">blue underline, green line-through, violet overline</span>
                    </span>
                </span>
            </div><br/>

            <!-- Test behavior on subscript and superscript text -->
            <div>
                <span class="green-line-through">
                    <sub class="gold-overline">subscript text, violet overline, green line-through</sub>
                    skyblue line-through
                    <sup class="blue-underline">superscript text, pink underline, green line-through</sup>
                </span>
            </div><br/>
        </div>
    </body>
</html>