idlharness.window.js (907B)
1 // META: script=/resources/WebIDLParser.js 2 // META: script=/resources/idlharness.js 3 4 // https://w3c.github.io/longtasks/ 5 6 'use strict'; 7 8 idl_test( 9 ['longtasks'], 10 ['performance-timeline', 'hr-time'], 11 (idl_array, t) => new Promise((resolve, reject) => { 12 const longTask = () => { 13 const begin = self.performance.now(); 14 while (self.performance.now() < begin + 100); 15 } 16 t.step_timeout(longTask, 0); 17 18 const observer = new PerformanceObserver((entryList, observer) => { 19 const entries = Array.from(entryList.getEntries()); 20 idl_array.add_objects({ 21 PerformanceLongTaskTiming: entries.slice(0, 1), 22 TaskAttributionTiming: entries[0].attribution, 23 }); 24 observer.disconnect(); 25 resolve(); 26 }); 27 observer.observe({entryTypes: ['longtask']}); 28 29 t.step_timeout(() => { 30 reject('longtask entry was not observed'); 31 }, 1000); 32 }) 33 );