selectorText-dynamic-001.html (1008B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <title>CSS Test: invalidation of class changes when the selector in a rule has changed</title> 4 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io"> 5 <link rel="help" href="https://drafts.csswg.org/selectors-4/#invalid"> 6 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1432850"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <style> 10 body { background: green; } 11 .red { background: red; } 12 </style> 13 <body class="red"> 14 Should have a green background. 15 <script> 16 test(() => { 17 document.body.offsetTop; 18 assert_equals(getComputedStyle(document.body).backgroundColor, "rgb(255, 0, 0)"); 19 document.body.className = ""; 20 document.styleSheets[0].cssRules[1].selectorText = ".bar"; 21 assert_equals(getComputedStyle(document.body).backgroundColor, "rgb(0, 128, 0)"); 22 }, "Style should be recomputed correctly when the selector it depends on changes"); 23 </script> 24 </body>