buffered-flag.any.js (977B)
1 async_test(t => { 2 performance.clearResourceTimings(); 3 // First observer creates second in callback to ensure the entry has been dispatched by the time 4 // the second observer begins observing. 5 new PerformanceObserver(() => { 6 // Second observer requires 'buffered: true' to see an entry. 7 new PerformanceObserver(t.step_func_done(list => { 8 const entries = list.getEntries(); 9 assert_equals(entries.length, 1, 'There should be 1 resource entry.'); 10 assert_equals(entries[0].entryType, 'resource'); 11 assert_greater_than(entries[0].startTime, 0); 12 assert_greater_than(entries[0].responseEnd, entries[0].startTime); 13 assert_greater_than(entries[0].duration, 0); 14 assert_true(entries[0].name.endsWith('resources/empty.js')); 15 })).observe({'type': 'resource', buffered: true}); 16 }).observe({'entryTypes': ['resource']}); 17 fetch('resources/empty.js'); 18 }, 'PerformanceObserver with buffered flag sees previous resource entries.');