Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=375363 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for parsing, storage, and serialization of CSS 'inherit' on all properties and 'unset' on inherited properties</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=375363">Mozilla Bug 375363</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 | /** Test for parsing, storage, and serialization of CSS 'inherit' on all |
michael@0 | 24 | properties and 'unset' on inherited properties **/ |
michael@0 | 25 | |
michael@0 | 26 | var gDeclaration = document.getElementById("testnode").style; |
michael@0 | 27 | |
michael@0 | 28 | var gTestUnset = SpecialPowers.getBoolPref("layout.css.unset-value.enabled"); |
michael@0 | 29 | |
michael@0 | 30 | function test_property(property) |
michael@0 | 31 | { |
michael@0 | 32 | var info = gCSSProperties[property]; |
michael@0 | 33 | |
michael@0 | 34 | var keywords = ["inherit"]; |
michael@0 | 35 | if (info.inherited && gTestUnset) |
michael@0 | 36 | keywords.push("unset"); |
michael@0 | 37 | |
michael@0 | 38 | keywords.forEach(function(keyword) { |
michael@0 | 39 | function check_initial(sproperty) { |
michael@0 | 40 | var sinfo = gCSSProperties[sproperty]; |
michael@0 | 41 | var val = gDeclaration.getPropertyValue(sproperty); |
michael@0 | 42 | is(val, "", "value of '" + sproperty + "' before we do anything"); |
michael@0 | 43 | is(val, gDeclaration[sinfo.domProp], |
michael@0 | 44 | "consistency between decl.getPropertyValue('" + sproperty + "') and decl." + sinfo.domProp); |
michael@0 | 45 | } |
michael@0 | 46 | check_initial(property); |
michael@0 | 47 | if ("subproperties" in info) |
michael@0 | 48 | for (var idx in info.subproperties) |
michael@0 | 49 | check_initial(info.subproperties[idx]); |
michael@0 | 50 | |
michael@0 | 51 | gDeclaration.setProperty(property, keyword, ""); |
michael@0 | 52 | |
michael@0 | 53 | function check_set(sproperty) { |
michael@0 | 54 | var sinfo = gCSSProperties[sproperty]; |
michael@0 | 55 | val = gDeclaration.getPropertyValue(sproperty); |
michael@0 | 56 | is(val, keyword, |
michael@0 | 57 | keyword + " reported back for property '" + sproperty + "'"); |
michael@0 | 58 | is(val, gDeclaration[sinfo.domProp], |
michael@0 | 59 | "consistency between decl.getPropertyValue('" + sproperty + |
michael@0 | 60 | "') and decl." + sinfo.domProp); |
michael@0 | 61 | } |
michael@0 | 62 | check_set(property); |
michael@0 | 63 | if ("subproperties" in info) |
michael@0 | 64 | for (var idx in info.subproperties) |
michael@0 | 65 | check_set(info.subproperties[idx]); |
michael@0 | 66 | |
michael@0 | 67 | // We don't care particularly about the whitespace or the placement of |
michael@0 | 68 | // semicolons, but for simplicity we'll test the current behavior. |
michael@0 | 69 | if ("alias_for" in info) { |
michael@0 | 70 | is(gDeclaration.cssText, info.alias_for + ": " + keyword + ";", |
michael@0 | 71 | "declaration should serialize to exactly what went in (for " + keyword + ")"); |
michael@0 | 72 | } else { |
michael@0 | 73 | is(gDeclaration.cssText, property + ": " + keyword + ";", |
michael@0 | 74 | "declaration should serialize to exactly what went in (for " + keyword + ")"); |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | gDeclaration.removeProperty(property); |
michael@0 | 78 | |
michael@0 | 79 | function check_final(sproperty) { |
michael@0 | 80 | var sinfo = gCSSProperties[sproperty]; |
michael@0 | 81 | var val = gDeclaration.getPropertyValue(sproperty); |
michael@0 | 82 | is(val, "", "value of '" + sproperty + "' after removal of value"); |
michael@0 | 83 | is(val, gDeclaration[sinfo.domProp], |
michael@0 | 84 | "consistency between decl.getPropertyValue('" + sproperty + "') and decl." + sinfo.domProp); |
michael@0 | 85 | } |
michael@0 | 86 | check_final(property); |
michael@0 | 87 | if ("subproperties" in info) |
michael@0 | 88 | for (var idx in info.subproperties) |
michael@0 | 89 | check_final(info.subproperties[idx]); |
michael@0 | 90 | |
michael@0 | 91 | // can all properties be removed from the style? |
michael@0 | 92 | function test_remove_all_properties(property, value) { |
michael@0 | 93 | var i, p = []; |
michael@0 | 94 | for (i = 0; i < gDeclaration.length; i++) p.push(gDeclaration[i]); |
michael@0 | 95 | for (i = 0; i < p.length; i++) gDeclaration.removeProperty(p[i]); |
michael@0 | 96 | var errstr = "when setting property " + property + " to " + value; |
michael@0 | 97 | is(gDeclaration.length, 0, "unremovable properties " + errstr); |
michael@0 | 98 | is(gDeclaration.cssText, "", "non-empty serialization after removing all properties " + errstr); |
michael@0 | 99 | } |
michael@0 | 100 | |
michael@0 | 101 | // sanity check shorthands to make sure disabled props aren't exposed |
michael@0 | 102 | if (info.type != CSS_TYPE_LONGHAND) { |
michael@0 | 103 | gDeclaration.setProperty(property, keyword, ""); |
michael@0 | 104 | test_remove_all_properties(property, keyword); |
michael@0 | 105 | gDeclaration.removeProperty(property); |
michael@0 | 106 | } |
michael@0 | 107 | }); |
michael@0 | 108 | } |
michael@0 | 109 | |
michael@0 | 110 | for (var prop in gCSSProperties) |
michael@0 | 111 | test_property(prop); |
michael@0 | 112 | |
michael@0 | 113 | </script> |
michael@0 | 114 | </pre> |
michael@0 | 115 | </body> |
michael@0 | 116 | </html> |