summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/speculation-rules/prerender/resources/exec.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/speculation-rules/prerender/resources/exec.py
parentInitial commit. (diff)
downloadfirefox-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/speculation-rules/prerender/resources/exec.py')
-rw-r--r--testing/web-platform/tests/speculation-rules/prerender/resources/exec.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/testing/web-platform/tests/speculation-rules/prerender/resources/exec.py b/testing/web-platform/tests/speculation-rules/prerender/resources/exec.py
new file mode 100644
index 0000000000..de0636117d
--- /dev/null
+++ b/testing/web-platform/tests/speculation-rules/prerender/resources/exec.py
@@ -0,0 +1,26 @@
+from wptserve.utils import isomorphic_decode
+import os
+
+def main(request, response):
+ purpose = request.headers.get(b"purpose")
+ if (purpose == b'prefetch' and b"code" in request.GET):
+ code = int(request.GET.first(b"code"))
+ else:
+ code = 200
+
+ if b"uuid" in request.GET:
+ path = '/speculation-rules/prerender/resources/exec.py'
+ uuid = request.GET.first(b"uuid")
+ with request.server.stash.lock:
+ count = request.server.stash.take(uuid, path) or 0
+ if b"get-fetch-count" in request.GET:
+ response.status = 200
+ response.content = '%d' % count
+ request.server.stash.put(uuid, count, path)
+ return
+ count += 1
+ request.server.stash.put(uuid, count, path)
+
+ with open(os.path.join(os.path.dirname(isomorphic_decode(__file__)), "exec.html"), u"r") as fn:
+ response.content = fn.read()
+ response.status = code