first-image-child.html (1861B)
1 <!DOCTYPE html> 2 <head> 3 <title>Performance Paint Timing Test: child ignores parent FCP</title> 4 <meta name="timeout" content="long"> 5 </head> 6 <body> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <iframe src='../resources/subframe-sending-paint.html' id='child-iframe'></iframe> 10 <img src='../resources/circles.png'/> 11 <script> 12 setup({"hide_test_state": true}); 13 async_test(function (t) { 14 assert_implements(window.PerformancePaintTiming, "Paint Timing isn't supported."); 15 16 window.addEventListener('message', t.step_func(e => { 17 // Child iframe should not have any paint-timing entries. 18 assert_equals(e.data, '0'); 19 t.done(); 20 })); 21 // Wait for onload to ensure img and iframe have loaded. 22 window.addEventListener('load', function() { 23 function testPaintEntries() { 24 const bufferedEntries = performance.getEntriesByType('paint'); 25 if (bufferedEntries.length < 2) { 26 t.step_timeout(testPaintEntries, 20); 27 return; 28 } 29 t.step(function() { 30 assert_equals(bufferedEntries.length, 2, 'There should be two paint timing instances.'); 31 assert_equals(bufferedEntries[0].entryType, 'paint'); 32 assert_equals(bufferedEntries[0].name, 'first-paint'); 33 assert_equals(bufferedEntries[1].entryType, 'paint'); 34 assert_equals(bufferedEntries[1].name, 'first-contentful-paint'); 35 // Ask child iframe to send its paint-timing entries. 36 document.getElementById('child-iframe'). 37 contentWindow.postMessage('', '*'); 38 }) 39 } 40 testPaintEntries(); 41 }); 42 }, 'Child iframe ignores paint-timing events fired from parent image rendering.'); 43 </script> 44 </body> 45 </html>