chromium/third_party/blink/web_tests/external/wpt/css/css-variables/variable-substitution-background-properties.html

<!DOCTYPE html>
<html>
<head>
    <title>test background property variable substitution</title>

    <meta rel="author" title="Kevin Babbitt">
    <meta rel="author" title="Greg Whitworth">
    <link rel="author" title="Microsoft Corporation" href="http://microsoft.com" />
    <link rel="help" href="http://www.w3.org/TR/css-variables-1/#variables-in-shorthands">

    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <style>
        .testArea {
            width: 16px;
            height: 16px;
            display: inline-block;
            background-image: url("../../../../images/green.png");
        }
    </style>
</head>
<body>
    <div id="log"></div>
    <div class="testArea" id="background-attachment" style="--foo: fixed; background-attachment: var(--foo);"></div>
    <div class="testArea" id="background-clip" style="--foo: padding-box; background-clip: var(--foo);"></div>
    <div class="testArea" id="background-color" style="background-image: none; --foo: rgb(0, 128, 0); background-color: var(--foo);"></div>
    <div class="testArea" id="background-origin" style="--foo: content-box; background-origin: var(--foo);"></div>
    <div class="testArea" id="background-position" style="--foo: 0% 50%; background-position: var(--foo);"></div>
    <div class="testArea" id="background-repeat" style="--foo: repeat-x; background-repeat: var(--foo);"></div>
    <div class="testArea" id="background-size" style="--foo: cover; background-size: var(--foo);"></div>
    <div class="testArea" id="background-image-url" style="--foo: url('../../../../images/green-16x16.png'); background-image: var(--foo);"></div>
    <div class="testArea" id="background-image-linear-gradient" style="--location: bottom; background-image: linear-gradient(to var(--location), rgb(30,87,0) 0%,rgb(125,232,185) 100%);"></div>
    <div class="testArea" id="background-image-radial-gradient" style="--shape: ellipse; --location: farthest-corner; background-image: radial-gradient(var(--shape) var(--location) at 25px 25px, black 10%, green 90%);"></div>
    <script type="text/javascript">
        "use strict";

        let templates = [
            {
                testName:"background-attachment",
                propertyName:"background-attachment",
                expectedValue:"fixed",
            },
            {
                testName:"background-clip",
                propertyName:"background-clip",
                expectedValue:"padding-box",
            },
            {
                testName:"background-color",
                propertyName:"background-color",
                expectedValue:"rgb(0, 128, 0)",
            },
            {
                testName:"background-origin",
                propertyName:"background-origin",
                expectedValue:"content-box",
            },
            {
                testName:"background-position",
                propertyName:"background-position",
                expectedValue:"0% 50%",
            },
            {
                testName:"background-repeat",
                propertyName:"background-repeat",
                expectedValue:"repeat-x",
            },
            {
                testName:"background-size",
                propertyName:"background-size",
                expectedValue:"cover",
            },
            {
                testName:"background-image-url",
                propertyName:"background-image",
                expectedValue:"url(\"../../../../images/green-16x16.png\")",
            },
            {
                testName:"background-image-linear-gradient",
                propertyName:"background-image",
                expectedValue:"linear-gradient(rgb(30, 87, 0) 0%, rgb(125, 232, 185) 100%)",
            },
            {
                testName:"background-image-radial-gradient",
                propertyName:"background-image",
                expectedValue:"radial-gradient(at 25px 25px, rgb(0, 0, 0) 10%, rgb(0, 128, 0) 90%)",
            },
        ];

        templates.forEach(function (template) {
            test( function () {
                let target = document.getElementById(template.testName);
                let computedStyle = window.getComputedStyle(target);
                let value = computedStyle.getPropertyValue(template.propertyName);

                if (template.testName != "background-image-url")
                {
                    assert_equals(value, template.expectedValue, "Expected Value should match actual value");
                }
                else
                {
                    assert_regexp_match(value, /green-16x16/, "Actual value should contain expected substring");
                }
            }, template.testName);
        });
    </script>
</body>
</html>