Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[appmanifest] Add CORS/CSP tests for icons and shortcuts #27620

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions appmanifest/icons-member/icons-member-cors-fail-manual.sub.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>Test that icons member is supported (CORS violation)</title>
<link rel="help" href="https://w3c.github.io/manifest#icons-member" />
<link rel="manifest" href="icons-member-cors-fail.sub.webmanifest" />
<h1>Testing support for icons member (CORS 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 icon <strong>must not</strong> show a white cross on a red background.
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"icons": [{
"src": "https://{{host}}:{{ports[https][1]}}/appmanifest/icons-member/fail.png",
"sizes": "256x256",
"type": "image/png"
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content-Type: application/manifest+json; charset=utf-8
15 changes: 15 additions & 0 deletions appmanifest/icons-member/icons-member-cors-manual.sub.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>Test that icons member is supported (via CORS)</title>
<link rel="help" href="https://w3c.github.io/manifest#icons-member" />
<link rel="manifest" href="icons-member-cors.sub.webmanifest" />
<h1>Testing support for icons member (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 icon must show a white check mark on a green background.
</p>
7 changes: 7 additions & 0 deletions appmanifest/icons-member/icons-member-cors.sub.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"icons": [{
"src": "https://{{host}}:{{ports[https][1]}}/appmanifest/icons-member/pass.png",
"sizes": "256x256",
"type": "image/png"
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content-Type: application/manifest+json; charset=utf-8
16 changes: 16 additions & 0 deletions appmanifest/icons-member/icons-member-csp-fail-manual.sub.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<meta http-equiv="Content-Security-Policy" content="img-src {{host}}:{{ports[https][1]}}">
<title>Test that icons member is supported (CSP violation)</title>
<link rel="help" href="https://w3c.github.io/manifest#icons-member" />
<link rel="manifest" href="icons-member-csp-fail.webmanifest" />
<h1>Testing support for icons member (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 icon <strong>must not</strong> show a white cross on a red background.
</p>
7 changes: 7 additions & 0 deletions appmanifest/icons-member/icons-member-csp-fail.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"icons": [{
"src": "fail.png",
"sizes": "256x256",
"type": "image/png"
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content-Type: application/manifest+json; charset=utf-8
16 changes: 16 additions & 0 deletions appmanifest/icons-member/icons-member-csp-manual.sub.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<meta http-equiv="Content-Security-Policy" content="img-src {{host}}:{{ports[https][1]}}">
<title>Test that icons member is supported (CSP check)</title>
<link rel="help" href="https://w3c.github.io/manifest#icons-member" />
<link rel="manifest" href="icons-member-csp.sub.webmanifest" />
<h1>Testing support for icons member (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 icon must show a white check mark on a green background.
</p>
7 changes: 7 additions & 0 deletions appmanifest/icons-member/icons-member-csp.sub.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"icons": [{
"src": "https://{{host}}:{{ports[https][1]}}/appmanifest/icons-member/pass.png",
"sizes": "256x256",
"type": "image/png"
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content-Type: application/manifest+json; charset=utf-8
1 change: 1 addition & 0 deletions appmanifest/icons-member/pass.png.sub.headers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Access-Control-Allow-Origin: https://{{host}}:{{ports[https][0]}}
1 change: 1 addition & 0 deletions appmanifest/shortcuts-member/pass.png.sub.headers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Access-Control-Allow-Origin: https://{{host}}:{{ports[https][0]}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!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="shortcuts-member-cors-fail.sub.webmanifest" />
<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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Shortcut test",
"scope": "/",
"shortcuts": [{
"name": "pass",
"short_name": "",
"description": "",
"url": "shortcut_pass.html",
"icons": [{
"src": "https://{{host}}:{{ports[https][1]}}/appmanifest/icons-member/fail.png",
"sizes": "256x256"
}]
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content-Type: application/manifest+json; charset=utf-8
16 changes: 16 additions & 0 deletions appmanifest/shortcuts-member/shortcuts-member-cors-manual.sub.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!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="shortcuts-member-cors.sub.webmanifest" />
<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>
14 changes: 14 additions & 0 deletions appmanifest/shortcuts-member/shortcuts-member-cors.sub.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Shortcut test",
"scope": "/",
"shortcuts": [{
"name": "pass",
"short_name": "",
"description": "",
"url": "shortcut_pass.html",
"icons": [{
"src": "https://{{host}}:{{ports[https][1]}}/appmanifest/icons-member/pass.png",
"sizes": "256x256"
}]
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content-Type: application/manifest+json; charset=utf-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!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="shortcuts-member-cors-fail.sub.webmanifest" />
<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>
14 changes: 14 additions & 0 deletions appmanifest/shortcuts-member/shortcuts-member-csp-fail.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Shortcut test",
"scope": "/",
"shortcuts": [{
"name": "pass",
"short_name": "",
"description": "",
"url": "shortcut_pass.html",
"icons": [{
"src": "fail.png",
"sizes": "256x256"
}]
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content-Type: application/manifest+json; charset=utf-8
17 changes: 17 additions & 0 deletions appmanifest/shortcuts-member/shortcuts-member-csp-manual.sub.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<meta http-equiv="Content-Security-Policy" content="img-src {{host}}:{{ports[https][1]}}">
<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="shortcuts-member-cors.sub.webmanifest" />
<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>
14 changes: 14 additions & 0 deletions appmanifest/shortcuts-member/shortcuts-member-csp.sub.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Shortcut test",
"scope": "/",
"shortcuts": [{
"name": "pass",
"short_name": "",
"description": "",
"url": "shortcut_pass.html",
"icons": [{
"src": "https://{{host}}:{{ports[https][1]}}/appmanifest/icons-member/pass.png",
"sizes": "256x256"
}]
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content-Type: application/manifest+json; charset=utf-8