style_load_event.html (1027B)
1 <!DOCTYPE html> 2 <title>HTML Test: The style load event should fire when textContent is changed</title> 3 <link rel="author" href="mailto:masonf@chromium.org"> 4 <link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#update-a-style-block"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 8 <script> 9 var loadCount = 0; 10 function load() { loadCount++; } 11 </script> 12 13 <style id=target onload="load()"> 14 .box { color:red; } 15 </style> 16 <div class='box'>Box</div> 17 18 <script> 19 window.onload = () => { 20 const target = document.getElementById('target'); 21 promise_test(async t => { 22 assert_equals(loadCount,1,"Style element should have loaded once by now"); 23 target.textContent = `.box { color: green; }`; 24 await new Promise(resolve => target.addEventListener('load', resolve)); 25 assert_equals(loadCount,2,"Style element should fire the load event when textContent changes"); 26 },"style load event should fire when textContent changed"); 27 }; 28 </script>