idlharness.html (1022B)
1 <!doctype html> 2 <title>Largest Contentful Paint IDL tests</title> 3 <link rel="help" href="https://wicg.github.io/largest-contentful-paint/"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/resources/WebIDLParser.js"></script> 7 <script src="/resources/idlharness.js"></script> 8 <script> 9 'use strict'; 10 11 idl_test( 12 ['largest-contentful-paint'], 13 ['performance-timeline', 'dom', 'hr-time', 'paint-timing'], 14 async (idl_array, t) => { 15 idl_array.add_objects({ 16 LargestContentfulPaint: ['lcp'] 17 }); 18 19 window.lcp = await new Promise((resolve, reject) => { 20 const observer = new PerformanceObserver(entryList => { 21 resolve(entryList.getEntries()[0]); 22 }); 23 observer.observe({type: 'largest-contentful-paint', buffered: true}); 24 t.step_timeout(() => reject('Timed out waiting for LargestContentfulPaint entry'), 3000); 25 }); 26 } 27 ); 28 </script> 29 <!-- a contentful element to observe --> 30 <img src=/images/lcp-100x50.png>