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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/misc/resource-timing-sizes-redirect.html

Issue 2105713002: Render process changes for ResourceTiming sizes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@resource_timing_sizes_browser_process
Patch Set: Initialise encoded_body_length for sync XHR to data: URLs 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
(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>
5 <script src="/misc/resources/run-async-tasks-promise.js"></script>
6 <script>
7 const baseUrl =
8 new URL('/security/resources/cors-hello.php', location.href).href;
9 const expectedSize = 73;
10
11 // Because apache decrements the Keep-Alive max value on each request, the
12 // transferSize will vary slightly between requests for the same resource.
13 const fuzzFactor = 3; // bytes
14
15 const minHeaderSize = 100;
16
17 const hostInfo = get_host_info();
18
19 var directUrl, sameOriginRedirect, crossOriginRedirect, mixedRedirect;
20 var complexRedirect;
21
22 function checkBodySizeFields(entry) {
23 assert_equals(entry.decodedBodySize, expectedSize, 'decodedBodySize');
24 assert_equals(entry.encodedBodySize, expectedSize, 'encodedBodySize');
25 }
26
27 function checkResourceSizes() {
28 var entries = performance.getEntriesByType('resource');
29 var lowerBound, upperBound, withRedirectLowerBound;
30 var seenCount = 0;
31 for (var entry of entries) {
32 switch (entry.name) {
33 case directUrl:
34 checkBodySizeFields(entry);
35 assert_greater_than(entry.transferSize, expectedSize,
36 'transferSize');
37 lowerBound = entry.transferSize - fuzzFactor;
38 upperBound = entry.transferSize + fuzzFactor;
39 withRedirectLowerBound = entry.transferSize + minHeaderSize;
40 ++seenCount;
41 break;
42
43 case sameOriginRedirect:
44 checkBodySizeFields(entry);
45 assert_greater_than(entry.transferSize, withRedirectLowerBound,
46 'transferSize');
47 ++seenCount;
48 break;
49
50 case crossOriginRedirect:
51 case mixedRedirect:
52 case complexRedirect:
53 checkBodySizeFields(entry);
54 assert_between_exclusive(entry.transferSize, lowerBound, upperBound,
55 'transferSize');
56 ++seenCount;
57 break;
58
59 default:
60 break;
61 }
62 }
63 assert_equals(seenCount, 5, 'seenCount');
64 }
65
66 function redirectUrl(redirectSourceOrigin, allowOrigin, targetUrl) {
67 return redirectSourceOrigin +
68 '/resources/redirect.php?cors_allow_origin=' +
69 encodeURIComponent(allowOrigin) +
70 '&url=' + encodeURIComponent(targetUrl);
71 }
72
73 promise_test(() => {
74 // Use a different URL every time so that the cache behaviour does not
75 // depend on execution order.
76 directUrl = baseUrl + '?unique=' + Math.random().toString().substring(2) +
77 '&cors=*';
78 sameOriginRedirect = redirectUrl(hostInfo.HTTP_ORIGIN, '*', directUrl);
79 crossOriginRedirect = redirectUrl(hostInfo.HTTP_REMOTE_ORIGIN,
80 hostInfo.HTTP_ORIGIN, directUrl);
81 mixedRedirect = redirectUrl(hostInfo.HTTP_REMOTE_ORIGIN,
82 hostInfo.HTTP_ORIGIN, sameOriginRedirect);
83 complexRedirect = redirectUrl(hostInfo.HTTP_ORIGIN,
84 hostInfo.HTTP_REMOTE_ORIGIN, mixedRedirect);
85 var eatBody = response => response.arrayBuffer();
86 return fetch(directUrl)
87 .then(eatBody)
88 .then(() => fetch(sameOriginRedirect))
89 .then(eatBody)
90 .then(() => fetch(crossOriginRedirect))
91 .then(eatBody)
92 .then(() => fetch(mixedRedirect))
93 .then(eatBody)
94 .then(() => fetch(complexRedirect))
95 .then(eatBody)
96 .then(runAsyncTasks)
97 .then(checkResourceSizes);
98 }, 'PerformanceResourceTiming sizes Fetch with redirect test');
99 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698