Wed, 31 Dec 2014 07:53:36 +0100
Correct small whitespace inconsistency, lost while renaming variables.
1 <!DOCTYPE html>
2 <title>Test for CSSStyleDeclaration.getAuthoredPropertyValue()</title>
3 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
4 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
5 <script>
6 var values = [
7 // specified value // returned from getAuthoredPropertyValue()
8 "#12F", "#12f",
9 "#1122FF", "#1122ff",
10 "rgb(10,20,30)", "rgb(10, 20, 30)",
11 "Rgb(300,20,30)", "rgb(255, 20, 30)",
12 "rgba(10,20,30,0.250)", "rgba(10, 20, 30, 0.25)",
13 "OrangeRed", "OrangeRed",
14 "rgb(10%,25%,99%)", "rgb(10%, 25%, 99%)",
15 "rgb(6.66667%,0%,0.0%)", "rgb(6.66667%, 0%, 0%)",
16 "HSL(0,25%,75%)", "hsl(0, 25%, 75%)",
17 "hsl(60,0%,0%)", "hsl(60, 0%, 0%)",
18 "hsla(60,50%,50%,0.1250)", "hsla(60, 50%, 50%, 0.125)",
19 "rgba(0,0,0,0)", "rgba(0, 0, 0, 0)"
20 ];
22 var properties = [
23 // property to test with // fixed prefix to ignore from getAuthoredPropertyValue()
24 "color", "",
25 "background-color", "",
26 "background", "none repeat scroll 0% 0% "
27 ];
29 function runTest() {
30 var span = document.createElement("span");
31 for (var j = 0; j < properties.length; j += 2) {
32 var propertyName = properties[j];
33 var expectedPrefix = properties[j + 1];
34 for (var i = 0; i < values.length; i += 2) {
35 var value = values[i];
36 var expected = values[i + 1];
37 span.setAttribute("style", propertyName + ": " + value);
38 is(span.style.getAuthoredPropertyValue(propertyName), expectedPrefix + expected, "specified " + value);
39 }
40 }
42 // also test a custom property
43 span.setAttribute("style", "--color: rgb(10%,25%,99%)");
44 is(span.style.getAuthoredPropertyValue("--color"), " rgb(10%,25%,99%)", "specified --color");
46 SimpleTest.finish();
47 }
49 SimpleTest.waitForExplicitFinish();
50 SpecialPowers.pushPrefEnv({ set: [["layout.css.variables.enabled", true]] },
51 runTest);
52 </script>