1 async_test(function (t) {
2 assert_precondition(window.PerformanceLongTaskTiming, 'Longtasks are not supported.');
3 new PerformanceObserver(
4 t.step_func_done(entryList => {
5 const entries = entryList.getEntries();
6 assert_equals(entries.length, 1,
7 'Exactly one entry is expected.');
8 const longtask = entries[0];
9 assert_equals(longtask.entryType, 'longtask');
10 assert_equals(longtask.name, 'self');
11 assert_greater_than(longtask.duration, 50);
12 assert_greater_than_equal(longtask.startTime, 0);
13 const currentTime = performance.now();
14 assert_less_than_equal(longtask.startTime, currentTime);
17 ).observe({entryTypes: ['longtask']});
19 window.onload = () => {
20 /* Generate a slow microtask */
21 Promise.resolve().then(() => {
22 const begin = window.performance.now();
23 while (window.performance.now() < begin + 60);
26 }, 'A short task followed by a long microtask is observable.');