script-rt-entries.html (1425B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8" /> 5 <title>Resource Timing Entry Sequence of Events for Scripts</title> 6 <link rel="help" href="https://w3c.github.io/resource-timing/"/> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 </head> 10 <body> 11 <script> 12 async_test(t => { 13 const script = document.createElement("script"); 14 const url = new URL('resources/empty.js', location.href).toString(); 15 script.addEventListener('load', t.step_func(() => { 16 assert_equals(performance.getEntriesByName(url).length, 1); 17 t.done(); 18 })); 19 script.src = url; 20 document.body.appendChild(script); 21 t.add_cleanup(() => script.remove()); 22 }, "The RT entry for script should be available when the script 'load' event fires"); 23 24 async_test(t => { 25 const script = document.createElement("script"); 26 const url = new URL('resources/non-existent.js', location.href).toString(); 27 script.addEventListener('error', t.step_func(() => { 28 assert_equals(performance.getEntriesByName(url).length, 1); 29 t.done(); 30 })); 31 script.src = url; 32 document.body.appendChild(script); 33 t.add_cleanup(() => script.remove()); 34 }, "The RT entry for a non-existent script should be available when the script 'error' event fires"); 35 </script> 36 </body> 37 </html>