aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/css/css-variables/variable-substitution-plus-box-shadow.html
blob: 06dfd3628108333392c40e1afbca5e8406a9da02 (plain) (blame)
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
<!DOCTYPE html>
<html>
<head>
    <title>box-shadow + variable substitution on same element</title>

    <meta rel="author" title="Kevin Babbitt">
    <meta rel="author" title="Greg Whitworth">
    <link rel="author" title="Microsoft Corporation" href="http://microsoft.com" />
    <!-- This is testing filters functions with var() function -->
    <link rel="help" href="http://www.w3.org/TR/css-variables-1/#defining-variables">

    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
</head>
<body>
    <div id="target" style="box-shadow: 1px 1px 1px green; color: var(--alpha); --alpha: green;">This div should have green text and a green shadow.</div>

    <script type="text/javascript">
        "use strict";
        let target = document.getElementById('target');
        let computedStyle = window.getComputedStyle(target);

        let templates = [
            {
                testName:"box-shadow",
                value: computedStyle.boxShadow,
                potentialValues: ["1px 1px 1px green", "rgb(0, 128, 0) 1px 1px 1px 0px"],
                description: "Expected value should be 1px 1px 1px green or rgb(0, 128, 0) 1px 1px 1px 0px"
            },
            {
                testName:"--alpha",
                value: computedStyle.getPropertyValue("--alpha").trim(),
                potentialValues: ["green"],
                description: "Expected value is green"
            },
            {
                testName:"color",
                value: computedStyle.color,
                potentialValues: ["rgb(0, 128, 0)", "rgba(0, 128, 0, 1)"],
                description: "Expected value to be rgb(0, 128, 0) or rgba(0, 128, 0, 1)"
            }
        ];

        templates.forEach(function (template) {
            test( function () {
                assert_in_array(template.value, template.potentialValues, template.description);
            }, template.testName);
        });
    </script>
</body>
</html>