deadline-max-rAF-dynamic.html (1377B)
1 <!DOCTYPE html> 2 <title>window.requestIdleCallback max idle period deadline (requestAnimationFrame).</title> 3 <meta name="timeout" content="long"> 4 <link rel="author" title="Noam Rosenthal" href="mailto:noam@webkit.org" /> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="resources/ric-utils.js"></script> 8 <script> 9 10 promise_test(async () => { 11 for (let i = 0; i < getRICRetryCount(); ++i) { 12 const {before, after} = await new Promise(resolve => requestIdleCallback(async deadline => { 13 const before = deadline.timeRemaining(); 14 const animationFramePromise = new Promise(requestAnimationFrame); 15 const after = deadline.timeRemaining(); 16 17 // Waiting till rAF is handled before the next iteration, to avoid residual callacks between iterations. 18 await animationFramePromise; 19 resolve({before, after}) 20 })) 21 22 assert_less_than_equal(after, before) 23 assert_less_than_equal(after, getPendingRenderDeadlineCap()) 24 } 25 26 }, 'Check that the deadline is changed if there is a new requestAnimationFrame from within requestIdleCallback.'); 27 </script> 28 <h1>Test of requestIdleCallback deadline behavior</h1> 29 <p>The test can pass accidentally as idle deadlines have a maximum but they can always be shorter. 30 It runs multiple times to expose potential failures.</p> 31 <div id="log"></div>