observe-svg-data-uri-image.html (1281B)
1 <!DOCTYPE HTML> 2 <meta charset=utf-8> 3 <title>Largest Contentful Paint: observe image.</title> 4 <body> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="resources/largest-contentful-paint-helpers.js"></script> 8 <script> 9 async_test(function (t) { 10 assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented"); 11 const beforeLoad = performance.now(); 12 const observer = new PerformanceObserver( 13 t.step_func_done(function(entryList) { 14 assert_equals(entryList.getEntries().length, 1); 15 const entry = entryList.getEntries()[0]; 16 let url = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"'; 17 url += ' width="100" height="50"><rect fill="lime" width="100"'; 18 url += ' height="50"/></svg>'; 19 // green.svg is 100 by 50 20 const size = 100 * 50; 21 checkImage(entry, url, 'image_id', size, beforeLoad); 22 }) 23 ); 24 observer.observe({type: 'largest-contentful-paint', buffered: true}); 25 }, 'Same-origin image is observable.'); 26 </script> 27 28 <img src='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="50"><rect fill="lime" width="100" height="50"/></svg>' id='image_id'/> 29 </body>