author | Noam Rosenthal <noamr@users.noreply.github.com> |
Fri, 23 Apr 2021 10:23:19 +0000 | |
changeset 577300 | eed53a92a5ca294ae784430fe52d0870e63d5978 |
parent 577299 | 5f89a8cd30238f603337bc94a388f121f998cc0f |
child 577301 | 4a0f8597e20358df72c6614a2643167d9fe2439b |
push id | 141827 |
push user | wptsync@mozilla.com |
push date | Sat, 24 Apr 2021 02:11:12 +0000 |
treeherder | autoland@3a7d9d49c316 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | testonly |
bugs | 1705928, 28563 |
milestone | 90.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
new file mode 100644 --- /dev/null +++ b/testing/web-platform/tests/common/slow-redirect.py @@ -0,0 +1,29 @@ +import time + +def main(request, response): + """Simple handler that causes redirection. + + The request should typically have two query parameters: + status - The status to use for the redirection. Defaults to 302. + location - The resource to redirect to. + """ + status = 302 + delay = 2 + if b"status" in request.GET: + try: + status = int(request.GET.first(b"status")) + except ValueError: + pass + + if b"delay" in request.GET: + try: + delay = int(request.GET.first(b"delay")) + except ValueError: + pass + + response.status = status + time.sleep(delay) + + location = request.GET.first(b"location") + + response.headers.set(b"Location", location)
new file mode 100644 --- /dev/null +++ b/testing/web-platform/tests/resource-timing/cross-origin-start-end-time-with-redirects.html @@ -0,0 +1,32 @@ +<!DOCTYPE HTML> +<html> +<head> +<meta charset="utf-8" /> +<title>This test validates the values in resource timing for cross-origin +redirects.</title> +<link rel="author" title="Noam Rosenthal" href="noam@webkit.org"> +<link rel="help" href="https://www.w3.org/TR/resource-timing-2/#sec-performanceresourcetiming"/> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/get-host-info.sub.js"></script> +<script src="resources/resource-loaders.js"></script> +<script src="resources/entry-invariants.js"></script> +</head> +<body> +<script> +const {REMOTE_ORIGIN} = get_host_info(); +const delay = 2 +const blank_page = `/resource-timing/resources/blank_page_green.htm`; +const destUrl = `/common/slow-redirect.py?delay=${delay}&location=${REMOTE_ORIGIN}/${blank_page}`; + +const timeBefore = performance.now() +attribute_test(load.iframe, destUrl, entry => { + assert_equals(entry.startTime, entry.fetchStart, 'startTime and fetchStart should be equal'); + assert_greater_than(entry.startTime, timeBefore, 'startTime and fetchStart should be greater than the time before fetching'); + // See https://github.com/w3c/resource-timing/issues/264 + assert_less_than(Math.round(entry.startTime - timeBefore), delay * 1000, 'startTime should not expose redirect delays'); +}, "Verify that cross-origin resources don't implicitly expose their redirect timings") + +</script> +</body> +</html>