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