containertiming-two-overlapping-imgs.html (1971B)
1 <!DOCTYPE HTML> 2 <meta charset=utf-8> 3 <title>Container Timing: observe containertiming in a containertiming tree overlapping image children</title> 4 <body> 5 <style> 6 body { 7 margin: 0; 8 } 9 </style> 10 <script src="/resources/testharness.js"></script> 11 <script src="/resources/testharnessreport.js"></script> 12 <script src="/container-timing/resources/container-timing-helpers.js"></script> 13 <script src="/element-timing/resources/element-timing-helpers.js"></script> 14 <script> 15 let beforeRender; 16 async_test(function (t) { 17 assert_implements(window.PerformanceContainerTiming, "PerformanceContainerTiming is not implemented"); 18 const observer = new PerformanceObserver( 19 t.step_func_done(function(entryList) { 20 assert_equals(entryList.getEntries().length, 1); 21 const entry = entryList.getEntries()[0]; 22 checkContainerEntry(entry, 'div_ct', null, beforeRender) 23 checkRect(entry, [0, 150, 0, 150]) 24 // size is the total area that has been painted, so the more intersection, the less area painted. 25 checkContainerSize(entry, 17500); 26 }) 27 ); 28 observer.observe({entryTypes: ['container']}); 29 30 // Add a div that is the container timing root 31 const div = document.createElement('div'); 32 div.setAttribute('containertiming', 'div_ct'); 33 document.body.appendChild(div); 34 35 // Add two overlapping images 36 const img1 = document.createElement('img'); 37 img1.src = '/container-timing/resources/square100.png'; 38 img1.setAttribute('id', 'img1_id'); 39 img1.style.position = 'absolute'; 40 div.appendChild(img1); 41 42 const img2 = document.createElement('img'); 43 img2.src = '/container-timing/resources/square100.png'; 44 img2.setAttribute('id', 'img2_id'); 45 img2.style.marginLeft = '50px'; 46 img2.style.marginTop = '50px'; 47 img2.style.position = 'absolute'; 48 div.appendChild(img2); 49 50 beforeRender = performance.now(); 51 }, 'Overlapping images report to containertiming.'); 52 </script> 53 54 </body>