| <!doctype html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>Shorthand serialization should be done correctly.</title> |
| <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</a> |
| |
| <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."); |
| </script> |
| </body> |
| </html> |