summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/cssom/cssstyledeclaration-csstext.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/css/cssom/cssstyledeclaration-csstext.html
parentInitial commit. (diff)
downloadfirefox-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/cssstyledeclaration-csstext.html')
-rw-r--r--testing/web-platform/tests/css/cssom/cssstyledeclaration-csstext.html126
1 files changed, 126 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/cssom/cssstyledeclaration-csstext.html b/testing/web-platform/tests/css/cssom/cssstyledeclaration-csstext.html
new file mode 100644
index 0000000000..686684e614
--- /dev/null
+++ b/testing/web-platform/tests/css/cssom/cssstyledeclaration-csstext.html
@@ -0,0 +1,126 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>CSSOM Test: CSSStyleDeclaration.cssText Test</title>
+ <link rel="author" title="kkoichi" href="mailto:coarse.ground@gmail.com">
+ <link rel="reviewer" title="Simon Pieters" href="mailto:simonp@opera.com"><!-- 06-27-2013 -->
+ <link rel="help" href="https://drafts.csswg.org/cssom-1/#dom-cssstyledeclaration-csstext">
+ <meta name="assert" content="CSS declarations is serialized as expected">
+ <meta name="flags" content="dom">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ function newElm() {
+ return document.body.appendChild(document.createElement('div'));
+ }
+
+ test(function(){
+ var style = newElm().style;
+ style.COLOR = 'red';
+
+ assert_equals(style.cssText, '');
+
+ }, 'uppercase property');
+
+ test(function(){
+ var style = newElm().style;
+ style.color = 'RED';
+
+ // https://www.w3.org/Bugs/Public/show_bug.cgi?id=29317
+ assert_any(assert_equals, style.cssText, ['color: red;', 'color: RED;']);
+
+ }, 'uppercase value');
+
+ test(function(){
+ var style = newElm().style;
+
+ style.color = 'red';
+
+ style.color = 'unknown color';
+
+ assert_equals(style.cssText, 'color: red;');
+
+ }, 'overwriting with invalid value');
+
+ test(function(){
+ var style = newElm().style;
+ style.color = 'rgb(255, 0, 0)';
+
+ assert_equals(style.cssText, 'color: rgb(255, 0, 0);');
+
+ }, 'use rgb');
+
+ test(function(){
+ var e = newElm();
+ var style = e.style;
+
+ style.color = 'red';
+ style.fontSize = '10pt';
+ style.fontWeight = 'bold';
+
+ assert_equals(style.cssText, 'color: red; font-size: 10pt; font-weight: bold;');
+
+ }, 'cssText order');
+
+ test(function(){
+ var e = newElm();
+ var style = e.style;
+
+ style.fontWeight = 'bold';
+ style.color = 'red';
+ style.fontSize = '10pt';
+
+ assert_equals(style.cssText, 'font-weight: bold; color: red; font-size: 10pt;');
+
+ }, 'another cssText order (non-alphabetical order)');
+
+ test(function(){
+ var style = newElm().style;
+
+ style.color = ' red';
+ style.fontSize = '10pt ';
+
+ assert_equals(style.cssText, 'color: red; font-size: 10pt;');
+
+ }, 'whitespaces in value');
+
+ test(function(){
+ var style = newElm().style;
+
+ style.color = 'red';
+ style.unknown = 'unknown';
+ style.fontSize = '10pt';
+ assert_equals(style.cssText, 'color: red; font-size: 10pt;');
+
+ }, 'invalid property does not appear');
+
+ test(function(){
+ var style = newElm().style;
+ style.cssText = "margin: 10px; margin-inline: 10px; margin-block: 10px; margin-inline-end: 10px; margin-bottom: 10px;";
+ assert_equals(style.cssText, "margin-top: 10px; margin-right: 10px; margin-left: 10px; margin-inline-start: 10px; margin-block: 10px; margin-inline-end: 10px; margin-bottom: 10px;");
+ }, 'Shorthands aren\'t serialized if there are other properties with different logical groups in between');
+
+ test(function(){
+ var style = newElm().style;
+ style.cssText = "margin-top: 10px; margin-left: 10px; margin-right: 10px; margin-bottom: 10px; margin-inline-start: 10px; margin-inline-end: 10px; margin-block-start: 10px; margin-block-end: 10px;";
+ assert_equals(style.cssText, "margin: 10px; margin-inline: 10px; margin-block: 10px;");
+ }, 'Shorthands _are_ serialized if there are no other properties with different logical groups in between');
+
+ // https://github.com/w3c/csswg-drafts/issues/1033
+ test(function() {
+ var elm = newElm();
+ var style = elm.style;
+
+ style.color = 'red';
+ style.unknown = 'unknown';
+ style.fontSize = '10pt';
+
+ assert_not_equals(getComputedStyle(elm).length, 0, "Should have a style");
+ assert_equals(getComputedStyle(elm).cssText, "", "cssText is empty");
+ }, 'cssText on computed style declaration returns the empty string');
+ </script>
+ </body>
+</html>