diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/resource-timing/interim-response-times.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/resource-timing/interim-response-times.html')
-rw-r--r-- | testing/web-platform/tests/resource-timing/interim-response-times.html | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/testing/web-platform/tests/resource-timing/interim-response-times.html b/testing/web-platform/tests/resource-timing/interim-response-times.html new file mode 100644 index 0000000000..a4d03f599e --- /dev/null +++ b/testing/web-platform/tests/resource-timing/interim-response-times.html @@ -0,0 +1,72 @@ +<!DOCTYPE html> +<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> +<script src="/common/get-host-info.sub.js"></script> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + const {REMOTE_ORIGIN} = get_host_info(); + function interim_response_time_test({origin, with100, with103}) { + promise_test(async t => { + 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 (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 (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"); + } + + 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"); + } + } + + total_delay += delay; + if (!with100 && !with103) + assert_equals(entry.firstInterimResponseStart, 0); + + 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> |