buffered-flag.window.js (1170B)
1 setup({"hide_test_state": true}); 2 async_test(t => { 3 assert_implements(window.PerformancePaintTiming, "Paint Timing isn't supported."); 4 // First observer creates a second one in the callback to ensure the entry has been dispatched 5 // by the time the second observer begins observing. 6 new PerformanceObserver(entries => { 7 const entry_seen = entries.getEntriesByName('first-contentful-paint').length > 0; 8 // Abort if we have not yet received the entry. 9 if (!entry_seen) 10 return; 11 12 // Second observer requires 'buffered: true' to see the entry. 13 new PerformanceObserver(t.step_func_done(list => { 14 const fcp = list.getEntriesByName('first-contentful-paint'); 15 assert_equals(fcp.length, 1, 'Should have an fcp entry'); 16 const entry = fcp[0]; 17 assert_equals(entry.entryType, 'paint'); 18 })).observe({'type': 'paint', buffered: true}); 19 }).observe({'entryTypes': ['paint']}); 20 // Trigger the first contentful paint entry. 21 const img = document.createElement("img"); 22 img.src = "../resources/circles.png"; 23 document.body.appendChild(img); 24 }, "PerformanceObserver with buffered flag sees previous FCP entry.");