shadow-shared-style-cache-001.html (1374B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Shared style invalidation with removals</title> 4 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1707116"> 5 <link rel="help" href="https://drafts.csswg.org/css-scoping/"> 6 <link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez"> 7 <link rel="author" href="https://mozilla.org" title="Mozilla"> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <div id="host-1"></div> 11 <div id="host-2"></div> 12 <script> 13 const INITIALLY_COMMON_STYLE = `<style>:host { background-color: red !important }</style>`; 14 let helper = document.querySelector("#host-1"); 15 let host = document.querySelector("#host-2"); 16 17 test(function() { 18 helper.attachShadow({ mode: "open" }).innerHTML = INITIALLY_COMMON_STYLE; 19 assert_equals(getComputedStyle(helper).backgroundColor, "rgb(255, 0, 0)", "Common style should apply to helper"); 20 21 host.attachShadow({ mode: "open" }).innerHTML = INITIALLY_COMMON_STYLE; 22 assert_equals(getComputedStyle(host).backgroundColor, "rgb(255, 0, 0)", "Common style should apply to host"); 23 24 host.shadowRoot.innerHTML = `<style>:host { background-color: lime; width: 100px; height: 100px; }</style>`; 25 assert_equals(getComputedStyle(host).backgroundColor, "rgb(0, 255, 0)", "Common style should no longer apply to host"); 26 }); 27 </script>