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_variable_serialization_computed.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_variable_serialization_computed.html')
-rw-r--r-- | layout/style/test/test_variable_serialization_computed.html | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/layout/style/test/test_variable_serialization_computed.html b/layout/style/test/test_variable_serialization_computed.html new file mode 100644 index 000000000..c93ae8938 --- /dev/null +++ b/layout/style/test/test_variable_serialization_computed.html @@ -0,0 +1,82 @@ +<!DOCTYPE html> +<title>Test serialization of computed CSS variable values</title> +<script src="/MochiKit/MochiKit.js"></script> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" href="/tests/SimpleTest/test.css" type="text/css"> + +<div> + <span></span> +</div> + +<script> +// Each entry is an entire declaration followed by the property to check and +// its expected computed value. +var values = [ + ["", "--z", "an-inherited-value"], + ["--a: ", "--a", " "], + ["--a: initial", "--a", ""], + ["--z: initial", "--z", ""], + ["--a: inherit", "--a", ""], + ["--z: inherit", "--z", "an-inherited-value"], + ["--a: unset", "--a", ""], + ["--z: unset", "--z", "an-inherited-value"], + ["--a: 1px", "--a", " 1px"], + ["--a: var(--a)", "--a", ""], + ["--a: var(--b)", "--a", ""], + ["--a: var(--b); --b: 1px", "--a", " 1px"], + ["--a: var(--b, 1px)", "--a", " 1px"], + ["--a: var(--a, 1px)", "--a", ""], + ["--a: something 3px url(whereever) calc(var(--a) + 1px)", "--a", ""], + ["--a: something 3px url(whereever) calc(var(--b,1em) + 1px)", "--a", " something 3px url(whereever) calc(1em + 1px)"], + ["--a: var(--b, var(--c, var(--d, Black)))", "--a", " Black"], + ["--a: a var(--b) c; --b:b", "--a", " a b c"], + ["--a: a var(--b,b var(--c) d) e; --c:c", "--a", " a b c d e"], + ["--a: var(--b)red; --b:orange;", "--a", " orange/**/red"], + ["--a: var(--b)var(--c); --b:orange; --c:red;", "--a", " orange/**/red"], + ["--a: var(--b)var(--c,red); --b:orange;", "--a", " orange/**/red"], + ["--a: var(--b,orange)var(--c); --c:red;", "--a", " orange/**/red"], + ["--a: var(--b)-; --b:-;", "--a", " -/**/-"], + ["--a: var(--b)--; --b:-;", "--a", " -/**/--"], + ["--a: var(--b)--x; --b:-;", "--a", " -/**/--x"], + ["--a: var(--b)var(--c); --b:-; --c:-;", "--a", " -/**/-"], + ["--a: var(--b)var(--c); --b:--; --c:-;", "--a", " --/**/-"], + ["--a: var(--b)var(--c); --b:--x; --c:-;", "--a", " --x/**/-"], + ["counter-reset: var(--a)red; --a:orange;", "counter-reset", "orange 0 red 0"], + ["--a: var(--b)var(--c); --c:[c]; --b:('ab", "--a", " ('ab')[c]"], + ["--a: '", "--a", " ''"], + ["--a: '\\", "--a", " ''"], + ["--a: \\", "--a", " \\\ufffd"], + ["--a: \"", "--a", " \"\""], + ["--a: \"\\", "--a", " \"\""], + ["--a: /* abc ", "--a", " /* abc */"], + ["--a: /* abc *", "--a", " /* abc */"], + ["--a: url(http://example.org/", "--a", " url(http://example.org/)"], + ["--a: url(http://example.org/\\", "--a", " url(http://example.org/\\\ufffd)"], + ["--a: url('http://example.org/", "--a", " url('http://example.org/')"], + ["--a: url('http://example.org/\\", "--a", " url('http://example.org/')"], + ["--a: url(\"http://example.org/", "--a", " url(\"http://example.org/\")"], + ["--a: url(\"http://example.org/\\", "--a", " url(\"http://example.org/\")"] +]; + +function runTest() { + var div = document.querySelector("div"); + var span = document.querySelector("span"); + + div.setAttribute("style", "--z:an-inherited-value"); + + values.forEach(function(entry, i) { + var declaration = entry[0]; + var property = entry[1]; + var expected = entry[2]; + span.setAttribute("style", declaration); + var cs = getComputedStyle(span, ""); + is(cs.getPropertyValue(property), expected, "subtest #" + i); + }); + + SimpleTest.finish(); +} + +SimpleTest.waitForExplicitFinish(); +SpecialPowers.pushPrefEnv({ set: [["layout.css.variables.enabled", true]] }, + runTest); +</script> |