OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="/resources/testharness.js"></script> |
| 3 <script src="/resources/testharnessreport.js"></script> |
| 4 <script src="/misc/resources/run-async-tasks-promise.js"></script> |
| 5 <script> |
| 6 const url = '/misc/resources/gzip-content-encoding.php'; |
| 7 const uncompressedSize = 1250; |
| 8 |
| 9 function checkResourceSizes() { |
| 10 var absoluteUrl = new URL(url, location.href).href; |
| 11 var entries = performance.getEntriesByName(absoluteUrl); |
| 12 assert_equals(entries.length, 2, 'Wrong number of entries'); |
| 13 for (var entry of entries) { |
| 14 if (entry.name === absoluteUrl) { |
| 15 assert_between_exclusive(entry.encodedBodySize, 0, uncompressedSize, |
| 16 'encodedBodySize'); |
| 17 assert_equals(entry.decodedBodySize, uncompressedSize); |
| 18 } |
| 19 } |
| 20 } |
| 21 |
| 22 promise_test(() => { |
| 23 // Fetch twice to ensure at least one fetch comes from the cache. |
| 24 var eatBody = response => response.arrayBuffer(); |
| 25 return fetch(url) |
| 26 .then(eatBody) |
| 27 .then(() => fetch(url)) |
| 28 .then(eatBody) |
| 29 .then(runAsyncTasks) |
| 30 .then(checkResourceSizes); |
| 31 }, 'PerformanceResourceTiming sizes compressed content test'); |
| 32 </script> |
OLD | NEW |