summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-highlight-api/Highlight-multiple-type-attribute.html
blob: dc8b33045595bc472e41d94e7f040cf610d189af (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
<!DOCTYPE html>
<html>
<head>
    <title>Highlight type has a limited set of types</title>
    <link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <style>
    #one::highlight(yellow-highlight) {
        background-color: yellow;
    }
    #two::highlight(green-highlight) {
        background-color: green;
    }
    </style>
</head>
<body>
    <span id="one">One </span><span id="two">two </span>
    <script>
        test(() => {
            let highlightYellow = new Highlight(new StaticRange({startContainer: document.body, startOffset: 1, endContainer: document.body, endOffset: 2}));
            let highlightGreen = new Highlight(new StaticRange({startContainer: document.body, startOffset: 2, endContainer: document.body, endOffset: 3}));

            CSS.highlights.set("yellow-highlight", highlightYellow);
            CSS.highlights.set("green-highlight", highlightGreen);

            assert_equals(highlightYellow.type, "highlight");
            assert_equals(highlightGreen.type, "highlight");

            highlightGreen.type = "grammar-error";

            assert_equals(highlightYellow.type, "highlight");
            assert_equals(highlightGreen.type, "grammar-error");

            highlightGreen.type = "Spelling-error";

            assert_equals(highlightYellow.type, "highlight");
            assert_equals(highlightGreen.type, "grammar-error");

            highlightYellow.type = "ergeoirgjgeerror";

            assert_equals(highlightYellow.type, "highlight");
            assert_equals(highlightGreen.type, "grammar-error");
        });
    </script>
</body>
</html>