preferred-stylesheet-order.html (950B)
1 <!DOCTYPE html> 2 <link rel="help" href="https://drafts.csswg.org/cssom/#add-a-css-style-sheet"> 3 <link rel="help" href="https://drafts.csswg.org/cssom/#create-a-css-style-sheet"> 4 <link rel="help" href="https://html.spec.whatwg.org/#update-a-style-block"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <div id="t1">This text should be green</div> 8 <script> 9 function createStyleElement(text, title) { 10 var elm = document.createElement("style"); 11 elm.setAttribute("title", title); 12 elm.appendChild(document.createTextNode(text)); 13 return elm; 14 } 15 16 test(function() { 17 document.head.appendChild(createStyleElement("#t1 {color:green}", "preferred")); 18 document.head.appendChild(createStyleElement("#t1 {color:red}", "notpreferred")); 19 20 assert_equals(getComputedStyle(t1).color, "rgb(0, 128, 0)"); 21 }, "Preferred stylesheet where insertion order is reversed tree order"); 22 </script>