observe-child-element.html (1425B)
1 <!DOCTYPE HTML> 2 <meta charset=utf-8> 3 <title>Element Timing: do NOT observe elements from same-origin iframes</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="resources/element-timing-helpers.js"></script> 13 <script> 14 async_test((t) => { 15 assert_implements(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented"); 16 const observer = new PerformanceObserver( 17 t.step_func_done((entryList) => { 18 assert_unreached("Should not have received an entry!"); 19 }) 20 ); 21 observer.observe({entryTypes: ['element']}); 22 // We add the iframe during onload to be sure that the observer is registered 23 // in time for it to observe the element timing. 24 // TODO(npm): change observer to use buffered flag. 25 window.onload = () => { 26 // Add iframe with an image of width and height equal to 100. 27 const iframe = document.createElement('iframe'); 28 iframe.src = 'resources/iframe-with-square.html'; 29 iframe.onload = () => { 30 // After a short delay, assume that the entry was not dispatched to the 31 // parent frame. 32 t.step_timeout(() => { 33 t.done(); 34 }, 100); 35 } 36 document.body.appendChild(iframe); 37 }; 38 }, 'Element in child iframe is not observed, even if same-origin.'); 39 </script> 40 41 </body>