| <!DOCTYPE HTML> |
| <meta charset=utf-8> |
| <title>Resource timing attributes are consistent for the same-origin subresources.</title> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <body> |
| <script> |
| promise_test(async t => { |
| const link = document.createElement("link"); |
| link.rel = "webbundle"; |
| link.href = "../resources/wbn/dynamic1.wbn?pipe=trickle(d0.5)"; |
| link.resources.add('https://web-platform.test:8444/web-bundle/resources/wbn/dynamic/resource1.js'); |
| const script_id = 'https://web-platform.test:8444/web-bundle/resources/wbn/dynamic/resource1.js'; |
| document.body.appendChild(link); |
| var script_entries = 0; |
| var web_bundle_entries = 0; |
| var web_bundle_entry, script_entry; |
| const promise = new Promise(resolve => { |
| new PerformanceObserver(t.step_func(entryList => { |
| var entries = entryList.getEntriesByType("resource"); |
| for (var i = 0; i < entries.length; ++i) { |
| if (entries[i].name === script_id) { |
| script_entry = entries[i]; |
| script_entries++; |
| } |
| |
| if (entries[i].name === 'https://web-platform.test:8444/web-bundle/resources/wbn/dynamic1.wbn?pipe=trickle(d0.5)') { |
| web_bundle_entry = entries[i]; |
| web_bundle_entries++; |
| } |
| } |
| |
| if (web_bundle_entries > 0 && script_entries > 0) { |
| // Check timestamps. |
| assert_greater_than_equal(script_entry.responseStart, script_entry.requestStart + 500); |
| assert_greater_than_equal(script_entry.responseStart, web_bundle_entry.responseStart); |
| assert_greater_than_equal(script_entry.responseEnd, script_entry.responseStart); |
| assert_greater_than_equal(script_entry.requestStart, script_entry.connectEnd); |
| assert_greater_than_equal(script_entry.responseEnd, script_entry.responseStart); |
| // Check sizes. |
| assert_greater_than(script_entry.encodedBodySize, 0); |
| assert_equals(script_entry.transferSize, script_entry.encodedBodySize + 300); |
| assert_equals(script_entry.encodedBodySize, script_entry.decodedBodySize); |
| resolve(); |
| } |
| })).observe({entryTypes: ["resource"]}); |
| }); |
| const script = document.createElement("script"); |
| script.type = "module"; |
| script.src = script_id; |
| document.body.appendChild(script); |
| return promise; |
| }, '"Timestamp attributes filled in resource timing entries should be consistent."'); |
| </script> |
| <h1>Resource timing attributes are consistent</h1> |
| <p> |
| This test verifies that attributes filled in the PerformanceResourceTiming entries for subresources |
| loaded from the WebBundle are consistent. |
| </p> |
| <div id="log"></div> |
| </body> |
| |