summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/client-hints/service-workers/critical-ch
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/client-hints/service-workers/critical-ch')
-rw-r--r--testing/web-platform/tests/client-hints/service-workers/critical-ch/echo-hint-in-html.py24
-rw-r--r--testing/web-platform/tests/client-hints/service-workers/critical-ch/foo.html1
-rw-r--r--testing/web-platform/tests/client-hints/service-workers/critical-ch/foo.html.headers2
-rw-r--r--testing/web-platform/tests/client-hints/service-workers/critical-ch/intercept-request.js6
-rw-r--r--testing/web-platform/tests/client-hints/service-workers/critical-ch/navigation-preload.js2
-rw-r--r--testing/web-platform/tests/client-hints/service-workers/critical-ch/new-request.js3
-rw-r--r--testing/web-platform/tests/client-hints/service-workers/critical-ch/passthrough-request.js1
7 files changed, 39 insertions, 0 deletions
diff --git a/testing/web-platform/tests/client-hints/service-workers/critical-ch/echo-hint-in-html.py b/testing/web-platform/tests/client-hints/service-workers/critical-ch/echo-hint-in-html.py
new file mode 100644
index 0000000000..87a1afed7c
--- /dev/null
+++ b/testing/web-platform/tests/client-hints/service-workers/critical-ch/echo-hint-in-html.py
@@ -0,0 +1,24 @@
+import sys
+
+def main(request, response):
+ """
+ Simple handler that sets a response header based on which client hint
+ request headers were received.
+ """
+
+ response.headers.append(b"Content-Type", b"text/html; charset=UTF-8")
+ response.headers.append(b"Access-Control-Allow-Origin", b"*")
+ response.headers.append(b"Access-Control-Allow-Headers", b"*")
+ response.headers.append(b"Access-Control-Expose-Headers", b"*")
+
+ response.headers.append(b"Cache-Control", b"no-store")
+
+ response.headers.append(b"Accept-CH", b"sec-ch-device-memory,device-memory");
+ response.headers.append(b"Critical-CH", b"sec-ch-device-memory,device-memory");
+
+ result = "FAIL"
+
+ if b"sec-ch-device-memory" in request.headers and b"device-memory" in request.headers:
+ result = "PASS"
+
+ response.content = result
diff --git a/testing/web-platform/tests/client-hints/service-workers/critical-ch/foo.html b/testing/web-platform/tests/client-hints/service-workers/critical-ch/foo.html
new file mode 100644
index 0000000000..ba578e48b1
--- /dev/null
+++ b/testing/web-platform/tests/client-hints/service-workers/critical-ch/foo.html
@@ -0,0 +1 @@
+BAR
diff --git a/testing/web-platform/tests/client-hints/service-workers/critical-ch/foo.html.headers b/testing/web-platform/tests/client-hints/service-workers/critical-ch/foo.html.headers
new file mode 100644
index 0000000000..56b489178e
--- /dev/null
+++ b/testing/web-platform/tests/client-hints/service-workers/critical-ch/foo.html.headers
@@ -0,0 +1,2 @@
+Accept-CH: sec-ch-device-memory, device-memory
+Critical-CH: sec-ch-device-memory, device-memory
diff --git a/testing/web-platform/tests/client-hints/service-workers/critical-ch/intercept-request.js b/testing/web-platform/tests/client-hints/service-workers/critical-ch/intercept-request.js
new file mode 100644
index 0000000000..4d27ceadcc
--- /dev/null
+++ b/testing/web-platform/tests/client-hints/service-workers/critical-ch/intercept-request.js
@@ -0,0 +1,6 @@
+self.addEventListener('fetch', (event) => {
+ result="FAIL";
+ if(event.request.headers.has("sec-ch-device-memory") && event.request.headers.has("device-memory"))
+ result="PASS";
+ event.respondWith(new Response(result));
+});
diff --git a/testing/web-platform/tests/client-hints/service-workers/critical-ch/navigation-preload.js b/testing/web-platform/tests/client-hints/service-workers/critical-ch/navigation-preload.js
new file mode 100644
index 0000000000..d8a38ee7de
--- /dev/null
+++ b/testing/web-platform/tests/client-hints/service-workers/critical-ch/navigation-preload.js
@@ -0,0 +1,2 @@
+self.addEventListener('activate', () => self.registration.navigationPreload.enable());
+self.addEventListener('fetch', (event) => event.respondWith(event.preloadResponse));
diff --git a/testing/web-platform/tests/client-hints/service-workers/critical-ch/new-request.js b/testing/web-platform/tests/client-hints/service-workers/critical-ch/new-request.js
new file mode 100644
index 0000000000..395c77183e
--- /dev/null
+++ b/testing/web-platform/tests/client-hints/service-workers/critical-ch/new-request.js
@@ -0,0 +1,3 @@
+self.addEventListener('fetch', (event) => {
+ event.respondWith(fetch("/client-hints/service-workers/resources/echo-hint-in-html.py"))
+});
diff --git a/testing/web-platform/tests/client-hints/service-workers/critical-ch/passthrough-request.js b/testing/web-platform/tests/client-hints/service-workers/critical-ch/passthrough-request.js
new file mode 100644
index 0000000000..5541c5eb55
--- /dev/null
+++ b/testing/web-platform/tests/client-hints/service-workers/critical-ch/passthrough-request.js
@@ -0,0 +1 @@
+self.addEventListener('fetch', (event) => fetch(event.request));