Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/misc/resources/resource-timing-sizes-content-encoding.js

Issue 2159163002: Set Resource Timing transferSize field in Workers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@resource_timing_sizes_render_process
Patch Set: Rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 // This test code is shared between resource-timing-sizes-content-encoding.html
2 <script src="/resources/testharness.js"></script> 2 // and resource-timing-sizes-content-encoding-worker.html
3 <script src="/resources/testharnessreport.js"></script> 3
4 <script src="/misc/resources/run-async-tasks-promise.js"></script> 4 if (typeof document === 'undefined') {
5 <script> 5 importScripts('/resources/testharness.js',
6 '/misc/resources/run-async-tasks-promise.js');
7 }
8
6 const url = '/misc/resources/gzip-content-encoding.php'; 9 const url = '/misc/resources/gzip-content-encoding.php';
7 const uncompressedSize = 1250; 10 const uncompressedSize = 1250;
8 11
9 function checkResourceSizes() { 12 function checkResourceSizes() {
10 var absoluteUrl = new URL(url, location.href).href; 13 var absoluteUrl = new URL(url, location.href).href;
11 var entries = performance.getEntriesByName(absoluteUrl); 14 var entries = performance.getEntriesByName(absoluteUrl);
12 assert_equals(entries.length, 2, 'Wrong number of entries'); 15 assert_equals(entries.length, 2, 'Wrong number of entries');
13 for (var entry of entries) { 16 for (var entry of entries) {
14 if (entry.name === absoluteUrl) { 17 if (entry.name === absoluteUrl) {
15 assert_between_exclusive(entry.encodedBodySize, 0, uncompressedSize, 18 assert_between_exclusive(entry.encodedBodySize, 0, uncompressedSize,
16 'encodedBodySize'); 19 'encodedBodySize');
17 assert_equals(entry.decodedBodySize, uncompressedSize); 20 assert_equals(entry.decodedBodySize, uncompressedSize);
18 } 21 }
19 } 22 }
20 } 23 }
21 24
22 promise_test(() => { 25 promise_test(() => {
23 // Fetch twice to ensure at least one fetch comes from the cache. 26 // Fetch twice to ensure at least one fetch comes from the cache.
24 var eatBody = response => response.arrayBuffer(); 27 var eatBody = response => response.arrayBuffer();
25 return fetch(url) 28 return fetch(url)
26 .then(eatBody) 29 .then(eatBody)
27 .then(() => fetch(url)) 30 .then(() => fetch(url))
28 .then(eatBody) 31 .then(eatBody)
29 .then(runAsyncTasks) 32 .then(runAsyncTasks)
30 .then(checkResourceSizes); 33 .then(checkResourceSizes);
31 }, 'PerformanceResourceTiming sizes compressed content test'); 34 }, 'PerformanceResourceTiming sizes compressed content test');
32 </script> 35
36 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698