diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /layout/style/test/test_initial_storage.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'layout/style/test/test_initial_storage.html')
-rw-r--r-- | layout/style/test/test_initial_storage.html | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/layout/style/test/test_initial_storage.html b/layout/style/test/test_initial_storage.html new file mode 100644 index 000000000..f75c0d68c --- /dev/null +++ b/layout/style/test/test_initial_storage.html @@ -0,0 +1,130 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=375363 +--> +<head> + <title>Test for parsing, storage, and serialization of CSS 'initial' on all properties and 'unset' on reset properties</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="text/javascript" src="property_database.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=375363">Mozilla Bug 375363</a> +<p id="display"></p> +<div id="content" style="display: none"> + +<div id="testnode"></div> + +</div> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +/** Test for parsing, storage, and serialization of CSS 'initial' on all + properties and 'unset' on reset properties **/ + +var gDeclaration = document.getElementById("testnode").style; + +var gTestUnset = SpecialPowers.getBoolPref("layout.css.unset-value.enabled"); + +/** + * Checks that the passed-in property-value (returned by getPropertyValue) is + * consistent with the DOM accessors that we know about for the given sproperty. + */ +function check_consistency(sproperty, valFromGetPropertyValue, messagePrefix) +{ + var sinfo = gCSSProperties[sproperty]; + is(valFromGetPropertyValue, gDeclaration[sinfo.domProp], + `(${messagePrefix}) consistency between ` + + `decl.getPropertyValue(${sproperty}) and decl.${sinfo.domProp}`); + + if (sinfo.domProp.startsWith("webkit")) { + // For webkit-prefixed DOM accessors, test with lowercase and uppercase + // first letter. + var uppercaseDomProp = "W" + sinfo.domProp.substring(1); + is(valFromGetPropertyValue, gDeclaration[uppercaseDomProp], + `(${messagePrefix}) consistency between ` + + `decl.getPropertyValue(${sproperty}) and decl.${uppercaseDomProp}`); + } +} + +function test_property(property) +{ + var info = gCSSProperties[property]; + + var keywords = ["initial"]; + if (!info.inherited && gTestUnset) + keywords.push("unset"); + + keywords.forEach(function(keyword) { + function check_initial(sproperty) { + var val = gDeclaration.getPropertyValue(sproperty); + is(val, "", "value of '" + sproperty + "' before we do anything"); + check_consistency(sproperty, val, "initial"); + } + check_initial(property); + if ("subproperties" in info) + for (var idx in info.subproperties) + check_initial(info.subproperties[idx]); + + gDeclaration.setProperty(property, keyword, ""); + + function check_set(sproperty) { + val = gDeclaration.getPropertyValue(sproperty); + is(val, keyword, + keyword + " reported back for property '" + sproperty + "'"); + check_consistency(sproperty, val, "set"); + } + check_set(property); + if ("subproperties" in info) + for (var idx in info.subproperties) + check_set(info.subproperties[idx]); + + // We don't care particularly about the whitespace or the placement of + // semicolons, but for simplicity we'll test the current behavior. + if ("alias_for" in info) { + is(gDeclaration.cssText, info.alias_for + ": " + keyword + ";", + "declaration should serialize to exactly what went in (for " + keyword + ")"); + } else { + is(gDeclaration.cssText, property + ": " + keyword + ";", + "declaration should serialize to exactly what went in (for " + keyword + ")"); + } + + gDeclaration.removeProperty(property); + + function check_final(sproperty) { + var val = gDeclaration.getPropertyValue(sproperty); + is(val, "", "value of '" + sproperty + "' after removal of value"); + check_consistency(sproperty, val, "final"); + } + check_final(property); + if ("subproperties" in info) + for (var idx in info.subproperties) + check_final(info.subproperties[idx]); + + // can all properties be removed from the style? + function test_remove_all_properties(property, value) { + var i, p = []; + for (i = 0; i < gDeclaration.length; i++) p.push(gDeclaration[i]); + for (i = 0; i < p.length; i++) gDeclaration.removeProperty(p[i]); + var errstr = "when setting property " + property + " to " + value; + is(gDeclaration.length, 0, "unremovable properties " + errstr); + is(gDeclaration.cssText, "", "non-empty serialization after removing all properties " + errstr); + } + + // sanity check shorthands to make sure disabled props aren't exposed + if (info.type != CSS_TYPE_LONGHAND) { + gDeclaration.setProperty(property, keyword, ""); + test_remove_all_properties(property, keyword); + gDeclaration.removeProperty(property); + } + }); +} + +for (var prop in gCSSProperties) + test_property(prop); + +</script> +</pre> +</body> +</html> |