variable-substitution-background-properties.html (4820B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>test background property variable substitution</title> 5 6 <meta rel="author" title="Kevin Babbitt"> 7 <meta rel="author" title="Greg Whitworth"> 8 <link rel="author" title="Microsoft Corporation" href="http://microsoft.com" /> 9 <link rel="help" href="http://www.w3.org/TR/css-variables-1/#variables-in-shorthands"> 10 11 <script src="/resources/testharness.js"></script> 12 <script src="/resources/testharnessreport.js"></script> 13 <style> 14 .testArea { 15 width: 16px; 16 height: 16px; 17 display: inline-block; 18 background-image: url("../../../../images/green.png"); 19 } 20 </style> 21 </head> 22 <body> 23 <div id="log"></div> 24 <div class="testArea" id="background-attachment" style="--foo: fixed; background-attachment: var(--foo);"></div> 25 <div class="testArea" id="background-clip" style="--foo: padding-box; background-clip: var(--foo);"></div> 26 <div class="testArea" id="background-color" style="background-image: none; --foo: rgb(0, 128, 0); background-color: var(--foo);"></div> 27 <div class="testArea" id="background-origin" style="--foo: content-box; background-origin: var(--foo);"></div> 28 <div class="testArea" id="background-position" style="--foo: 0% 50%; background-position: var(--foo);"></div> 29 <div class="testArea" id="background-repeat" style="--foo: repeat-x; background-repeat: var(--foo);"></div> 30 <div class="testArea" id="background-size" style="--foo: cover; background-size: var(--foo);"></div> 31 <div class="testArea" id="background-image-url" style="--foo: url('../../../../images/green-16x16.png'); background-image: var(--foo);"></div> 32 <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> 33 <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> 34 <script type="text/javascript"> 35 "use strict"; 36 37 let templates = [ 38 { 39 testName:"background-attachment", 40 propertyName:"background-attachment", 41 expectedValue:"fixed", 42 }, 43 { 44 testName:"background-clip", 45 propertyName:"background-clip", 46 expectedValue:"padding-box", 47 }, 48 { 49 testName:"background-color", 50 propertyName:"background-color", 51 expectedValue:"rgb(0, 128, 0)", 52 }, 53 { 54 testName:"background-origin", 55 propertyName:"background-origin", 56 expectedValue:"content-box", 57 }, 58 { 59 testName:"background-position", 60 propertyName:"background-position", 61 expectedValue:"0% 50%", 62 }, 63 { 64 testName:"background-repeat", 65 propertyName:"background-repeat", 66 expectedValue:"repeat-x", 67 }, 68 { 69 testName:"background-size", 70 propertyName:"background-size", 71 expectedValue:"cover", 72 }, 73 { 74 testName:"background-image-url", 75 propertyName:"background-image", 76 expectedValue:"url(\"../../../../images/green-16x16.png\")", 77 }, 78 { 79 testName:"background-image-linear-gradient", 80 propertyName:"background-image", 81 expectedValue:"linear-gradient(rgb(30, 87, 0) 0%, rgb(125, 232, 185) 100%)", 82 }, 83 { 84 testName:"background-image-radial-gradient", 85 propertyName:"background-image", 86 expectedValue:"radial-gradient(at 25px 25px, rgb(0, 0, 0) 10%, rgb(0, 128, 0) 90%)", 87 }, 88 ]; 89 90 templates.forEach(function (template) { 91 test( function () { 92 let target = document.getElementById(template.testName); 93 let computedStyle = window.getComputedStyle(target); 94 let value = computedStyle.getPropertyValue(template.propertyName); 95 96 if (template.testName != "background-image-url") 97 { 98 assert_equals(value, template.expectedValue, "Expected Value should match actual value"); 99 } 100 else 101 { 102 assert_regexp_match(value, /green-16x16/, "Actual value should contain expected substring"); 103 } 104 }, template.testName); 105 }); 106 </script> 107 </body> 108 </html>