resource-timing-attributes-consistent.https.tentative.sub.html (3144B)
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="../resources/test-helpers.js"></script> 9 <body> 10 <script> 11 setup(() => { 12 assert_true(HTMLScriptElement.supports("webbundle")); 13 }); 14 15 promise_test(async (t) => { 16 const bundle_url = 17 "https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/dynamic1.wbn?pipe=trickle(d0.5)"; 18 const script_url = 19 "https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/dynamic/resource1.js"; 20 const element = createWebBundleElement( 21 "../resources/wbn/dynamic1.wbn?pipe=trickle(d0.5)", 22 /*resources=*/ [script_url] 23 ); 24 document.body.appendChild(element); 25 var script_entries = 0; 26 var web_bundle_entries = 0; 27 var web_bundle_entry, script_entry; 28 const promise = new Promise((resolve) => { 29 new PerformanceObserver( 30 t.step_func((entryList) => { 31 var entries = entryList.getEntriesByType("resource"); 32 for (var i = 0; i < entries.length; ++i) { 33 if (entries[i].name === script_url) { 34 script_entry = entries[i]; 35 script_entries++; 36 } 37 38 if (entries[i].name === bundle_url) { 39 web_bundle_entry = entries[i]; 40 web_bundle_entries++; 41 } 42 } 43 44 if (web_bundle_entries > 0 && script_entries > 0) { 45 // Check timestamps. 46 assert_greater_than_equal( 47 script_entry.responseStart, 48 script_entry.requestStart + 500 49 ); 50 assert_greater_than_equal( 51 script_entry.responseStart, 52 web_bundle_entry.responseStart 53 ); 54 assert_greater_than_equal( 55 script_entry.responseEnd, 56 script_entry.responseStart 57 ); 58 assert_greater_than_equal( 59 script_entry.requestStart, 60 script_entry.connectEnd 61 ); 62 assert_greater_than_equal( 63 script_entry.responseEnd, 64 script_entry.responseStart 65 ); 66 // Check sizes. 67 assert_greater_than(script_entry.encodedBodySize, 0); 68 assert_equals( 69 script_entry.transferSize, 70 script_entry.encodedBodySize + 300 71 ); 72 assert_equals( 73 script_entry.encodedBodySize, 74 script_entry.decodedBodySize 75 ); 76 resolve(); 77 } 78 }) 79 ).observe({ entryTypes: ["resource"] }); 80 }); 81 const script = document.createElement("script"); 82 script.type = "module"; 83 script.src = script_url; 84 document.body.appendChild(script); 85 return promise; 86 }, "Timestamp attributes filled in resource timing entries should be consistent."); 87 </script> 88 </body>