| Hao Liu | 38dd900 | 2023-09-07 16:15:53 | [diff] [blame] | 1 | <!doctype html> |
| 2 | |
| 3 | <script src="/resources/testharness.js"></script> |
| 4 | <script src="/resources/testharnessreport.js"></script> |
| 5 | <link rel="stylesheet" href="resources/empty_style.css"> |
| 6 | <link rel="stylesheet" href="resources/non_exist.css"> |
| 7 | |
| 8 | <script> |
| 9 | promise_test(async () => { |
| 10 | const css_resource_timing_entries = await new Promise(resolve => { |
| 11 | new PerformanceObserver((list, observer) => { |
| 12 | let css_resource_timing_entries = list.getEntries().filter(e => e.name.includes('css')); |
| 13 | if (css_resource_timing_entries.length >= 2) { |
| 14 | resolve(css_resource_timing_entries); |
| 15 | } |
| 16 | }).observe({ 'type': 'resource', 'buffered': true }); |
| 17 | }); |
| 18 | |
| 19 | assert_equals(css_resource_timing_entries.length, 2, |
| 20 | 'There should be two resource timing entries for css resources'); |
| 21 | |
| 22 | assert_equals(css_resource_timing_entries.filter( |
| 23 | e => e.name.includes('empty_style.css')).length, 1, |
| 24 | 'There should be one resource timing entry for successfully fetched resource.'); |
| 25 | |
| 26 | assert_equals(css_resource_timing_entries.filter( |
| 27 | e => e.name.includes('non_exist.css')).length, 1, |
| 28 | 'There should be one resource timing entry for fetching failed resource.'); |
| 29 | |
| 30 | }, 'Resource fetched by HTTP protocol should have resource timing entry emitted, \ |
| 31 | even when the fetch failed.'); |
| 32 | </script> |
| 33 | |
| 34 | </html> |