longtask-in-childiframe.html (2473B)
1 <!DOCTYPE HTML> 2 <meta charset=utf-8> 3 <title>LongTask Timing: long task in nested child iframe</title> 4 <body> 5 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="resources/utils.js"></script> 9 10 <h1>Long Task in Nested Child Iframe</h1> 11 <div id="log"></div> 12 <script> 13 promise_test(async (t) => { 14 assert_implements(window.PerformanceLongTaskTiming, 'Longtasks are not supported.'); 15 const initialTime = performance.now(); 16 const performanceObserverTimeout = 5 * 1000; 17 const longTasksPromise = new Promise(resolve => { 18 const observer = new PerformanceObserver( 19 t.step_func(function (entryList) { 20 const entries = entryList.getEntries(); 21 entries.forEach(longtask => { 22 assert_equals(longtask.entryType, 'longtask'); 23 if (hasUnrelatedTaskName(longtask.name, 'same-origin-descendant')) { 24 return; 25 } 26 checkLongTaskEntry(longtask, 'same-origin-descendant'); 27 // Assert the TaskAttributionTiming entry in attribution. 28 assert_equals(longtask.attribution.length, 1, 29 'Exactly one attribution entry is expected'); 30 const attribution = longtask.attribution[0]; 31 assert_equals(attribution.entryType, 'taskattribution'); 32 assert_equals(attribution.name, 'unknown'); 33 assert_equals(attribution.duration, 0); 34 assert_equals(attribution.startTime, 0); 35 assert_equals(attribution.containerType, 'iframe'); 36 assert_equals(attribution.containerId, 'child-iframe-id'); 37 assert_equals(attribution.containerName, 'child-iframe-name'); 38 assert_equals(attribution.containerSrc, 'resources/subframe-with-longtask.html'); 39 observer.disconnect(); 40 resolve(); 41 }) 42 }) 43 ); 44 observer.observe({ 45 entryTypes: ['longtask'] 46 }); 47 const iframe = document.createElement('iframe'); 48 iframe.id = 'child-iframe-id'; 49 iframe.name = 'child-iframe-name'; 50 document.body.appendChild(iframe); 51 iframe.src = 'resources/subframe-with-longtask.html'; 52 }); 53 const timeout = new Promise( 54 (resolve, reject) => t.step_timeout( 55 () => { 56 reject(new Error('observer failed to find any entries')) 57 }, 58 performanceObserverTimeout) 59 ) 60 return Promise.race([longTasksPromise, timeout]); 61 }, 'Performance longtask entries in child iframe are observable in parent.'); 62 </script> 63 64 </body>