longtask-sync-xhr.html (1008B)
1 <!DOCTYPE HTML> 2 <meta charset=utf-8> 3 <title>LongTask Timing: synchronous XHR</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: synchronous XHR</h1> 11 <div id="log"></div> 12 <script> 13 setup(() => assert_implements(window.PerformanceLongTaskTiming, 'Longtasks are not supported.')); 14 15 promise_test(async t => { 16 const receivedLongTask = new Promise(resolve => 17 new PerformanceObserver(entries => resolve(entries.getEntries())).observe({entryTypes: ['longtask']})); 18 await new Promise(resolve => window.addEventListener('load', () => { 19 const xhr = new XMLHttpRequest(); 20 xhr.open('GET', '/resource-timing/resources/delay-css.py?delay=100', false /* synchronous xhr */); 21 xhr.send(); 22 resolve(); 23 })); 24 const entries = await receivedLongTask; 25 assert_equals(entries.length, 1); 26 }, 'A long synchronous XHR is a longtask'); 27 </script> 28 </body>