4 <title>variable definition cascading tests
</title>
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/#using-variables">
11 <script src=
"/resources/testharness.js"></script>
12 <script src=
"/resources/testharnessreport.js"></script>
20 <!-- test global selector -->
23 <!-- multiple unique variables cascading together -->
24 <div id=
"t1a" style=
"--var1:a">
25 <div id=
"t1b" style=
"--var2:b">
26 <div id=
"t1c" style=
"--var3:c"></div>
27 <div id=
"t1d" style=
"--var4:d"></div>
31 <!-- testing overwriting -->
32 <div id=
"t2a" style=
"--var0:a">
33 <div id=
"t2b" style=
"--var0:b;--var1:c">
34 <div id=
"t2c" style=
"--var0:d;--var1:e"></div>
35 <div id=
"t2d" style=
"--var2:f"></div>
39 <script type=
"text/javascript">
43 {"divid": "t0", "expectedValues":["x"]},
44 {"divid": "t1a", "expectedValues":["x","a"]},
45 {"divid": "t1b", "expectedValues":["x","a","b"]},
46 {"divid": "t1c", "expectedValues":["x","a","b","c"]},
47 {"divid": "t1d", "expectedValues":["x","a","b","","d"]},
48 {"divid": "t2a", "expectedValues":["a"]},
49 {"divid": "t2b", "expectedValues":["b","c"]},
50 {"divid": "t2c", "expectedValues":["d","e"]},
51 {"divid": "t2d", "expectedValues":["x","c","f"]}
56 tests
.forEach(function (testCase
) {
58 let div
= document
.getElementById(testCase
.divid
);
59 let computedStyle
= window
.getComputedStyle(div
);
60 for (var i
= 0; i
< maxVariables
; ++i
) {
61 let testVar
= "--var" + i
;
62 let actualValue
= computedStyle
.getPropertyValue(testVar
);
63 let expectedValue
= testCase
.expectedValues
[i
];
64 if (expectedValue
=== undefined){
67 assert_equals(actualValue
, expectedValue
, "Actual Value for '" + testVar
+ "' should match expected value");
70 }, "testing cascaded CSS Variables on div '" + testCase
.divid
+ "'");