resource_reparenting.html (2024B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8" /> 5 <title>Resource Timing reparenting elements</title> 6 <link rel="author" title="Google" href="http://www.google.com/" /> 7 <link rel="help" href="http://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src="resources/webperftestharness.js"></script> 11 <script src="resources/webperftestharnessextension.js"></script> 12 <script> 13 let iframe; 14 function setup_iframe() { 15 iframe = document.getElementById('frameContext'); 16 const d = iframe.contentWindow.document; 17 const iframeBody = d.createElement('body'); 18 19 const move_to_parent = d.createElement('img'); 20 move_to_parent.src = 'blue.png?id=move_to_parent'; 21 iframeBody.appendChild(move_to_parent); 22 iframeBody.removeChild(move_to_parent); 23 24 const parentBody = document.getElementsByTagName('body')[0]; 25 parentBody.appendChild(move_to_parent); 26 27 const move_to_child = document.createElement('img'); 28 move_to_child.src = 'blue.png?id=move_to_child'; 29 parentBody.appendChild(move_to_child); 30 parentBody.removeChild(move_to_child); 31 iframeBody.appendChild(move_to_child); 32 } 33 function onload_test() { 34 const context = new PerformanceContext(iframe.contentWindow.performance); 35 const entries = context.getEntriesByType('resource'); 36 37 const index = window.location.pathname.lastIndexOf('/'); 38 const pathname = window.location.pathname.substring(0, index); 39 let expected_entries = {}; 40 expected_entries[pathname + '/resources/blue.png?id=move_to_child'] = 'img'; 41 42 test_resource_entries(entries, expected_entries); 43 } 44 window.setup_iframe = setup_iframe; 45 </script> 46 </head> 47 <body> 48 <h1>Description</h1> 49 <p>This test validates that reparenting an element doesn't change the initiator document.</p> 50 <div id="log"></div> 51 <iframe id="frameContext" onload="onload_test();" src="resources/inject_resource_test.html"></iframe> 52 </body> 53 </html>