diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/element-timing/multiple-redirects-TAO.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/element-timing/multiple-redirects-TAO.html')
-rw-r--r-- | testing/web-platform/tests/element-timing/multiple-redirects-TAO.html | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/testing/web-platform/tests/element-timing/multiple-redirects-TAO.html b/testing/web-platform/tests/element-timing/multiple-redirects-TAO.html new file mode 100644 index 0000000000..3a45b552be --- /dev/null +++ b/testing/web-platform/tests/element-timing/multiple-redirects-TAO.html @@ -0,0 +1,62 @@ +<!DOCTYPE HTML> +<html> +<head> +<meta charset="utf-8" /> +<title>This test validates some Timing-Allow-Origin header usage in multiple redirects.</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/element-timing-helpers.js"></script> +<script src="/common/get-host-info.sub.js"></script> +</head> +<body> +<script> +async_test(t => { + assert_implements(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented"); + let destUrl = get_host_info().HTTP_REMOTE_ORIGIN + + '/element-timing/resources/multiple-redirects.py?'; + destUrl += 'redirect_count=2'; + // The final resource has '*' in TAO header, so will not affect the result. + destUrl += '&final_resource=/element-timing/resources/circle-tao.svg'; + destUrl += '&origin1=' + get_host_info().UNAUTHENTICATED_ORIGIN; + destUrl += '&origin2=' + get_host_info().HTTP_REMOTE_ORIGIN; + const taoCombinations = [ + {tao1: location.origin, tao2: location.origin, passes: false}, + {tao1: location.origin, tao2: get_host_info().HTTP_REMOTE_ORIGIN, passes: false}, + {tao1: location.origin, tao2: 'null', passes: true}, + {tao1: location.origin, tao2: '*', passes: true}, + {tao1: location.origin, tao2: location.origin, passes: false}, + {tao1: 'null', tao2: '*', passes: false}, + {tao1: '*', tao2: 'null', passes: true}, + ]; + function getURL(item) { + return destUrl + '&tao1=' + item.tao1 + '&tao2=' + item.tao2; + } + taoCombinations.forEach((item, index) => { + const image = document.createElement('img'); + image.src = getURL(item); + image.setAttribute('elementtiming', item.passes.toString()); + image.setAttribute('id', index); + document.body.appendChild(image); + }); + let observed = new Array(taoCombinations.length).fill(false); + let observedCount = 0; + const beforeRender = performance.now(); + new PerformanceObserver(t.step_func(entries => { + entries.getEntries().forEach(e => { + const index = parseInt(e.id); + assert_false(observed[index]); + const item = taoCombinations[index]; + const url = getURL(item); + checkElement(e, url, item.passes.toString(), e.id, item.passes ? beforeRender : 0, + document.getElementById(e.id)); + observed[index] = true; + observedCount++; + if (observedCount === taoCombinations.length) + t.done(); + }); + })).observe({entryTypes: ['element']}); +}, 'Cross-origin images with passing/failing TAO should/shouldn\'t have its renderTime set.'); +</script> +</body> +</html> + |