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

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: 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 // 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 function checkResourceSizes() {
21 var lowerBound, upperBound;
22 var entries = performance.getEntriesByName(url);
23 assert_equals(entries.length, 3, 'Wrong number of entries');
24 // Firefox 47 puts the preflight after the request in the timeline.
25 // Sort by requestStart for compatibility.
26 entries.sort((a, b) => b.requestStart - a.requestStart);
27 var seenCount = 0;
28 for (var entry of entries) {
29 switch (seenCount) {
30 case 0:
31 assert_greater_than(entry.transferSize, 0,
32 'no preflight transferSize');
33 lowerBound = entry.transferSize - fuzzFactor;
34 upperBound = entry.transferSize + fuzzFactor;
35 break;
36
37 case 1:
38 assert_between_exclusive(entry.transferSize, minHeaderSize,
39 maxHeaderSize,
40 'preflight transferSize');
41 break;
42
43 case 2:
44 assert_between_exclusive(entry.transferSize, lowerBound,
45 upperBound,
46 'preflighted transferSize');
47 break;
48 }
49 ++seenCount;
50 }
51 }
52
53 promise_test(() => {
54 var eatBody = response => response.arrayBuffer();
55 var requirePreflight = {headers: {'X-Require-Preflight': '1'}};
56 return fetch(url)
57 .then(eatBody)
58 .then(() => fetch(url, requirePreflight))
59 .then(eatBody)
60 .then(runAsyncTasks)
61 .then(checkResourceSizes);
62 }, 'PerformanceResourceTiming sizes Fetch with preflight test');
63 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698