From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../test/fetch/imagecache-maxage/image-20px.png | Bin 0 -> 87 bytes .../test/fetch/imagecache-maxage/image-40px.png | Bin 0 -> 123 bytes .../test/fetch/imagecache-maxage/index.html | 29 +++++++++++++ .../test/fetch/imagecache-maxage/maxage_test.js | 45 +++++++++++++++++++++ .../test/fetch/imagecache-maxage/register.html | 14 +++++++ .../test/fetch/imagecache-maxage/unregister.html | 12 ++++++ 6 files changed, 100 insertions(+) create mode 100644 dom/serviceworkers/test/fetch/imagecache-maxage/image-20px.png create mode 100644 dom/serviceworkers/test/fetch/imagecache-maxage/image-40px.png create mode 100644 dom/serviceworkers/test/fetch/imagecache-maxage/index.html create mode 100644 dom/serviceworkers/test/fetch/imagecache-maxage/maxage_test.js create mode 100644 dom/serviceworkers/test/fetch/imagecache-maxage/register.html create mode 100644 dom/serviceworkers/test/fetch/imagecache-maxage/unregister.html (limited to 'dom/serviceworkers/test/fetch/imagecache-maxage') diff --git a/dom/serviceworkers/test/fetch/imagecache-maxage/image-20px.png b/dom/serviceworkers/test/fetch/imagecache-maxage/image-20px.png new file mode 100644 index 0000000000..ae6a8a6b88 Binary files /dev/null and b/dom/serviceworkers/test/fetch/imagecache-maxage/image-20px.png differ diff --git a/dom/serviceworkers/test/fetch/imagecache-maxage/image-40px.png b/dom/serviceworkers/test/fetch/imagecache-maxage/image-40px.png new file mode 100644 index 0000000000..fe391dc8a2 Binary files /dev/null and b/dom/serviceworkers/test/fetch/imagecache-maxage/image-40px.png differ diff --git a/dom/serviceworkers/test/fetch/imagecache-maxage/index.html b/dom/serviceworkers/test/fetch/imagecache-maxage/index.html new file mode 100644 index 0000000000..0d4c52eedd --- /dev/null +++ b/dom/serviceworkers/test/fetch/imagecache-maxage/index.html @@ -0,0 +1,29 @@ + + + + diff --git a/dom/serviceworkers/test/fetch/imagecache-maxage/maxage_test.js b/dom/serviceworkers/test/fetch/imagecache-maxage/maxage_test.js new file mode 100644 index 0000000000..c664e07c28 --- /dev/null +++ b/dom/serviceworkers/test/fetch/imagecache-maxage/maxage_test.js @@ -0,0 +1,45 @@ +function synthesizeImage(suffix) { + // Serve image-20px for the first page, and image-40px for the second page. + return clients + .matchAll() + .then(clients => { + var url = "image-20px.png"; + clients.forEach(client => { + if (client.url.indexOf("?new") > 0) { + url = "image-40px.png"; + } + client.postMessage({ suffix, url }); + }); + return fetch(url); + }) + .then(response => { + return response.arrayBuffer(); + }) + .then(ab => { + var headers; + if (suffix == "") { + headers = { + "Content-Type": "image/png", + Date: "Tue, 1 Jan 1990 01:02:03 GMT", + "Cache-Control": "max-age=1", + }; + } else { + headers = { + "Content-Type": "image/png", + "Cache-Control": "no-cache", + }; + } + return new Response(ab, { + status: 200, + headers, + }); + }); +} + +self.addEventListener("fetch", function (event) { + if (event.request.url.includes("image.png")) { + event.respondWith(synthesizeImage("")); + } else if (event.request.url.includes("image2.png")) { + event.respondWith(synthesizeImage("2")); + } +}); diff --git a/dom/serviceworkers/test/fetch/imagecache-maxage/register.html b/dom/serviceworkers/test/fetch/imagecache-maxage/register.html new file mode 100644 index 0000000000..af4dde2e29 --- /dev/null +++ b/dom/serviceworkers/test/fetch/imagecache-maxage/register.html @@ -0,0 +1,14 @@ + + diff --git a/dom/serviceworkers/test/fetch/imagecache-maxage/unregister.html b/dom/serviceworkers/test/fetch/imagecache-maxage/unregister.html new file mode 100644 index 0000000000..1f13508fa7 --- /dev/null +++ b/dom/serviceworkers/test/fetch/imagecache-maxage/unregister.html @@ -0,0 +1,12 @@ + + -- cgit v1.2.3