From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- .../tests/css/fetching/fetch-resources.sub.html | 102 +++++++++++++++++++++ .../tests/css/fetching/support/echo-css.py | 7 ++ .../tests/css/fetching/support/echo-headers.py | 24 +++++ .../tests/css/fetching/support/echo-helper.js | 19 ++++ 4 files changed, 152 insertions(+) create mode 100644 testing/web-platform/tests/css/fetching/fetch-resources.sub.html create mode 100644 testing/web-platform/tests/css/fetching/support/echo-css.py create mode 100644 testing/web-platform/tests/css/fetching/support/echo-headers.py create mode 100644 testing/web-platform/tests/css/fetching/support/echo-helper.js (limited to 'testing/web-platform/tests/css/fetching') diff --git a/testing/web-platform/tests/css/fetching/fetch-resources.sub.html b/testing/web-platform/tests/css/fetching/fetch-resources.sub.html new file mode 100644 index 0000000000..03c3e346f1 --- /dev/null +++ b/testing/web-platform/tests/css/fetching/fetch-resources.sub.html @@ -0,0 +1,102 @@ + + + +Test various interactions between fetch, service-workers and resource timing + + + + + + + + + + + + diff --git a/testing/web-platform/tests/css/fetching/support/echo-css.py b/testing/web-platform/tests/css/fetching/support/echo-css.py new file mode 100644 index 0000000000..bbfd3f07c0 --- /dev/null +++ b/testing/web-platform/tests/css/fetching/support/echo-css.py @@ -0,0 +1,7 @@ +import sys +import json + +def main(request, response): + content = request.GET.first(b"content", None) + response.headers.set(b"Content-Type", "text/css"); + return content diff --git a/testing/web-platform/tests/css/fetching/support/echo-headers.py b/testing/web-platform/tests/css/fetching/support/echo-headers.py new file mode 100644 index 0000000000..9feb6f91a4 --- /dev/null +++ b/testing/web-platform/tests/css/fetching/support/echo-headers.py @@ -0,0 +1,24 @@ +import sys +import json + +def main(request, response): + token = request.GET.first(b"token", None) + location = request.GET.first(b"location", None) + store = request.server.stash.take(token) + headers = {} + if (location == b"echo"): + return store + + if (store == None): + store = {} + else: + store = json.loads(store) + + for header in request.headers: + headers[header.decode('utf-8')] = request.headers.get(header).decode('utf-8') + + store[location.decode('utf-8')] = headers + + request.server.stash.put(token, json.dumps(store)) + response.status = 302 + response.headers.set(b"Location", location) diff --git a/testing/web-platform/tests/css/fetching/support/echo-helper.js b/testing/web-platform/tests/css/fetching/support/echo-helper.js new file mode 100644 index 0000000000..15bec65033 --- /dev/null +++ b/testing/web-platform/tests/css/fetching/support/echo-helper.js @@ -0,0 +1,19 @@ +function get_resource_echo_url(uid, url) { + return `/css/fetching/support/echo-headers.py?token=${uid}&location=${url}` +} + +function wait_for_resource(url) { + return new Promise(resolve => { + const po = new PerformanceObserver(list => { + const entries = list.getEntries(); + if (entries.find(e => e.name.includes(url))) + resolve(); + }) + po.observe({type: "resource", buffered: true}); + }); +} + +async function get_headers(uid) { + return await (await fetch(`/css/fetching/support/echo-headers.py?token=${uid}&location=echo`)).json() +} + -- cgit v1.2.3