resource-timing-failed-fetch-web-bundle.tentative.html (1914B)
1 <!DOCTYPE html> 2 <meta charset="utf-8" /> 3 <title> 4 Resource timing attributes are consistent for the same-origin subresources. 5 </title> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="/web-bundle/resources/test-helpers.js"></script> 9 10 <body> 11 <script> 12 setup(() => { 13 assert_true(HTMLScriptElement.supports("webbundle")); 14 }); 15 16 promise_test(async (t) => { 17 const script_url = 'dynamic1:resource1.js'; 18 const non_exist_script_url = 'dynamic1:non_exist_resource.js'; 19 // Using functions from /web-bundle/resources/test-helpers.js. 20 const element = createWebBundleElement( 21 "../web-bundle/resources/wbn/dynamic1.wbn", 22 /*resources=*/[script_url] 23 ); 24 25 document.body.appendChild(element); 26 27 // Fetch the script that is in the web bundle. 28 const script = document.createElement("script"); 29 script.type = "module"; 30 script.src = script_url; 31 document.body.appendChild(script); 32 33 // Fetch the script that is not in the web bundle. 34 // Using functions from /web-bundle/resources/test-helpers.js. 35 await fetchAndWaitForReject(non_exist_script_url); 36 37 let resource1_entries = []; 38 let non_exist_resource_entries = []; 39 40 await new Promise((resolve) => { 41 new PerformanceObserver(list => { 42 resource1_entries.push(list.getEntries().filter(e => e.name.includes('resource1.js'))); 43 non_exist_resource_entries.push( 44 list.getEntries().filter(e => e.name.includes('non_exist_resource.js'))); 45 if (resource1_entries.length == 1 && non_exist_resource_entries.length == 1) { 46 resolve(); 47 } 48 } 49 ).observe({ type: 'resource', buffered: true }); 50 }); 51 }, "Web bundle resources should have resource timing entries, even when the fetch failed."); 52 </script> 53 </body>