Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=940229 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test handling extra inherit/initial/unset in CSS declarations (Bug 940229)</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <script type="text/javascript" src="property_database.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=940229">Mozilla Bug 940229</a> |
michael@0 | 14 | <p id="display"></p> |
michael@0 | 15 | <div id="content" style="display: none"> |
michael@0 | 16 | |
michael@0 | 17 | <div id="testnode"></div> |
michael@0 | 18 | |
michael@0 | 19 | </div> |
michael@0 | 20 | <pre id="test"> |
michael@0 | 21 | <script class="testbody" type="text/javascript"> |
michael@0 | 22 | |
michael@0 | 23 | /* |
michael@0 | 24 | * Inspired by mistake in quotes noticed while reviewing bug 189519. |
michael@0 | 25 | */ |
michael@0 | 26 | |
michael@0 | 27 | var gPropsNeedComma = { |
michael@0 | 28 | "font": true, |
michael@0 | 29 | "font-family": true, |
michael@0 | 30 | "voice-family": true, |
michael@0 | 31 | }; |
michael@0 | 32 | |
michael@0 | 33 | var gElement = document.getElementById("testnode"); |
michael@0 | 34 | var gDeclaration = gElement.style; |
michael@0 | 35 | |
michael@0 | 36 | function test_property(property) |
michael@0 | 37 | { |
michael@0 | 38 | var info = gCSSProperties[property]; |
michael@0 | 39 | |
michael@0 | 40 | var delim = (property in gPropsNeedComma) ? ", " : " "; |
michael@0 | 41 | |
michael@0 | 42 | function test_value_pair(relation, val1, val2, extraval) { |
michael@0 | 43 | var decl = property + ": " + val1 + delim + val2; |
michael@0 | 44 | gElement.setAttribute("style", decl); |
michael@0 | 45 | if ("subproperties" in info) { |
michael@0 | 46 | for (idx in info.subproperties) { |
michael@0 | 47 | var subprop = info.subproperties[idx]; |
michael@0 | 48 | is(gDeclaration.getPropertyValue(subprop), "", |
michael@0 | 49 | ["expected", extraval, "ignored", relation, "value in", |
michael@0 | 50 | "'" + decl + "'", "when looking at subproperty", |
michael@0 | 51 | "'" + subprop + "'"].join(" ")); |
michael@0 | 52 | } |
michael@0 | 53 | } else { |
michael@0 | 54 | is(gDeclaration.getPropertyValue(property), "", |
michael@0 | 55 | ["expected", extraval, "ignored", relation, "value in", |
michael@0 | 56 | "'" + decl + "'"].join(" ")); |
michael@0 | 57 | } |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | function test_value(value) { |
michael@0 | 61 | test_value_pair("after", value, "inherit", "inherit"); |
michael@0 | 62 | test_value_pair("after", value, "initial", "initial"); |
michael@0 | 63 | test_value_pair("after", value, "unset", "unset"); |
michael@0 | 64 | test_value_pair("before", "inherit", value, "inherit"); |
michael@0 | 65 | test_value_pair("before", "initial", value, "initial"); |
michael@0 | 66 | test_value_pair("before", "unset", value, "unset"); |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | var idx; |
michael@0 | 70 | for (idx in info.initial_values) |
michael@0 | 71 | test_value(info.initial_values[idx]); |
michael@0 | 72 | for (idx in info.other_values) |
michael@0 | 73 | test_value(info.other_values[idx]); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 77 | SimpleTest.requestLongerTimeout(4); |
michael@0 | 78 | |
michael@0 | 79 | function start_test() { |
michael@0 | 80 | for (var prop in gCSSProperties) { |
michael@0 | 81 | test_property(prop); |
michael@0 | 82 | } |
michael@0 | 83 | SimpleTest.finish(); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | // Turn off CSS error reporting for this test, since it's a bit expensive, |
michael@0 | 87 | // and we're expecting to generate tons and tons of parse errors here. |
michael@0 | 88 | SpecialPowers.pushPrefEnv({ "set": [["layout.css.report_errors", false]] }, |
michael@0 | 89 | start_test); |
michael@0 | 90 | |
michael@0 | 91 | </script> |
michael@0 | 92 | </pre> |
michael@0 | 93 | </body> |
michael@0 | 94 | </html> |