Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 8a1d60c

Browse files
noamrmoz-wptsync-bot
authored andcommitted
Bug 1831797 [wpt PR 39881] - ResourceTiming: firstInterimResponseStart should include 100 responses, a=testonly
Automatic update from web-platform-tests ResourceTiming: firstInterimResponseStart should include 100 responses Amending implementation based on spec change as per review See discussion: w3c/resource-timing#366 Refactored HTTP1 & HTTP2 tests to be flexible as to whether to send 100 response. Bug: 1402089 Change-Id: If47bd5bf25425f9e5a012cd46be99bdaa1ec6969 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4507473 Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org> Reviewed-by: Yoav Weiss <yoavweiss@chromium.org> Cr-Commit-Position: refs/heads/main@{#1141426} -- wpt-commits: fd5c04fb75f07887491c0c47999a5e95d40b190c wpt-pr: 39881
1 parent 22b0a86 commit 8a1d60c

File tree

4 files changed

+94
-70
lines changed

4 files changed

+94
-70
lines changed

testing/web-platform/tests/resource-timing/interim-response-times.h2.html

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf-8" />
5+
<meta name="timeout" content="long">
56
<title>Resource Timing: PerformanceResourceTiming interim resource times</title>
67
<link rel="author" title="Google" href="http://www.google.com/" />
78
<script src="/common/utils.js"></script>
@@ -10,55 +11,64 @@
1011
<script src="/resources/testharnessreport.js"></script>
1112
<script>
1213
const {REMOTE_HOST} = get_host_info();
13-
function interim_response_time_test({origin, tao, with103, expected}) {
14+
function interim_response_time_test({origin, with100, with103}) {
1415
promise_test(async t => {
15-
const delay = 100;
16+
const delay = 500;
1617
const url = new URL('/resource-timing/resources/header-delay.h2.py',
17-
origin == "same-origin" ?
18+
origin == "same-origin" ?
1819
location.href :
1920
`${location.protocol}//${REMOTE_HOST}:${location.port}`);
2021
url.searchParams.set("delay", delay);
21-
if (tao)
22+
if (origin === "cross-origin-with-TAO")
2223
url.searchParams.set("tao", "*");
24+
if (with100)
25+
url.searchParams.set("with100", "true");
2326
if (with103)
2427
url.searchParams.set("with103", "true");
2528
const response = await fetch(url.toString(), {mode: "cors"});
2629
assert_equals(response.status, 200)
2730
await response.text();
2831
const [entry] = performance.getEntriesByName(url.toString());
29-
if (expected) {
30-
assert_greater_than(entry.firstInterimResponseStart,
31-
entry.requestStart + delay * 2,
32-
"firstInterimResponseStart");
33-
assert_greater_than(entry.responseStart,
34-
entry.firstInterimResponseStart + delay,
35-
"responseStart");
36-
} else {
32+
if (origin === "cross-origin") {
3733
assert_equals(entry.firstInterimResponseStart, 0);
34+
return;
35+
}
36+
let total_delay = entry.requestStart;
37+
if (with100) {
38+
total_delay += delay;
39+
assert_greater_than(entry.firstInterimResponseStart,
40+
total_delay,
41+
"firstInterimResponseStart > 100 response");
3842
}
3943

40-
assert_equals(entry.toJSON().firstInterimResponseStart,
41-
entry.firstInterimResponseStart);
42-
}, `Fetch from ${origin} ${with103 ? "with" : "without"} early hints, ${
43-
tao ? "with" : "without"} Timing-Allow-Origin should ${
44-
expected ? "expose" : "not expose"} interim response times`);
45-
}
46-
47-
interim_response_time_test(
48-
{origin: "same-origin", tao: false, with103: true, expected: true});
44+
if (with103) {
45+
total_delay += delay;
46+
if (with100) {
47+
assert_less_than_equal(entry.firstInterimResponseStart,
48+
total_delay, "firstInterimResponseStart > 100 response");
49+
} else {
50+
assert_greater_than(entry.firstInterimResponseStart,
51+
delay, "firstInterimResponseStart > 100 response");
52+
}
53+
}
4954

50-
// TAO should protect firstInterimResponseStart
51-
interim_response_time_test(
52-
{origin: "cross-origin", tao: true, with103: true, expected: true});
53-
interim_response_time_test(
54-
{origin: "cross-origin", tao: false, with103: true, expected: false});
55+
total_delay += delay;
56+
if (!with100 && !with103)
57+
assert_equals(entry.firstInterimResponseStart, 0);
5558

56-
// Without early hints, firstInterimResponseStart should be 0 regalrdss of protections.
57-
interim_response_time_test(
58-
{origin: "same-origin", tao: false, with103: false, expected: false});
59-
interim_response_time_test(
60-
{origin: "cross-origin", tao: true, with103: false, expected: false});
59+
assert_greater_than(entry.responseStart, total_delay,
60+
"responseStart");
61+
}, `Fetch from ${origin} ${with103 ? "with" : "without"} early hints, ${
62+
with100 ? "with" : "without"} 100 response`);
63+
}
6164

65+
for (const with103 of [true, false]) {
66+
for (const with100 of [true, false]) {
67+
for (origin of ['same-origin', 'cross-origin', 'cross-origin-with-TAO']) {
68+
interim_response_time_test({with100, with103, origin});
69+
}
70+
}
71+
}
6272
</script>
6373
</body>
6474
</html>

testing/web-platform/tests/resource-timing/interim-response-times.html

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf-8" />
5+
<meta name="timeout" content="long">
56
<title>Resource Timing: PerformanceResourceTiming interim resource times</title>
67
<link rel="author" title="Google" href="http://www.google.com/" />
78
<script src="/common/utils.js"></script>
@@ -10,53 +11,62 @@
1011
<script src="/resources/testharnessreport.js"></script>
1112
<script>
1213
const {REMOTE_ORIGIN} = get_host_info();
13-
function interim_response_time_test({origin, tao, with103, expected}) {
14+
function interim_response_time_test({origin, with100, with103}) {
1415
promise_test(async t => {
15-
const delay = 100;
16+
const delay = 500;
1617
const url = new URL('/resource-timing/resources/header-delay.py',
1718
origin == "same-origin" ? location.href : REMOTE_ORIGIN);
1819
url.searchParams.set("delay", delay);
19-
if (tao)
20+
if (origin === "cross-origin-with-TAO")
2021
url.searchParams.set("tao", "*");
22+
if (with100)
23+
url.searchParams.set("with100", "true");
2124
if (with103)
2225
url.searchParams.set("with103", "true");
2326
const response = await fetch(url.toString(), {mode: "cors"});
2427
assert_equals(response.status, 200)
2528
await response.text();
2629
const [entry] = performance.getEntriesByName(url.toString());
27-
if (expected) {
28-
assert_greater_than(entry.firstInterimResponseStart,
29-
entry.requestStart + delay * 2,
30-
"firstInterimResponseStart");
31-
assert_greater_than(entry.responseStart,
32-
entry.firstInterimResponseStart + delay,
33-
"responseStart");
34-
} else {
30+
if (origin === "cross-origin") {
3531
assert_equals(entry.firstInterimResponseStart, 0);
32+
return;
33+
}
34+
let total_delay = entry.requestStart;
35+
if (with100) {
36+
total_delay += delay;
37+
assert_greater_than(entry.firstInterimResponseStart,
38+
total_delay,
39+
"firstInterimResponseStart > 100 response");
3640
}
3741

38-
assert_equals(entry.toJSON().firstInterimResponseStart,
39-
entry.firstInterimResponseStart);
40-
}, `Fetch from ${origin} ${with103 ? "with" : "without"} early hints, ${
41-
tao ? "with" : "without"} Timing-Allow-Origin should ${
42-
expected ? "expose" : "not expose"} interim response times`);
43-
}
44-
45-
interim_response_time_test(
46-
{origin: "same-origin", tao: false, with103: true, expected: true});
42+
if (with103) {
43+
total_delay += delay;
44+
if (with100) {
45+
assert_less_than_equal(entry.firstInterimResponseStart,
46+
total_delay, "firstInterimResponseStart > 100 response");
47+
} else {
48+
assert_greater_than(entry.firstInterimResponseStart,
49+
delay, "firstInterimResponseStart > 100 response");
50+
}
51+
}
4752

48-
// TAO should protect firstInterimResponseStart
49-
interim_response_time_test(
50-
{origin: "cross-origin", tao: true, with103: true, expected: true});
51-
interim_response_time_test(
52-
{origin: "cross-origin", tao: false, with103: true, expected: false});
53+
total_delay += delay;
54+
if (!with100 && !with103)
55+
assert_equals(entry.firstInterimResponseStart, 0);
5356

54-
// Without early hints, firstInterimResponseStart should be 0 regalrdss of protections.
55-
interim_response_time_test(
56-
{origin: "same-origin", tao: false, with103: false, expected: false});
57-
interim_response_time_test(
58-
{origin: "cross-origin", tao: true, with103: false, expected: false});
57+
assert_greater_than(entry.responseStart, total_delay,
58+
"responseStart");
59+
}, `Fetch from ${origin} ${with103 ? "with" : "without"} early hints, ${
60+
with100 ? "with" : "without"} 100 response`);
61+
}
5962

63+
for (const with103 of [true, false]) {
64+
for (const with100 of [true, false]) {
65+
for (origin of ['same-origin', 'cross-origin', 'cross-origin-with-TAO']) {
66+
interim_response_time_test({with100, with103, origin});
67+
}
68+
}
69+
}
6070
</script>
6171
</body>
6272
</html>

testing/web-platform/tests/resource-timing/resources/header-delay.h2.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
def handle_headers(frame, request, response):
44
delay = int(request.GET.first(b"delay")) / 1000
5-
sleep(delay)
6-
response.writer.write_raw_header_frame(headers=[(b":status", b"100")], end_headers=True)
7-
sleep(delay)
85

9-
if b"with103" in request.GET:
6+
if b"with100" in request.GET:
7+
sleep(delay)
108
response.writer.write_raw_header_frame(headers=[(b":status", b"103")], end_headers=True)
9+
10+
if b"with103" in request.GET:
1111
sleep(delay)
12+
response.writer.write_raw_header_frame(headers=[(b":status", b"103")], end_headers=True)
1213

14+
sleep(delay)
1315
response.status = 200
1416

1517
if b"tao" in request.GET:

testing/web-platform/tests/resource-timing/resources/header-delay.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ def main(request, response):
55

66
# TODO: make this exported from ResponseWriter
77
handler = response.writer._handler
8-
sleep(delay)
9-
handler.send_response(100)
10-
handler.end_headers()
11-
sleep(delay)
8+
if b"with100" in request.GET:
9+
sleep(delay)
10+
handler.send_response(100)
11+
handler.end_headers()
1212

1313
if b"with103" in request.GET:
14+
sleep(delay)
1415
handler.send_response(103)
1516
handler.send_header("Link", "<resources/empty.js>;rel=preload;as=script")
1617
handler.end_headers()
17-
sleep(delay)
18+
19+
sleep(delay)
1820

1921
handler.send_response(200)
2022

0 commit comments

Comments
 (0)