diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-21 20:56:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-21 20:56:19 +0000 |
commit | 0b6210cd37b68b94252cb798598b12974a20e1c1 (patch) | |
tree | e371686554a877842d95aa94f100bee552ff2a8e /test/wpt/tests/fetch/api/resources/keepalive-redirect-window.html | |
parent | Initial commit. (diff) | |
download | node-undici-upstream.tar.xz node-undici-upstream.zip |
Adding upstream version 5.28.2+dfsg1+~cs23.11.12.3.upstream/5.28.2+dfsg1+_cs23.11.12.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/wpt/tests/fetch/api/resources/keepalive-redirect-window.html')
-rw-r--r-- | test/wpt/tests/fetch/api/resources/keepalive-redirect-window.html | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/wpt/tests/fetch/api/resources/keepalive-redirect-window.html b/test/wpt/tests/fetch/api/resources/keepalive-redirect-window.html new file mode 100644 index 0000000..c186507 --- /dev/null +++ b/test/wpt/tests/fetch/api/resources/keepalive-redirect-window.html @@ -0,0 +1,42 @@ +<!doctype html> +<html> +<meta charset="utf-8"> +<script src="/common/utils.js"></script> +<script src="/common/get-host-info.sub.js"></script> +<script> +const TOKEN = token(); +const { + HTTP_NOTSAMESITE_ORIGIN, + HTTP_REMOTE_ORIGIN, + HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT +} = get_host_info(); + +const SEARCH_PARAMS = new URL(location.href).searchParams; +const WITH_HEADERS = !!SEARCH_PARAMS.has('with-headers'); +const ORIGIN1 = SEARCH_PARAMS.get('origin1') || ''; +const ORIGIN2 = SEARCH_PARAMS.get('origin2') || ''; +const URL2 = SEARCH_PARAMS.get('url2') || ''; + +const REDIRECT_DESTINATION = URL2 ? URL2 : + `${ORIGIN2}/fetch/api/resources/stash-put.py` + + `?key=${TOKEN}&value=on`; +const FROM_URL = + `${ORIGIN1}/fetch/api/resources/redirect.py?` + + `delay=500&` + + `allow_headers=foo&` + + `location=${encodeURIComponent(REDIRECT_DESTINATION)}`; + +addEventListener('load', () => { + const headers = WITH_HEADERS ? {'foo': 'bar'} : undefined; + const iframe = document.createElement('iframe'); + document.body.appendChild(iframe); + iframe.contentWindow.addEventListener('unload', () => { + iframe.contentWindow.fetch(FROM_URL, {keepalive: true, headers}); + }); + + window.opener.postMessage(TOKEN, '*'); + // Do NOT remove `iframe` here. We want to check the case where the nested + // frame is implicitly closed by window closure. +}); +</script> +</html> |