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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/misc/resource-timing-sizes-cors-preflight.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: Fix variable name style. 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 // Because apache decrements the Keep-Alive max value on each request, the
8 // transferSize will vary slightly between requests for the same resource.
9 const fuzzFactor = 3; // bytes
10
11 const hostInfo = get_host_info();
12 const url = new URL('/misc/resources/cors-preflight.php',
13 hostInfo['HTTP_REMOTE_ORIGIN']).href;
14
15 // The header bytes are expected to be > |minHeaderSize| and
16 // < |maxHeaderSize|. If they are outside this range the test will fail.
17 const minHeaderSize = 100;
18 const maxHeaderSize = 1024;
19
20 var seenCount = 0;
Kunihiko Sakamoto 2016/07/07 09:56:51 nit: move this into checkResourceSizes()
Adam Rice 2016/07/07 11:21:12 Done.
21
22 function checkResourceSizes() {
23 var lowerBound, upperBound;
24 var entries = performance.getEntriesByType('resource');
25 // Firefox 47 puts the preflight after the request in the timeline.
26 // Sort by requestStart for compatibility.
27 entries.sort((a, b) => b.requestStart > a.requestStart ? 1 : -1);
Kunihiko Sakamoto 2016/07/07 09:56:51 nit: (a, b) => b.requestStart - a.requestStart wo
Adam Rice 2016/07/07 11:21:12 Done.
28 for (var entry of entries) {
29 if (entry.name === url) {
30 switch (seenCount) {
31 case 0:
Kunihiko Sakamoto 2016/07/07 09:56:51 -4 indent
Adam Rice 2016/07/07 11:21:12 Done.
32 assert_greater_than(entry.transferSize, 0,
33 'no preflight transferSize');
34 lowerBound = entry.transferSize - fuzzFactor;
35 upperBound = entry.transferSize + fuzzFactor;
36 break;
37
38 case 1:
39 assert_between_exclusive(entry.transferSize, minHeaderSize,
40 maxHeaderSize,
41 'preflight transferSize');
42 break;
43
44 case 2:
45 assert_between_exclusive(entry.transferSize, lowerBound,
46 upperBound,
47 'preflighted transferSize');
48 break;
49 }
50 ++seenCount;
51 }
52 }
53 assert_equals(seenCount, 3, 'seenCount');
54 }
55
56 promise_test(() => {
57 var eatBody = response => response.arrayBuffer();
58 var requirePreflight = {headers: {'X-Require-Preflight': '1'}};
59 return fetch(url)
60 .then(eatBody)
61 .then(() => fetch(url, requirePreflight))
62 .then(eatBody)
63 .then(runAsyncTasks)
64 .then(checkResourceSizes);
65 }, 'PerformanceResourceTiming sizes Fetch with preflight test');
66 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698