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/appmanifest/start_url-member/fail.html | 4 ++ .../tests/appmanifest/start_url-member/pass.html | 5 ++ .../start_url-member/resources/icon.png | Bin 0 -> 8364 bytes .../start_url-member-fail.sub.webmanifest | 11 +++++ .../start_url-member-fail.sub.webmanifest.headers | 1 + .../resources/start_url-member-manual.js | 4 ++ .../resources/start_url-member.webmanifest | 11 +++++ .../resources/start_url-member.webmanifest.headers | 1 + .../start_url-member-fail-manual.sub.html | 16 ++++++ .../start_url-member-pass-manual.html | 9 ++++ .../start_url-member-service-worker.js | 55 +++++++++++++++++++++ 11 files changed, 117 insertions(+) create mode 100644 testing/web-platform/tests/appmanifest/start_url-member/fail.html create mode 100644 testing/web-platform/tests/appmanifest/start_url-member/pass.html create mode 100644 testing/web-platform/tests/appmanifest/start_url-member/resources/icon.png create mode 100644 testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member-fail.sub.webmanifest create mode 100644 testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member-fail.sub.webmanifest.headers create mode 100644 testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member-manual.js create mode 100644 testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member.webmanifest create mode 100644 testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member.webmanifest.headers create mode 100644 testing/web-platform/tests/appmanifest/start_url-member/start_url-member-fail-manual.sub.html create mode 100644 testing/web-platform/tests/appmanifest/start_url-member/start_url-member-pass-manual.html create mode 100644 testing/web-platform/tests/appmanifest/start_url-member/start_url-member-service-worker.js (limited to 'testing/web-platform/tests/appmanifest/start_url-member') diff --git a/testing/web-platform/tests/appmanifest/start_url-member/fail.html b/testing/web-platform/tests/appmanifest/start_url-member/fail.html new file mode 100644 index 0000000000..4c6c599b5a --- /dev/null +++ b/testing/web-platform/tests/appmanifest/start_url-member/fail.html @@ -0,0 +1,4 @@ + + + +

FAIL

diff --git a/testing/web-platform/tests/appmanifest/start_url-member/pass.html b/testing/web-platform/tests/appmanifest/start_url-member/pass.html new file mode 100644 index 0000000000..caecc70f6d --- /dev/null +++ b/testing/web-platform/tests/appmanifest/start_url-member/pass.html @@ -0,0 +1,5 @@ + +PASS + + +

PASS

diff --git a/testing/web-platform/tests/appmanifest/start_url-member/resources/icon.png b/testing/web-platform/tests/appmanifest/start_url-member/resources/icon.png new file mode 100644 index 0000000000..b8845ac098 Binary files /dev/null and b/testing/web-platform/tests/appmanifest/start_url-member/resources/icon.png differ diff --git a/testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member-fail.sub.webmanifest b/testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member-fail.sub.webmanifest new file mode 100644 index 0000000000..9cfb0b815b --- /dev/null +++ b/testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member-fail.sub.webmanifest @@ -0,0 +1,11 @@ +{ + "name": "start_url member WPT", + "icons": [ + { + "src": "icon.png", + "sizes": "192x192" + } + ], + "start_url": "https://{{host}}:{{ports[https][1]}}/appmanifest/start_url-member/fail.html", + "display": "fullscreen" +} diff --git a/testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member-fail.sub.webmanifest.headers b/testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member-fail.sub.webmanifest.headers new file mode 100644 index 0000000000..23f36ea27c --- /dev/null +++ b/testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member-fail.sub.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 \ No newline at end of file diff --git a/testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member-manual.js b/testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member-manual.js new file mode 100644 index 0000000000..302ce45aeb --- /dev/null +++ b/testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member-manual.js @@ -0,0 +1,4 @@ +if ('serviceWorker' in navigator) { + navigator.serviceWorker.register( + 'start_url-member-service-worker.js'); +} diff --git a/testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member.webmanifest b/testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member.webmanifest new file mode 100644 index 0000000000..2afae97566 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member.webmanifest @@ -0,0 +1,11 @@ +{ + "name": "start_url member WPT", + "icons": [ + { + "src": "icon.png", + "sizes": "192x192" + } + ], + "start_url": "../pass.html", + "display": "fullscreen" +} diff --git a/testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member.webmanifest.headers b/testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member.webmanifest.headers new file mode 100644 index 0000000000..23f36ea27c --- /dev/null +++ b/testing/web-platform/tests/appmanifest/start_url-member/resources/start_url-member.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 \ No newline at end of file diff --git a/testing/web-platform/tests/appmanifest/start_url-member/start_url-member-fail-manual.sub.html b/testing/web-platform/tests/appmanifest/start_url-member/start_url-member-fail-manual.sub.html new file mode 100644 index 0000000000..079f048b55 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/start_url-member/start_url-member-fail-manual.sub.html @@ -0,0 +1,16 @@ + +Test that start_url member is supported + + + +

Cross-origin start URLs are invalid

+ +

+ To pass, the start URL must not be fail.html because it's not same origin. +

diff --git a/testing/web-platform/tests/appmanifest/start_url-member/start_url-member-pass-manual.html b/testing/web-platform/tests/appmanifest/start_url-member/start_url-member-pass-manual.html new file mode 100644 index 0000000000..34be2d6263 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/start_url-member/start_url-member-pass-manual.html @@ -0,0 +1,9 @@ + +Test that start_url member is supported + + + +

Testing support for start_url member

+

+ To pass, the start URL must be pass.html after installing. +

diff --git a/testing/web-platform/tests/appmanifest/start_url-member/start_url-member-service-worker.js b/testing/web-platform/tests/appmanifest/start_url-member/start_url-member-service-worker.js new file mode 100644 index 0000000000..6ffe893e13 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/start_url-member/start_url-member-service-worker.js @@ -0,0 +1,55 @@ +// Some user agents only offer app installation if there is a SW and it handles +// offline requests. + +const cacheVersion = "1.2"; +const CACHE_NAME = `cache-v${cacheVersion}`; + +// The resources cached by this service worker. +const resources = [ + "fail.html", + "pass.html", + "start_url-member-fail-manual.sub.html", + "start_url-member-pass-manual.html", + "start_url-member-service-worker.js", + "resources/start_url-member-manual.js", + "resources/icon.png" +]; + +// Load all resources for this service worker. +const precache = async () => { + const cache = await caches.open(CACHE_NAME); + await cache.addAll(resources); +}; + +// Get a resource from the cache. +const fromCache = async request => { + const cache = await caches.open(CACHE_NAME); + return await cache.match(request.url); +}; + +// Attempt to get resources from the network first, fallback to the cache if we're +// offline. +const networkFallbackToCache = async request => { + try { + const response = await fetch(request); + if (response.ok) return response; + } catch (err) {} + return await fromCache(request); +}; + +// When we have a new service worker, update the caches and swap immediately. +self.addEventListener("install", e => { + e.waitUntil(precache().then(() => self.skipWaiting())); +}); + +// Claim existing clients. +self.addEventListener("activate", e => { + e.waitUntil(self.clients.claim()); +}); + +// When a resource need to be fetched, check whether it is +// contained in the cache and return the cached version, otherwise +// get it from the network. +self.addEventListener("fetch", e => { + e.respondWith(networkFallbackToCache(e.request)); +}); -- cgit v1.2.3