cross-origin-iframe-element.sub.html (1459B)
1 <!DOCTYPE HTML> 2 <meta charset=utf-8> 3 <title>Element Timing: do NOT observe elements from cross-origin iframes</title> 4 <body> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="resources/element-timing-helpers.js"></script> 8 <script> 9 async_test((t) => { 10 assert_implements(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented"); 11 const observer = new PerformanceObserver( 12 t.step_func_done((entryList) => { 13 assert_unreached("We should not observe a cross origin element."); 14 }) 15 ); 16 observer.observe({entryTypes: ['element']}); 17 // We add the iframe during onload to be sure that the observer is registered 18 // in time for it to observe the element timing. 19 // TODO(npm): change observer to use buffered flag. 20 window.onload = t.step_func(() => { 21 // Add a cross origin iframe with an image. 22 const iframe = document.createElement('iframe'); 23 iframe.src = 'http://{{domains[www]}}:{{ports[http][1]}}' 24 + '/element-timing/resources/iframe-with-square.html'; 25 document.body.appendChild(iframe); 26 iframe.onload = t.step_func(() => { 27 t.step_timeout( () => { 28 // After some wait, assume observer did not receive the entry, so the test passes. 29 t.done(); 30 }, 100); 31 }); 32 }); 33 }, 'Element from cross origin iframe is NOT observable.'); 34 </script> 35 36 </body>