Skip to content

Commit

Permalink
Bug 1831797 [wpt PR 39881] - ResourceTiming: firstInterimResponseStar…
Browse files Browse the repository at this point in the history
…t 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 <[email protected]>
Reviewed-by: Yoav Weiss <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1141426}

--

wpt-commits: fd5c04fb75f07887491c0c47999a5e95d40b190c
wpt-pr: 39881
  • Loading branch information
noamr authored and moz-wptsync-bot committed May 21, 2023
1 parent 22b0a86 commit 8a1d60c
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>
<head>
<meta charset="utf-8" />
<meta name="timeout" content="long">
<title>Resource Timing: PerformanceResourceTiming interim resource times</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<script src="/common/utils.js"></script>
Expand All @@ -10,55 +11,64 @@
<script src="/resources/testharnessreport.js"></script>
<script>
const {REMOTE_HOST} = get_host_info();
function interim_response_time_test({origin, tao, with103, expected}) {
function interim_response_time_test({origin, with100, with103}) {
promise_test(async t => {
const delay = 100;
const delay = 500;
const url = new URL('/resource-timing/resources/header-delay.h2.py',
origin == "same-origin" ?
origin == "same-origin" ?
location.href :
`${location.protocol}//${REMOTE_HOST}:${location.port}`);
url.searchParams.set("delay", delay);
if (tao)
if (origin === "cross-origin-with-TAO")
url.searchParams.set("tao", "*");
if (with100)
url.searchParams.set("with100", "true");
if (with103)
url.searchParams.set("with103", "true");
const response = await fetch(url.toString(), {mode: "cors"});
assert_equals(response.status, 200)
await response.text();
const [entry] = performance.getEntriesByName(url.toString());
if (expected) {
assert_greater_than(entry.firstInterimResponseStart,
entry.requestStart + delay * 2,
"firstInterimResponseStart");
assert_greater_than(entry.responseStart,
entry.firstInterimResponseStart + delay,
"responseStart");
} else {
if (origin === "cross-origin") {
assert_equals(entry.firstInterimResponseStart, 0);
return;
}
let total_delay = entry.requestStart;
if (with100) {
total_delay += delay;
assert_greater_than(entry.firstInterimResponseStart,
total_delay,
"firstInterimResponseStart > 100 response");
}

assert_equals(entry.toJSON().firstInterimResponseStart,
entry.firstInterimResponseStart);
}, `Fetch from ${origin} ${with103 ? "with" : "without"} early hints, ${
tao ? "with" : "without"} Timing-Allow-Origin should ${
expected ? "expose" : "not expose"} interim response times`);
}

interim_response_time_test(
{origin: "same-origin", tao: false, with103: true, expected: true});
if (with103) {
total_delay += delay;
if (with100) {
assert_less_than_equal(entry.firstInterimResponseStart,
total_delay, "firstInterimResponseStart > 100 response");
} else {
assert_greater_than(entry.firstInterimResponseStart,
delay, "firstInterimResponseStart > 100 response");
}
}

// TAO should protect firstInterimResponseStart
interim_response_time_test(
{origin: "cross-origin", tao: true, with103: true, expected: true});
interim_response_time_test(
{origin: "cross-origin", tao: false, with103: true, expected: false});
total_delay += delay;
if (!with100 && !with103)
assert_equals(entry.firstInterimResponseStart, 0);

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

for (const with103 of [true, false]) {
for (const with100 of [true, false]) {
for (origin of ['same-origin', 'cross-origin', 'cross-origin-with-TAO']) {
interim_response_time_test({with100, with103, origin});
}
}
}
</script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>
<head>
<meta charset="utf-8" />
<meta name="timeout" content="long">
<title>Resource Timing: PerformanceResourceTiming interim resource times</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<script src="/common/utils.js"></script>
Expand All @@ -10,53 +11,62 @@
<script src="/resources/testharnessreport.js"></script>
<script>
const {REMOTE_ORIGIN} = get_host_info();
function interim_response_time_test({origin, tao, with103, expected}) {
function interim_response_time_test({origin, with100, with103}) {
promise_test(async t => {
const delay = 100;
const delay = 500;
const url = new URL('/resource-timing/resources/header-delay.py',
origin == "same-origin" ? location.href : REMOTE_ORIGIN);
url.searchParams.set("delay", delay);
if (tao)
if (origin === "cross-origin-with-TAO")
url.searchParams.set("tao", "*");
if (with100)
url.searchParams.set("with100", "true");
if (with103)
url.searchParams.set("with103", "true");
const response = await fetch(url.toString(), {mode: "cors"});
assert_equals(response.status, 200)
await response.text();
const [entry] = performance.getEntriesByName(url.toString());
if (expected) {
assert_greater_than(entry.firstInterimResponseStart,
entry.requestStart + delay * 2,
"firstInterimResponseStart");
assert_greater_than(entry.responseStart,
entry.firstInterimResponseStart + delay,
"responseStart");
} else {
if (origin === "cross-origin") {
assert_equals(entry.firstInterimResponseStart, 0);
return;
}
let total_delay = entry.requestStart;
if (with100) {
total_delay += delay;
assert_greater_than(entry.firstInterimResponseStart,
total_delay,
"firstInterimResponseStart > 100 response");
}

assert_equals(entry.toJSON().firstInterimResponseStart,
entry.firstInterimResponseStart);
}, `Fetch from ${origin} ${with103 ? "with" : "without"} early hints, ${
tao ? "with" : "without"} Timing-Allow-Origin should ${
expected ? "expose" : "not expose"} interim response times`);
}

interim_response_time_test(
{origin: "same-origin", tao: false, with103: true, expected: true});
if (with103) {
total_delay += delay;
if (with100) {
assert_less_than_equal(entry.firstInterimResponseStart,
total_delay, "firstInterimResponseStart > 100 response");
} else {
assert_greater_than(entry.firstInterimResponseStart,
delay, "firstInterimResponseStart > 100 response");
}
}

// TAO should protect firstInterimResponseStart
interim_response_time_test(
{origin: "cross-origin", tao: true, with103: true, expected: true});
interim_response_time_test(
{origin: "cross-origin", tao: false, with103: true, expected: false});
total_delay += delay;
if (!with100 && !with103)
assert_equals(entry.firstInterimResponseStart, 0);

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

for (const with103 of [true, false]) {
for (const with100 of [true, false]) {
for (origin of ['same-origin', 'cross-origin', 'cross-origin-with-TAO']) {
interim_response_time_test({with100, with103, origin});
}
}
}
</script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

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

if b"with103" in request.GET:
if b"with100" in request.GET:
sleep(delay)
response.writer.write_raw_header_frame(headers=[(b":status", b"103")], end_headers=True)

if b"with103" in request.GET:
sleep(delay)
response.writer.write_raw_header_frame(headers=[(b":status", b"103")], end_headers=True)

sleep(delay)
response.status = 200

if b"tao" in request.GET:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ def main(request, response):

# TODO: make this exported from ResponseWriter
handler = response.writer._handler
sleep(delay)
handler.send_response(100)
handler.end_headers()
sleep(delay)
if b"with100" in request.GET:
sleep(delay)
handler.send_response(100)
handler.end_headers()

if b"with103" in request.GET:
sleep(delay)
handler.send_response(103)
handler.send_header("Link", "<resources/empty.js>;rel=preload;as=script")
handler.end_headers()
sleep(delay)

sleep(delay)

handler.send_response(200)

Expand Down

0 comments on commit 8a1d60c

Please sign in to comment.