long-microtask.window.js (829B)
1 // META: script=resources/utils.js 2 3 async_test(function (t) { 4 assert_implements(window.PerformanceLongTaskTiming, 'Longtasks are not supported.'); 5 new PerformanceObserver( 6 t.step_func_done(entryList => { 7 const entries = entryList.getEntries(); 8 assert_equals(entries.length, 1, 9 'Exactly one entry is expected.'); 10 const longtask = entries[0]; 11 checkLongTaskEntry(longtask); 12 t.done(); 13 }) 14 ).observe({entryTypes: ['longtask']}); 15 16 window.onload = () => { 17 /* Generate a slow microtask */ 18 Promise.resolve().then(() => { 19 const begin = window.performance.now(); 20 while (window.performance.now() < begin + 60); 21 }); 22 }; 23 }, 'A short task followed by a long microtask is observable.');