diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/appmanifest/unrecognized-member | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/appmanifest/unrecognized-member')
6 files changed, 82 insertions, 0 deletions
diff --git a/testing/web-platform/tests/appmanifest/unrecognized-member/resources/icon.png b/testing/web-platform/tests/appmanifest/unrecognized-member/resources/icon.png Binary files differnew file mode 100644 index 0000000000..deea71918a --- /dev/null +++ b/testing/web-platform/tests/appmanifest/unrecognized-member/resources/icon.png diff --git a/testing/web-platform/tests/appmanifest/unrecognized-member/resources/unrecognized-member-manual.js b/testing/web-platform/tests/appmanifest/unrecognized-member/resources/unrecognized-member-manual.js new file mode 100644 index 0000000000..9be8fb602e --- /dev/null +++ b/testing/web-platform/tests/appmanifest/unrecognized-member/resources/unrecognized-member-manual.js @@ -0,0 +1,4 @@ +if ('serviceWorker' in navigator) { + navigator.serviceWorker.register( + 'unrecognized-member-service-worker.js'); +} diff --git a/testing/web-platform/tests/appmanifest/unrecognized-member/resources/unrecognized-member.webmanifest b/testing/web-platform/tests/appmanifest/unrecognized-member/resources/unrecognized-member.webmanifest new file mode 100644 index 0000000000..1eb7b6285a --- /dev/null +++ b/testing/web-platform/tests/appmanifest/unrecognized-member/resources/unrecognized-member.webmanifest @@ -0,0 +1,15 @@ +{ + "this member name is not expected to be recognized": "ok", + "this object is not expected to be recognized": { + "this sub-field is not expected to be recognized": [] + }, + "short_name": "pass", + "icons": [ + { + "src": "icon.png", + "sizes": "192x192" + } + ], + "start_url": "../unrecognized-member-manual.html", + "display": "fullscreen" +} diff --git a/testing/web-platform/tests/appmanifest/unrecognized-member/resources/unrecognized-member.webmanifest.headers b/testing/web-platform/tests/appmanifest/unrecognized-member/resources/unrecognized-member.webmanifest.headers new file mode 100644 index 0000000000..23f36ea27c --- /dev/null +++ b/testing/web-platform/tests/appmanifest/unrecognized-member/resources/unrecognized-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/unrecognized-member/unrecognized-member-manual.html b/testing/web-platform/tests/appmanifest/unrecognized-member/unrecognized-member-manual.html new file mode 100644 index 0000000000..d22b5bacd7 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/unrecognized-member/unrecognized-member-manual.html @@ -0,0 +1,10 @@ +<!DOCTYPE html> +<title>Test that an unrecognized member is ignored</title> +<link rel="help" href="https://www.w3.org/TR/appmanifest/#processing" /> +<link rel="manifest" href="resources/unrecognized-member.webmanifest" /> +<script src="resources/unrecognized-member-manual.js"></script> +<h1>Testing support for ignoring an unrecognized member</h1> +<p> + To pass, the application name must be "pass". Parsing must not fail due to the + presence of the unrecognized members in the manifest. +</p> diff --git a/testing/web-platform/tests/appmanifest/unrecognized-member/unrecognized-member-service-worker.js b/testing/web-platform/tests/appmanifest/unrecognized-member/unrecognized-member-service-worker.js new file mode 100644 index 0000000000..5364b09ffd --- /dev/null +++ b/testing/web-platform/tests/appmanifest/unrecognized-member/unrecognized-member-service-worker.js @@ -0,0 +1,52 @@ +// 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 = [ + "unrecognized-member-manual.html", + "unrecognized-member-service-worker.js", + "resources/unrecognized-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)); +}); |