diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/css/cssom/shorthand-serialization.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/cssom/shorthand-serialization.html')
-rw-r--r-- | testing/web-platform/tests/css/cssom/shorthand-serialization.html | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/cssom/shorthand-serialization.html b/testing/web-platform/tests/css/cssom/shorthand-serialization.html new file mode 100644 index 0000000000..97e11da8b8 --- /dev/null +++ b/testing/web-platform/tests/css/cssom/shorthand-serialization.html @@ -0,0 +1,86 @@ +<!doctype html> +<html> +<head> + <meta charset="utf-8"> + <title>Shorthand serialization should be done correctly.</title> + <link rel="help" href="https://drafts.csswg.org/cssom/#serialize-a-css-declaration-block"> + <link rel="help" href="https://drafts.csswg.org/css-variables/#variables-in-shorthands"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> +</head> +<body> + <div id="foo1" style="background: red;">foo</div> + <div id="foo2" style="background-color: blue; background: red !important; background-color: green;">foo</div> + <div id="foo3" style="background-color: blue; background: red; background-color: green !important;">foo</div> + + <div id="foo4" style="margin-right: 10px; margin-left: 10px; margin-top: 10px; margin-bottom: 10px;">foo</div> + <div id="foo5" style="margin-right: 10px; margin-left: 10px; margin-top: 10px; margin-bottom: 10px!important;">foo</div> + <div id="foo6" style="margin-right: 10px !important; margin-left: 10px !important; margin-top: 10px !important; margin-bottom: 10px!important;">foo</div> + + <div id="foo7" style="background:var(--a);">foo</div> + <div id="test"></div> + + <script> + test(function() { + var elem1 = document.getElementById('foo1'); + var elem2 = document.getElementById('foo2'); + var elem3 = document.getElementById('foo3'); + + assert_false(elem1.style.cssText.endsWith('!important;')); + assert_true(elem2.style.cssText.endsWith('!important;')); + assert_false(elem3.style.background.endsWith('!important')); + + }, "Shorthand serialization with shorthand and longhands mixed."); + + test(function() { + var elem4 = document.getElementById('foo4'); + var elem5 = document.getElementById('foo5'); + var elem6 = document.getElementById('foo6'); + + assert_equals(elem4.style.cssText, 'margin: 10px;'); + assert_equals(elem4.style.margin, '10px'); + assert_equals(elem5.style.cssText, 'margin-right: 10px; margin-left: 10px; margin-top: 10px; margin-bottom: 10px !important;'); + assert_equals(elem5.style.margin, ''); + assert_equals(elem6.style.cssText, 'margin: 10px !important;'); + assert_equals(elem6.style.margin, '10px'); + }, "Shorthand serialization with just longhands."); + + test(function() { + var elem7 = document.getElementById('foo7'); + + assert_equals(elem7.style.background, 'var(--a)'); + assert_equals(elem7.style.backgroundPosition, ''); + }, "Shorthand serialization with variable and variable from other shorthand."); + + test(function() { + var testElem = document.getElementById("test"); + testElem.style.margin = "20px 20px 20px 20px"; + assert_equals(testElem.style.margin, "20px"); + assert_equals(testElem.style.cssText, "margin: 20px;") + }, "Shorthand serialization after setting"); + + test(function() { + const testElem = document.getElementById("test"); + testElem.style.cssText = "margin: initial;"; + assert_equals(testElem.style.margin, "initial"); + assert_equals(testElem.style.cssText, "margin: initial;"); + }, "Shorthand serialization with 'initial' value."); + + test(function() { + const testElem = document.getElementById("test"); + testElem.style.setProperty("margin-top", "initial", "important"); + assert_equals(testElem.style.margin, ""); + }, "Shorthand serialization with 'initial' value, one longhand with important flag."); + + test(function() { + const testElem = document.getElementById("test"); + testElem.style.cssText = ""; + testElem.style.setProperty("margin-top", "initial"); + testElem.style.setProperty("margin-right", "initial"); + testElem.style.setProperty("margin-bottom", "initial"); + testElem.style.setProperty("margin-left", "initial", "important"); + assert_equals(testElem.style.margin, ""); + }, "Shorthand serialization with 'initial' value, longhands set individually, one with important flag."); + </script> +</body> +</html> |