subframe-observing-longtask.html (1293B)
1 <!DOCTYPE HTML> 2 <meta charset=utf-8> 3 <meta name="viewport" content="width=device-width"> 4 <title>Child Iframe</title> 5 <h1>Child Iframe observing long tasks</h1> 6 7 <script> 8 const observer = new PerformanceObserver(function(entryList) { 9 for (i = 0; i < entryList.getEntries().length; i++) { 10 const longtask = entryList.getEntries()[i]; 11 // Ignore long task generated within here, as part of making this iframe. 12 // Ignore multiple-contexts and unknown because they cause longtask-in-parentiframe test to be flaky. 13 if (longtask.name == 'self' || 14 longtask.name == 'multiple-contexts' || longtask.name == 'unknown') 15 return; 16 // TODO(panicker): include containerType. 17 const attribution = longtask.attribution[0]; 18 const entryContents = { 19 'entryType': longtask.entryType, 20 'frame-attribution': longtask.name, 21 'task-attribution': attribution.name, 22 'containerType': attribution.containerType, 23 'containerId': attribution.containerId, 24 'containerName': attribution.containerName, 25 'containerSrc': attribution.containerSrc 26 }; 27 top.postMessage(entryContents, '*'); 28 } 29 }); 30 observer.observe({entryTypes: ['longtask']}); 31 </script>