spurious-frame-callbacks-optimization.html (1327B)
1 <!DOCTYPE html> 2 <head> 3 <title>Optimization of requestAnimationFrame callbacks that don't modify the DOM shouldn't break animations</title> 4 <link rel="author" title="Mukilan Thiyagarajan" href="mailto:mukilan@igalia.com"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 </head> 8 <body> 9 <div id="target">0</div> 10 </body> 11 <script> 12 "use strict"; 13 async_test(function(test) { 14 let frame = 0; 15 const draw = (t) => { 16 frame += 1; 17 if (frame < 11) { 18 // Don't mutate the DOM for 10 frames to meet the threshold for Servo's 19 // spurious frame optimization to kick in. 20 requestAnimationFrame(draw); 21 } else if (frame == 11) { 22 // Don't schedule next rAF so the compositor's tick is disabled. 23 // This is specific to Servo as the spurious frame detection at the 24 // time of this test was broken. 25 test.step_timeout(() => { 26 requestAnimationFrame(draw); 27 }, 0); 28 } else { 29 // Normal frames. 30 document.getElementById('target').innerText = t; 31 requestAnimationFrame(draw); 32 } 33 }; 34 35 let target = document.getElementById('target'); 36 test.step_timeout(test.step_func_done(() => { 37 assert_greater_than(parseInt(target.innerText), 500); 38 }), 550); 39 requestAnimationFrame(draw); 40 }); 41 </script>