summaryrefslogtreecommitdiffstats
path: root/test/wpt/tests/fetch/origin/resources
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 20:56:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 20:56:19 +0000
commit0b6210cd37b68b94252cb798598b12974a20e1c1 (patch)
treee371686554a877842d95aa94f100bee552ff2a8e /test/wpt/tests/fetch/origin/resources
parentInitial commit. (diff)
downloadnode-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/origin/resources')
-rw-r--r--test/wpt/tests/fetch/origin/resources/redirect-and-stash.py38
-rw-r--r--test/wpt/tests/fetch/origin/resources/referrer-policy.py7
2 files changed, 45 insertions, 0 deletions
diff --git a/test/wpt/tests/fetch/origin/resources/redirect-and-stash.py b/test/wpt/tests/fetch/origin/resources/redirect-and-stash.py
new file mode 100644
index 0000000..36c584c
--- /dev/null
+++ b/test/wpt/tests/fetch/origin/resources/redirect-and-stash.py
@@ -0,0 +1,38 @@
+import json
+
+from wptserve.utils import isomorphic_decode
+
+def main(request, response):
+ key = request.GET.first(b"stash")
+ origin = request.headers.get(b"origin")
+ if origin is None:
+ origin = b"no Origin header"
+
+ origin_list = request.server.stash.take(key)
+
+ if b"dump" in request.GET:
+ response.headers.set(b"Content-Type", b"application/json")
+ response.content = json.dumps(origin_list)
+ return
+
+ if origin_list is None:
+ origin_list = [isomorphic_decode(origin)]
+ else:
+ origin_list.append(isomorphic_decode(origin))
+
+ request.server.stash.put(key, origin_list)
+
+ if b"location" in request.GET:
+ location = request.GET.first(b"location")
+ if b"dummyJS" in request.GET:
+ location += b"&dummyJS"
+ response.status = 308
+ response.headers.set(b"Location", location)
+ return
+
+ response.headers.set(b"Content-Type", b"text/html")
+ response.headers.set(b"Access-Control-Allow-Origin", b"*")
+ if b"dummyJS" in request.GET:
+ response.content = b"console.log('dummy JS')"
+ else:
+ response.content = b"<meta charset=utf-8>\n<body><script>parent.postMessage('loaded','*')</script></body>"
diff --git a/test/wpt/tests/fetch/origin/resources/referrer-policy.py b/test/wpt/tests/fetch/origin/resources/referrer-policy.py
new file mode 100644
index 0000000..15716e0
--- /dev/null
+++ b/test/wpt/tests/fetch/origin/resources/referrer-policy.py
@@ -0,0 +1,7 @@
+def main(request, response):
+ if b"referrerPolicy" in request.GET:
+ response.headers.set(b"Referrer-Policy",
+ request.GET.first(b"referrerPolicy"))
+ response.status = 200
+ response.headers.set(b"Content-Type", b"text/html")
+ response.content = b"<meta charset=utf-8>\n<body><script>parent.postMessage('action','*')</script></body>"