diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/appmanifest/display-member | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/appmanifest/display-member')
15 files changed, 251 insertions, 0 deletions
diff --git a/testing/web-platform/tests/appmanifest/display-member/display-member-media-feature-browser-manual.html b/testing/web-platform/tests/appmanifest/display-member/display-member-media-feature-browser-manual.html new file mode 100644 index 0000000000..690b4ba521 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/display-member/display-member-media-feature-browser-manual.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<title>Test "browser" value of display member + media feature</title> +<link rel="help" href="https://w3c.github.io/manifest#display-member" /> +<link rel="help" href="https://w3c.github.io/manifest/#dom-displaymodetype-browser" /> +<link rel="help" href="https://w3c.github.io/manifest/#the-display-mode-media-feature" /> +<link rel="manifest" href="resources/display-member-media-feature-browser.webmanifest" /> +<script src="resources/display-member-media-feature-manual.js"></script> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<h1>Testing support for "browser" value of display member + media feature</h1> +<style> + .fail { + background-color: red; + } + + @media all and (display-mode: browser) { + body { + background-color: green; + } + } +</style> +<script> +const browser = matchMedia("(display-mode: browser)"); + +browser.onchange = () => { + if (browser.matches) { + document.body.classList.remove("fail"); + } +} + +if (!browser.matches) { + document.body.classList.add("fail"); +} +</script> +<p> + To pass, the background color must be green after installing. +</p> diff --git a/testing/web-platform/tests/appmanifest/display-member/display-member-media-feature-fullscreen-manual.html b/testing/web-platform/tests/appmanifest/display-member/display-member-media-feature-fullscreen-manual.html new file mode 100644 index 0000000000..a6db66679c --- /dev/null +++ b/testing/web-platform/tests/appmanifest/display-member/display-member-media-feature-fullscreen-manual.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<title>Test "fullscreen" value of display member + media feature</title> +<link rel="help" href="https://w3c.github.io/manifest#display-member" /> +<link rel="help" href="https://w3c.github.io/manifest/#dom-displaymodetype-fullscreen" /> +<link rel="help" href="https://w3c.github.io/manifest/#the-display-mode-media-feature" /> +<link rel="manifest" href="resources/display-member-media-feature-fullscreen.webmanifest" /> +<script src="resources/display-member-media-feature-manual.js"></script> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<h1>Testing support for "fullscreen" value of display member + media feature</h1> +<style> + .fail { + background-color: red; + } + + @media all and (display-mode: fullscreen) { + body { + background-color: green; + } + } +</style> +<script> +const fullscreen = matchMedia("(display-mode: fullscreen)"); + +fullscreen.onchange = () => { + if (fullscreen.matches) { + document.body.classList.remove("fail"); + } +} + +if (!fullscreen.matches) { + document.body.classList.add("fail"); +} +</script> +<p> + To pass, the background color must be green after installing. +</p> diff --git a/testing/web-platform/tests/appmanifest/display-member/display-member-media-feature-minimal-ui-manual.html b/testing/web-platform/tests/appmanifest/display-member/display-member-media-feature-minimal-ui-manual.html new file mode 100644 index 0000000000..b645d6cd7f --- /dev/null +++ b/testing/web-platform/tests/appmanifest/display-member/display-member-media-feature-minimal-ui-manual.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<title>Test "minimal-ui" value of display member + media feature</title> +<link rel="help" href="https://w3c.github.io/manifest#display-member" /> +<link rel="help" href="https://w3c.github.io/manifest/#dom-displaymodetype-minimal-ui" /> +<link rel="help" href="https://w3c.github.io/manifest/#the-display-mode-media-feature" /> +<link rel="manifest" href="resources/display-member-media-feature-minimal-ui.webmanifest" /> +<script src="resources/display-member-media-feature-manual.js"></script> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<h1>Testing support for "minimal-ui" value of display member + media feature</h1> +<style> + .fail { + background-color: red; + } + + @media all and (display-mode: minimal-ui) { + body { + background-color: green; + } + } +</style> +<script> +const minimalUi = matchMedia("(display-mode: minimal-ui)"); + +minimalUi.onchange = () => { + if (minimalUi.matches) { + document.body.classList.remove("fail"); + } +} + +if (!minimalUi.matches) { + document.body.classList.add("fail"); +} +</script> +<p> + To pass, the background color must be green after installing. +</p> diff --git a/testing/web-platform/tests/appmanifest/display-member/display-member-media-feature-service-worker.js b/testing/web-platform/tests/appmanifest/display-member/display-member-media-feature-service-worker.js new file mode 100644 index 0000000000..5720e3cbc3 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/display-member/display-member-media-feature-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 = [ + "display-member-media-feature-browser-manual.html", + "display-member-media-feature-fullscreen-manual.html", + "display-member-media-feature-minimal-ui-manual.html", + "display-member-media-feature-standalone-manual.html", + "display-member-media-feature-service-worker.js", + "resources/display-member-media-feature-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)); +}); diff --git a/testing/web-platform/tests/appmanifest/display-member/display-member-media-feature-standalone-manual.html b/testing/web-platform/tests/appmanifest/display-member/display-member-media-feature-standalone-manual.html new file mode 100644 index 0000000000..c820091f0f --- /dev/null +++ b/testing/web-platform/tests/appmanifest/display-member/display-member-media-feature-standalone-manual.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<title>Test "standalone" value of display member + media feature</title> +<link rel="help" href="https://w3c.github.io/manifest#display-member" /> +<link rel="help" href="https://w3c.github.io/manifest/#the-display-mode-media-feature" /> +<link rel="help" href="https://w3c.github.io/manifest/#dom-displaymodetype-standalone" /> +<link rel="manifest" href="resources/display-member-media-feature-standalone.webmanifest" /> +<script src="resources/display-member-media-feature-manual.js"></script> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<h1>Testing support for "standalone" value of display member + media feature</h1> +<style> + .fail { + background-color: red; + } + + @media all and (display-mode: standalone) { + body { + background-color: green; + } + } +</style> +<script> +const standalone = matchMedia("(display-mode: standalone)"); + +standalone.onchange = () => { + if (standalone.matches) { + document.body.classList.remove("fail"); + } +} + +if (!standalone.matches) { + document.body.classList.add("fail"); +} +</script> +<p> + To pass, the background color must be green after installing. +</p> diff --git a/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-browser.webmanifest b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-browser.webmanifest new file mode 100644 index 0000000000..9e1f6a3350 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-browser.webmanifest @@ -0,0 +1,11 @@ +{ + "name": "Display member media feature WPT", + "icons": [ + { + "src": "icon.png", + "sizes": "192x192" + } + ], + "start_url": "../display-member-media-feature-browser-manual.html", + "display": "browser" +} diff --git a/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-browser.webmanifest.headers b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-browser.webmanifest.headers new file mode 100644 index 0000000000..2bab061d43 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-browser.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 diff --git a/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-fullscreen.webmanifest b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-fullscreen.webmanifest new file mode 100644 index 0000000000..3954538e50 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-fullscreen.webmanifest @@ -0,0 +1,11 @@ +{ + "name": "Display member media feature WPT", + "icons": [ + { + "src": "icon.png", + "sizes": "192x192" + } + ], + "start_url": "../display-member-media-feature-fullscreen-manual.html", + "display": "fullscreen" +}
\ No newline at end of file diff --git a/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-fullscreen.webmanifest.headers b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-fullscreen.webmanifest.headers new file mode 100644 index 0000000000..2bab061d43 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-fullscreen.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 diff --git a/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-manual.js b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-manual.js new file mode 100644 index 0000000000..60723d5afe --- /dev/null +++ b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-manual.js @@ -0,0 +1,4 @@ +if ('serviceWorker' in navigator) { + navigator.serviceWorker.register( + 'display-member-media-feature-service-worker.js'); +} diff --git a/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-minimal-ui.webmanifest b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-minimal-ui.webmanifest new file mode 100644 index 0000000000..9463941aa4 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-minimal-ui.webmanifest @@ -0,0 +1,11 @@ +{ + "name": "Display member media feature WPT", + "icons": [ + { + "src": "icon.png", + "sizes": "192x192" + } + ], + "start_url": "../display-member-media-feature-minimal-ui-manual.html", + "display": "minimal-ui" +}
\ No newline at end of file diff --git a/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-minimal-ui.webmanifest.headers b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-minimal-ui.webmanifest.headers new file mode 100644 index 0000000000..2bab061d43 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-minimal-ui.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 diff --git a/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-standalone.webmanifest b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-standalone.webmanifest new file mode 100644 index 0000000000..a8269e977c --- /dev/null +++ b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-standalone.webmanifest @@ -0,0 +1,11 @@ +{ + "name": "Display member media feature WPT", + "icons": [ + { + "src": "icon.png", + "sizes": "192x192" + } + ], + "start_url": "../display-member-media-feature-standalone-manual.html", + "display": "standalone" +}
\ No newline at end of file diff --git a/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-standalone.webmanifest.headers b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-standalone.webmanifest.headers new file mode 100644 index 0000000000..2bab061d43 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/display-member/resources/display-member-media-feature-standalone.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 diff --git a/testing/web-platform/tests/appmanifest/display-member/resources/icon.png b/testing/web-platform/tests/appmanifest/display-member/resources/icon.png Binary files differnew file mode 100644 index 0000000000..267cba8d1e --- /dev/null +++ b/testing/web-platform/tests/appmanifest/display-member/resources/icon.png |