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

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

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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/misc/resource-timing-sizes-redirect.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/misc/resource-timing-sizes-redirect.html b/third_party/WebKit/LayoutTests/http/tests/misc/resource-timing-sizes-redirect.html
index 729ee3223f034a82c66699182047dd4c81d29ddc..b094b4b30cf1b99063a2e72ea850eda15b0f8252 100644
--- a/third_party/WebKit/LayoutTests/http/tests/misc/resource-timing-sizes-redirect.html
+++ b/third_party/WebKit/LayoutTests/http/tests/misc/resource-timing-sizes-redirect.html
@@ -3,97 +3,4 @@
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/get-host-info.js?pipe=sub"></script>
<script src="/misc/resources/run-async-tasks-promise.js"></script>
-<script>
-const baseUrl =
- new URL('/security/resources/cors-hello.php', location.href).href;
-const expectedSize = 73;
-
-// Because apache decrements the Keep-Alive max value on each request, the
-// transferSize will vary slightly between requests for the same resource.
-const fuzzFactor = 3; // bytes
-
-const minHeaderSize = 100;
-
-const hostInfo = get_host_info();
-
-var directUrl, sameOriginRedirect, crossOriginRedirect, mixedRedirect;
-var complexRedirect;
-
-function checkBodySizeFields(entry) {
- assert_equals(entry.decodedBodySize, expectedSize, 'decodedBodySize');
- assert_equals(entry.encodedBodySize, expectedSize, 'encodedBodySize');
-}
-
-function checkResourceSizes() {
- var entries = performance.getEntriesByType('resource');
- var lowerBound, upperBound, withRedirectLowerBound;
- var seenCount = 0;
- for (var entry of entries) {
- switch (entry.name) {
- case directUrl:
- checkBodySizeFields(entry);
- assert_greater_than(entry.transferSize, expectedSize,
- 'transferSize');
- lowerBound = entry.transferSize - fuzzFactor;
- upperBound = entry.transferSize + fuzzFactor;
- withRedirectLowerBound = entry.transferSize + minHeaderSize;
- ++seenCount;
- break;
-
- case sameOriginRedirect:
- checkBodySizeFields(entry);
- assert_greater_than(entry.transferSize, withRedirectLowerBound,
- 'transferSize');
- ++seenCount;
- break;
-
- case crossOriginRedirect:
- case mixedRedirect:
- case complexRedirect:
- checkBodySizeFields(entry);
- assert_between_exclusive(entry.transferSize, lowerBound, upperBound,
- 'transferSize');
- ++seenCount;
- break;
-
- default:
- break;
- }
- }
- assert_equals(seenCount, 5, 'seenCount');
-}
-
-function redirectUrl(redirectSourceOrigin, allowOrigin, targetUrl) {
- return redirectSourceOrigin +
- '/resources/redirect.php?cors_allow_origin=' +
- encodeURIComponent(allowOrigin) +
- '&url=' + encodeURIComponent(targetUrl);
-}
-
-promise_test(() => {
- // Use a different URL every time so that the cache behaviour does not
- // depend on execution order.
- directUrl = baseUrl + '?unique=' + Math.random().toString().substring(2) +
- '&cors=*';
- sameOriginRedirect = redirectUrl(hostInfo.HTTP_ORIGIN, '*', directUrl);
- crossOriginRedirect = redirectUrl(hostInfo.HTTP_REMOTE_ORIGIN,
- hostInfo.HTTP_ORIGIN, directUrl);
- mixedRedirect = redirectUrl(hostInfo.HTTP_REMOTE_ORIGIN,
- hostInfo.HTTP_ORIGIN, sameOriginRedirect);
- complexRedirect = redirectUrl(hostInfo.HTTP_ORIGIN,
- hostInfo.HTTP_REMOTE_ORIGIN, mixedRedirect);
- var eatBody = response => response.arrayBuffer();
- return fetch(directUrl)
- .then(eatBody)
- .then(() => fetch(sameOriginRedirect))
- .then(eatBody)
- .then(() => fetch(crossOriginRedirect))
- .then(eatBody)
- .then(() => fetch(mixedRedirect))
- .then(eatBody)
- .then(() => fetch(complexRedirect))
- .then(eatBody)
- .then(runAsyncTasks)
- .then(checkResourceSizes);
-}, 'PerformanceResourceTiming sizes Fetch with redirect test');
-</script>
+<script src="/misc/resources/resource-timing-sizes-redirect.js"></script>

Powered by Google App Engine
This is Rietveld 408576698