update-the-rendering.html (1254B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <link rel="help" href="https://html.spec.whatwg.org/C/#update-the-rendering"> 5 6 <body> 7 <script> 8 'use strict'; 9 10 async_test(t => { 11 t.events = []; 12 13 let w = window.open('/common/blank.html', 'name', 14 'width=100,height=100,menubar=no,toolbar=no,location=no'); 15 t.add_cleanup(() => { w.close(); }); 16 w.addEventListener('load', t.step_func(() => { 17 w.focus(); 18 let element = w.document.createElement('input'); 19 element.autofocus = true; 20 element.style.marginTop = '200px'; // Setting focus causes scrolling. 21 element.addEventListener('focus', t.step_func(() => { 22 t.events.push('autofocus'); 23 })); 24 25 w.addEventListener('scroll', t.step_func(() => { 26 t.events.push('scroll'); 27 })); 28 29 w.requestAnimationFrame( 30 () => w.requestAnimationFrame(t.step_func_done(() => { 31 t.events.push('animationFrame'); 32 assert_array_equals(t.events, ['autofocus', 'scroll', 'animationFrame'], t.events); 33 }))); 34 35 w.document.body.appendChild(element); 36 })); 37 }, '"Flush autofocus candidates" should be happen before a scroll event and ' + 38 'animation frame callbacks'); 39 </script> 40 </body>