diff options
Diffstat (limited to 'testing/web-platform/tests/appmanifest/shortcuts-member')
36 files changed, 452 insertions, 0 deletions
diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/pass.png b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/pass.png Binary files differnew file mode 100644 index 0000000000..be7433a3e2 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/pass.png diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/pass.png.sub.headers b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/pass.png.sub.headers new file mode 100644 index 0000000000..adf190aa8e --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/pass.png.sub.headers @@ -0,0 +1 @@ +Access-Control-Allow-Origin: https://{{host}}:{{ports[https][0]}} diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-cors-fail.sub.webmanifest b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-cors-fail.sub.webmanifest new file mode 100644 index 0000000000..a4975b03df --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-cors-fail.sub.webmanifest @@ -0,0 +1,22 @@ +{ + "name": "Shortcut test", + "icons": [ + { + "src": "https://{{host}}:{{ports[https][1]}}/appmanifest/icons-member/resources/fail.png", + "sizes": "256x256" + } + ], + "start_url": "../shortcuts-member-cors-fail-manual.sub.html", + "display": "fullscreen", + "scope": "../", + "shortcuts": [{ + "name": "pass", + "short_name": "", + "description": "", + "url": "../shortcut_pass.html", + "icons": [{ + "src": "https://{{host}}:{{ports[https][1]}}/appmanifest/icons-member/resources/fail.png", + "sizes": "256x256" + }] + }] +} diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-cors-fail.webmanifest.headers b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-cors-fail.webmanifest.headers new file mode 100644 index 0000000000..2bab061d43 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-cors-fail.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-cors.sub.webmanifest b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-cors.sub.webmanifest new file mode 100644 index 0000000000..94f0e0388c --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-cors.sub.webmanifest @@ -0,0 +1,22 @@ +{ + "name": "Shortcut test", + "icons": [ + { + "src": "https://{{host}}:{{ports[https][0]}}/appmanifest/shortcuts-member/resources/pass.png", + "sizes": "256x256" + } + ], + "start_url": "../shortcuts-member-cors-manual.sub.html", + "display": "fullscreen", + "scope": "../", + "shortcuts": [{ + "name": "pass", + "short_name": "", + "description": "", + "url": "../shortcut_pass.html", + "icons": [{ + "src": "https://{{host}}:{{ports[https][1]}}/appmanifest/icons-member/resources/pass.png", + "sizes": "256x256" + }] + }] +} diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-cors.webmanifest.headers b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-cors.webmanifest.headers new file mode 100644 index 0000000000..2bab061d43 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-cors.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-csp-fail.webmanifest b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-csp-fail.webmanifest new file mode 100644 index 0000000000..7efe564c9d --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-csp-fail.webmanifest @@ -0,0 +1,22 @@ +{ + "name": "Shortcut test", + "icons": [ + { + "src": "pass.png", + "sizes": "256x256" + } + ], + "start_url": "../shortcuts-member-csp-fail-manual.sub.html", + "display": "fullscreen", + "scope": "../", + "shortcuts": [{ + "name": "pass", + "short_name": "", + "description": "", + "url": "../shortcut_pass.html", + "icons": [{ + "src": "fail.png", + "sizes": "256x256" + }] + }] +} diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-csp-fail.webmanifest.headers b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-csp-fail.webmanifest.headers new file mode 100644 index 0000000000..2bab061d43 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-csp-fail.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-csp.sub.webmanifest b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-csp.sub.webmanifest new file mode 100644 index 0000000000..55b0afb3ed --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-csp.sub.webmanifest @@ -0,0 +1,22 @@ +{ + "name": "Shortcut test", + "icons": [ + { + "src": "https://{{host}}:{{ports[https][0]}}/appmanifest/shortcuts-member/resources/pass.png", + "sizes": "256x256" + } + ], + "start_url": "../shortcuts-member-csp-manual.sub.html", + "display": "fullscreen", + "scope": "../", + "shortcuts": [{ + "name": "pass", + "short_name": "", + "description": "", + "url": "../shortcut_pass.html", + "icons": [{ + "src": "https://{{host}}:{{ports[https][1]}}/appmanifest/icons-member/resources/pass.png", + "sizes": "256x256" + }] + }] +} diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-csp.webmanifest.headers b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-csp.webmanifest.headers new file mode 100644 index 0000000000..2bab061d43 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-csp.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-manual.js b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-manual.js new file mode 100644 index 0000000000..5fdfde1bd6 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-manual.js @@ -0,0 +1,4 @@ +if ('serviceWorker' in navigator) { + navigator.serviceWorker.register( + 'shortcuts-member-service-worker.js'); +} diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-empty-name.webmanifest b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-empty-name.webmanifest new file mode 100644 index 0000000000..6e17899c65 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-empty-name.webmanifest @@ -0,0 +1,27 @@ +{ + "name": "Shortcut test", + "icons": [ + { + "src": "pass.png", + "sizes": "256x256" + } + ], + "start_url": "../shortcuts-member-skip-for-empty-name-manual.html", + "display": "fullscreen", + "scope": "../", + "shortcuts": [{ + "name": "", + "short_name": "", + "description": "", + "url": "../shortcut_fail.html", + "icons": [] + }, { + "name": "pass", + "short_name": "", + "description": "", + "url": "../shortcut_pass.html", + "icons": [{ + "src": "pass.png" + }] + }] +} diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-empty-name.webmanifest.headers b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-empty-name.webmanifest.headers new file mode 100644 index 0000000000..2bab061d43 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-empty-name.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-invalid-url.webmanifest b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-invalid-url.webmanifest new file mode 100644 index 0000000000..573bbdc8c0 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-invalid-url.webmanifest @@ -0,0 +1,27 @@ +{ + "name": "Shortcut test", + "icons": [ + { + "src": "pass.png", + "sizes": "256x256" + } + ], + "start_url": "../shortcuts-member-skip-for-invalid-url-manual.html", + "display": "fullscreen", + "scope": "../", + "shortcuts": [{ + "name": "fail", + "short_name": "", + "description": "", + "url": "http://foo:660000", + "icons": [] + }, { + "name": "pass", + "short_name": "", + "description": "", + "url": "../shortcut_pass.html", + "icons": [{ + "src": "pass.png" + }] + }] +} diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-invalid-url.webmanifest.headers b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-invalid-url.webmanifest.headers new file mode 100644 index 0000000000..2bab061d43 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-invalid-url.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-out-of-scope-url.webmanifest b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-out-of-scope-url.webmanifest new file mode 100644 index 0000000000..79ac5130fb --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-out-of-scope-url.webmanifest @@ -0,0 +1,27 @@ +{ + "name": "Shortcut test", + "icons": [ + { + "src": "pass.png", + "sizes": "256x256" + } + ], + "start_url": "../shortcuts-member-skip-for-out-of-scope-url-manual.html", + "display": "fullscreen", + "scope": "../", + "shortcuts": [{ + "name": "fail", + "short_name": "", + "description": "", + "url": "https://example.com", + "icons": [] + }, { + "name": "pass", + "short_name": "", + "description": "", + "url": "../shortcut_pass.html", + "icons": [{ + "src": "pass.png" + }] + }] +} diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-out-of-scope-url.webmanifest.headers b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-out-of-scope-url.webmanifest.headers new file mode 100644 index 0000000000..2bab061d43 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-out-of-scope-url.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-undefined-name.webmanifest b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-undefined-name.webmanifest new file mode 100644 index 0000000000..14521109c2 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-undefined-name.webmanifest @@ -0,0 +1,26 @@ +{ + "name": "Shortcut test", + "icons": [ + { + "src": "pass.png", + "sizes": "256x256" + } + ], + "start_url": "../shortcuts-member-skip-for-undefined-name-manual.html", + "display": "fullscreen", + "scope": "../", + "shortcuts": [{ + "short_name": "fail", + "description": "", + "url": "../shortcut_fail.html", + "icons": [] + }, { + "name": "pass", + "short_name": "", + "description": "", + "url": "../shortcut_pass.html", + "icons": [{ + "src": "pass.png" + }] + }] +} diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-undefined-name.webmanifest.headers b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-undefined-name.webmanifest.headers new file mode 100644 index 0000000000..2bab061d43 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-undefined-name.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-undefined-url.webmanifest b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-undefined-url.webmanifest new file mode 100644 index 0000000000..e272c4cae5 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-undefined-url.webmanifest @@ -0,0 +1,26 @@ +{ + "name": "Shortcut test", + "icons": [ + { + "src": "pass.png", + "sizes": "256x256" + } + ], + "start_url": "../shortcuts-member-skip-for-undefined-url-manual.html", + "display": "fullscreen", + "scope": "../", + "shortcuts": [{ + "name": "fail", + "short_name": "", + "description": "", + "icons": [] + }, { + "name": "pass", + "short_name": "", + "description": "", + "url": "../shortcut_pass.html", + "icons": [{ + "src": "pass.png" + }] + }] +} diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-undefined-url.webmanifest.headers b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-undefined-url.webmanifest.headers new file mode 100644 index 0000000000..2bab061d43 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member-skip-for-undefined-url.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member.webmanifest b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member.webmanifest new file mode 100644 index 0000000000..68c3e99d70 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member.webmanifest @@ -0,0 +1,22 @@ +{ + "name": "Shortcut test", + "icons": [ + { + "src": "pass.png", + "sizes": "256x256" + } + ], + "start_url": "../shortcuts-member-manual.html", + "display": "fullscreen", + "scope": "../", + "shortcuts": [{ + "name": "pass", + "short_name": "", + "description": "", + "url": "../shortcut_pass.html", + "icons": [{ + "src": "pass.png", + "sizes": "256x256" + }] + }] +} diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member.webmanifest.headers b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member.webmanifest.headers new file mode 100644 index 0000000000..2bab061d43 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/resources/shortcuts-member.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/shortcut_fail.html b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcut_fail.html new file mode 100644 index 0000000000..d3259744d3 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcut_fail.html @@ -0,0 +1,4 @@ +<html> +<meta charset="utf-8"> +<body style="background: red"> +<h1>Fail</h1> diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/shortcut_pass.html b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcut_pass.html new file mode 100644 index 0000000000..f15bfe1141 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcut_pass.html @@ -0,0 +1,4 @@ +<html> +<meta charset="utf-8"> +<body style="background: green"> +<h1>Pass</h1> diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-cors-fail-manual.sub.html b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-cors-fail-manual.sub.html new file mode 100644 index 0000000000..5b1bd84dca --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-cors-fail-manual.sub.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<title>Test that shortcuts member is supported (icon violates CORS)</title> +<link rel="help" href="https://w3c.github.io/manifest/#shortcuts-member" /> +<link rel="manifest" href="resources/shortcuts-member-cors-fail.sub.webmanifest" /> +<script src="resources/shortcuts-member-manual.js"></script> +<h1>Testing support for shortcuts member (icon violates CORS)</h1> +<script> + // Force the port of the origin to be ports[https][0] (likely :8443) + // we treat the port ports[https][1] (likely :8444) to be another origin that we fail against + if (window.location.origin !== "https://{{host}}:{{ports[https][0]}}") { + window.location = new URL(window.location.pathname, "https://{{host}}:{{ports[https][0]}}") + } +</script> +<p> + To pass, the application <strong>must not</strong> show a shortcut with + a white cross on red background. +</p> diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-cors-manual.sub.html b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-cors-manual.sub.html new file mode 100644 index 0000000000..73b47c4336 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-cors-manual.sub.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<title>Test that shortcuts member is supported (icon via CORS)</title> +<link rel="help" href="https://w3c.github.io/manifest/#shortcuts-member" /> +<link rel="manifest" href="resources/shortcuts-member-cors.sub.webmanifest" /> +<script src="resources/shortcuts-member-manual.js"></script> +<h1>Testing support for shortcuts member (icon via CORS)</h1> +<script> + // Force the port of the origin to be ports[https][0] (likely :8443) + // we treat the port ports[https][1] (likely :8444) to be another origin that we fail against + if (window.location.origin !== "https://{{host}}:{{ports[https][0]}}") { + window.location = new URL(window.location.pathname, "https://{{host}}:{{ports[https][0]}}") + } +</script> +<p> + To pass, the application must show a shortcut named "pass" with a check + mark icon. Clicking it must open this document again. +</p> diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-csp-fail-manual.sub.html b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-csp-fail-manual.sub.html new file mode 100644 index 0000000000..228c9782c0 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-csp-fail-manual.sub.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<meta http-equiv="Content-Security-Policy" content="img-src {{host}}:{{ports[https][1]}}"> +<title>Test that shortcuts member is supported (icon CSP violation)</title> +<link rel="help" href="https://w3c.github.io/manifest/#shortcuts-member" /> +<link rel="manifest" href="resources/shortcuts-member-csp-fail.sub.webmanifest" /> +<script src="resources/shortcuts-member-manual.js"></script> +<h1>Testing support for shortcuts member (icon CSP violation)</h1> +<script> + // Force the port of the origin to be ports[https][0] (likely :8443) + // we treat the port ports[https][1] (likely :8444) to be another origin that we fail against + if (window.location.origin !== "https://{{host}}:{{ports[https][0]}}") { + window.location = new URL(window.location.pathname, "https://{{host}}:{{ports[https][0]}}") + } +</script> +<p> + To pass, the application <strong>must not</strong> show a shortcut with + a white cross on red background. +</p> diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-csp-manual.sub.html b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-csp-manual.sub.html new file mode 100644 index 0000000000..68c5f0107d --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-csp-manual.sub.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<meta http-equiv="Content-Security-Policy" content="img-src {{host}}:{{ports[https][0]}}"> +<title>Test that shortcuts member is supported (icon CSP check)</title> +<link rel="help" href="https://w3c.github.io/manifest/#shortcuts-member" /> +<link rel="manifest" href="resources/shortcuts-member-csp.sub.webmanifest" /> +<script src="resources/shortcuts-member-manual.js"></script> +<h1>Testing support for shortcuts member (icon CSP check)</h1> +<script> + // Force the port of the origin to be ports[https][0] (likely :8443) + // we treat the port ports[https][1] (likely :8444) to be another origin that we fail against + if (window.location.origin !== "https://{{host}}:{{ports[https][0]}}") { + window.location = new URL(window.location.pathname, "https://{{host}}:{{ports[https][0]}}") + } +</script> +<p> + To pass, the application must show a shortcut named "pass" with a check + mark icon. Clicking it must open this document again. +</p> diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-manual.html b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-manual.html new file mode 100644 index 0000000000..f2a7d6742d --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-manual.html @@ -0,0 +1,10 @@ +<!DOCTYPE html> +<title>Test that shortcuts member is supported</title> +<link rel="help" href="https://w3c.github.io/manifest/#shortcuts-member" /> +<link rel="manifest" href="resources/shortcuts-member.webmanifest" /> +<script src="resources/shortcuts-member-manual.js"></script> +<h1>Testing support for shortcuts member</h1> +<p> + To pass, the application must show a shortcut named "pass" with a check + mark icon. Clicking it must open this document again. +</p> diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-service-worker.js b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-service-worker.js new file mode 100644 index 0000000000..bd9995202e --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-service-worker.js @@ -0,0 +1,61 @@ +// 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 = [ + "shortcuts-member-cors-fail-manual.sub.html", + "shortcuts-member-cors-manual.sub.html", + "shortcuts-member-csp-fail-manual.sub.html", + "shortcuts-member-csp-manual.sub.html", + "shortcuts-member-manual.html", + "shortcuts-member-skip-for-empty-name-manual.html", + "shortcuts-member-skip-for-invalid-url-manual.html", + "shortcuts-member-skip-for-out-of-scope-url-manual.html", + "shortcuts-member-skip-for-undefined-name-manual.html", + "shortcuts-member-skip-for-undefined-url-manual.html", + "shortcuts-member-service-worker.js", + "resources/shortcuts-member-manual.js", + "resources/pass.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/shortcuts-member/shortcuts-member-skip-for-empty-name-manual.html b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-skip-for-empty-name-manual.html new file mode 100644 index 0000000000..48f4af7ba5 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-skip-for-empty-name-manual.html @@ -0,0 +1,9 @@ +<!DOCTYPE html> +<title>Test that shortcut items with an empty name are skipped</title> +<link rel="help" href="https://w3c.github.io/manifest/#shortcuts-member" /> +<link rel="manifest" href="resources/shortcuts-member-skip-for-empty-name.webmanifest" /> +<script src="resources/shortcuts-member-manual.js"></script> +<h1>Testing if shortcut items with an empty name are skipped</h1> +<p> + To pass, the application must provide a single shortcut named "pass". +</p> diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-skip-for-invalid-url-manual.html b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-skip-for-invalid-url-manual.html new file mode 100644 index 0000000000..6967f8dca2 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-skip-for-invalid-url-manual.html @@ -0,0 +1,9 @@ +<!DOCTYPE html> +<title>Test that shortcut items with an invalid URL are skipped</title> +<link rel="help" href="https://w3c.github.io/manifest/#shortcuts-member" /> +<link rel="manifest" href="resources/shortcuts-member-skip-for-invalid-url.webmanifest" /> +<script src="resources/shortcuts-member-manual.js"></script> +<h1>Testing if shortcut items with an invalid URL are skipped</h1> +<p> + To pass, the application must provide a single shortcut named "pass". +</p> diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-skip-for-out-of-scope-url-manual.html b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-skip-for-out-of-scope-url-manual.html new file mode 100644 index 0000000000..64f3d0fe15 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-skip-for-out-of-scope-url-manual.html @@ -0,0 +1,9 @@ +<!DOCTYPE html> +<title>Test that shortcut items with an out-of-scope URL are skipped</title> +<link rel="help" href="https://w3c.github.io/manifest/#shortcuts-member" /> +<link rel="manifest" href="resources/shortcuts-member-skip-for-out-of-scope-url.webmanifest" /> +<script src="resources/shortcuts-member-manual.js"></script> +<h1>Testing if shortcut items with an out-of-scope URL are skipped</h1> +<p> + To pass, the application must provide a single shortcut named "pass". +</p> diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-skip-for-undefined-name-manual.html b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-skip-for-undefined-name-manual.html new file mode 100644 index 0000000000..c0a7768eee --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-skip-for-undefined-name-manual.html @@ -0,0 +1,9 @@ +<!DOCTYPE html> +<title>Test that shortcut items with an undefined name are skipped</title> +<link rel="help" href="https://w3c.github.io/manifest/#shortcuts-member" /> +<link rel="manifest" href="resources/shortcuts-member-skip-for-undefined-name.webmanifest" /> +<script src="resources/shortcuts-member-manual.js"></script> +<h1>Testing if shortcut items with an undefined name are skipped</h1> +<p> + To pass, the application must provide a single shortcut named "pass". +</p> diff --git a/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-skip-for-undefined-url-manual.html b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-skip-for-undefined-url-manual.html new file mode 100644 index 0000000000..ffeb6af9a0 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/shortcuts-member/shortcuts-member-skip-for-undefined-url-manual.html @@ -0,0 +1,9 @@ +<!DOCTYPE html> +<title>Test that shortcut items with an undefined URL are skipped</title> +<link rel="help" href="https://w3c.github.io/manifest/#shortcuts-member" /> +<link rel="manifest" href="resources/shortcuts-member-skip-for-undefined-url.webmanifest" /> +<script src="resources/shortcuts-member-manual.js"></script> +<h1>Testing if shortcut items with an undefined URL are skipped</h1> +<p> + To pass, the application must provide a single shortcut named "pass". +</p> |