slider-switch.html (1747B)
1 <!doctype html> 2 <title>Check correct event bases for onclick</title> 3 <meta charset="utf-8"> 4 <link rel="help" href="https://svgwg.org/svg2-draft/single-page.html#interact-EventAttributes"> 5 <link rel="author" title="Edvard Thörnros" href="mailto:edvardt@opera.com"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <svg width="200" height="100"> 9 <rect x="0" y="0" width="100" height="100" id="a" fill="#0AA"> 10 <set begin="a.click" attributeName="display" to="none" fill="freeze"/> 11 <set begin="b.click" attributeName="display" to="block" fill="freeze"/> 12 </rect> 13 <rect x="100" y="0" width="100" height="100" id="b" display="none" fill="#A0A"> 14 <set begin="a.click" attributeName="display" to="block" fill="freeze"/> 15 <set begin="b.click" attributeName="display" to="none" fill="freeze"/> 16 </rect> 17 </svg> 18 <script> 19 let clicks_remaining = 2; 20 let a = document.querySelector("#a"); 21 let b = document.querySelector("#b"); 22 function perform_clicks(t) { 23 t.step_timeout(function() { 24 a.dispatchEvent(new Event("click")); 25 t.step_timeout(function() { 26 b.dispatchEvent(new Event("click")); 27 }, 20); 28 }, 20); 29 } 30 async_test(t => { 31 let observer = document.querySelector("#b > set + set"); 32 observer.addEventListener('beginEvent', t.step_func(function() { 33 if (clicks_remaining == 0) { 34 assert_equals(window.getComputedStyle(a).display, "block"); 35 assert_equals(window.getComputedStyle(b).display, "none"); 36 t.done(); 37 return; 38 } 39 perform_clicks(t); 40 clicks_remaining--; 41 })); 42 window.onload = t.step_func(() => { 43 perform_clicks(t); 44 clicks_remaining--; 45 }); 46 }); 47 </script>