Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="/resources/testharness.js"></script> | |
| 3 <script src="/resources/testharnessreport.js"></script> | |
| 4 <script src="/resources/get-host-info.js?pipe=sub"></script> | |
|
Kunihiko Sakamoto
2016/07/07 09:56:51
Is this necessary?
Adam Rice
2016/07/07 11:21:12
Removed, thanks.
| |
| 5 <script src="/misc/resources/run-async-tasks-promise.js"></script> | |
| 6 <script> | |
| 7 const url = '/misc/resources/gzip-content-encoding.php'; | |
| 8 const uncompressedSize = 1250; | |
| 9 | |
| 10 var seenCount = 0; | |
| 11 | |
| 12 function checkResourceSizes() { | |
| 13 var entries = performance.getEntriesByType('resource'); | |
| 14 var absoluteUrl = new URL(url, location.href).href; | |
| 15 for (var entry of entries) { | |
| 16 if (entry.name === absoluteUrl) { | |
|
Kunihiko Sakamoto
2016/07/07 09:56:50
You can use performance.getEntriesByName(absoluteU
Adam Rice
2016/07/07 11:21:12
That's better, thank you.
| |
| 17 assert_between_exclusive(entry.encodedBodySize, 0, uncompressedSize, | |
| 18 'encodedBodySize'); | |
| 19 assert_equals(entry.decodedBodySize, uncompressedSize); | |
| 20 ++seenCount; | |
| 21 } | |
| 22 } | |
| 23 assert_equals(seenCount, 2, 'seenCount'); | |
| 24 } | |
| 25 | |
| 26 promise_test(() => { | |
| 27 // Fetch twice to ensure at least one fetch comes from the cache. | |
| 28 var eatBody = response => response.arrayBuffer(); | |
| 29 return fetch(url) | |
| 30 .then(eatBody) | |
| 31 .then(() => fetch(url)) | |
| 32 .then(eatBody) | |
| 33 .then(runAsyncTasks) | |
| 34 .then(checkResourceSizes); | |
| 35 }, 'PerformanceResourceTiming sizes compressed content test'); | |
| 36 </script> | |
| OLD | NEW |