Skip to content

Commit

Permalink
DPWA: add tentative WPT manual tests for manifest id
Browse files Browse the repository at this point in the history
Adds tentative manual tests for manifest id, specifically for manifest
update behavior.
As suggested in #30409
manifest update is both not specified in spec and not supported in
other user agents yet, so adding these tests as tentative.

Bug: 1182363
Change-Id: I065afc19982f528b509fb81491738b899b72cc1d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3177731
Commit-Queue: Phillis Tang <phillis@chromium.org>
Reviewed-by: Daniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/main@{#925858}
  • Loading branch information
philloooo authored and chromium-wpt-export-bot committed Sep 28, 2021
1 parent 82d5eb8 commit 12c0dec
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 0 deletions.
Binary file added appmanifest/id-member/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Manifest Id Web Platform Test</title>
<style>
body {
margin: 2em;
}

ol {
line-height: 200%;
}
</style>
<!-- This points to manifest v2 with a different start_url, but the
id is url-equivalent to manifest v1. -->
<link rel="manifest" href="id-member-manifest-update-v2.webmanifest" />
<script src="id-member-manifest-update.js"></script>

</head>
<body>
<h1>
Manifest Id Test
</h1>
<h2 style="color: red">
start_url v1
</h2>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Manifest Id Web Platform Test</title>
<style>
body {
margin: 2em;
}

ol {
line-height: 200%;
}
</style>
<link rel="manifest" href="id-member-manifest-update-v1.webmanifest" />
<script src="id-member-manifest-update.js"></script>
</head>
<body>
<h1>
Manifest Id Test
</h1>
<h2 style="color: green">
start_url v2
</h2>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Manifest Id Web Platform Test</title>
<style>
body {
margin: 2em;
}

ol {
line-height: 200%;
}
</style>
<link rel="manifest" href="id-member-manifest-update-v1.webmanifest" />
<script src="id-member-manifest-update.js"></script>
</head>
<body>
<h1>
Manifest Id Test
</h1>
</body>
</html>
13 changes: 13 additions & 0 deletions appmanifest/id-member/id-member-manifest-update-v1.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "id member test",
"id": "/testId",
"start_url": "id-member-manifest-update-manual-v1.tentative.html",
"icons": [
{
"src": "icon.png",
"sizes": "256x256",
"type": "image/png"
}
],
"display": "standalone"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content-Type: application/manifest+json; charset=utf-8
13 changes: 13 additions & 0 deletions appmanifest/id-member/id-member-manifest-update-v2.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "id member test",
"id": "testId",
"start_url": "id-member-manifest-update-manual-v2.tentative.html",
"icons": [
{
"src": "icon.png",
"sizes": "256x256",
"type": "image/png"
}
],
"display": "standalone"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content-Type: application/manifest+json; charset=utf-8
34 changes: 34 additions & 0 deletions appmanifest/id-member/id-member-manifest-update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
window.onload = () => {
const instruction = document.createElement("div");
instruction.innerHTML = `
<h2>
Instructions
</h2>
<ol>
<li>Install <a href="id-member-manifest-update-manual.tentative.html ">id-member-manifest-update-manual.tentative.html </a> as a PWA</li>
<li>
Launch the app from OS. The page should be launched to start_url v1.
</li>
<li>
Close the app window.
</li>
<li>
Trigger a manifest update event.
<p>
This step is specific to each browser implementation.
On Chrome, trigger the update by restarting the browser through chrome://restart.
</p>
</li>
<li>
Launch the app from OS again, start_url should be updated to v2.
</li>
</ol>
`;

document.body.appendChild(instruction);
};
async function main() {
await navigator.serviceWorker.register("id-member-service-worker.js");
await navigator.serviceWorker.ready;
}
main();
8 changes: 8 additions & 0 deletions appmanifest/id-member/id-member-service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Some user agents only offer app installation if there is a SW and it handles
// offline requests.

self.addEventListener("fetch", e => {
e.respondWith(fetch(e.request).catch(_ => {
return new Response('Offline test.');
}));
});

0 comments on commit 12c0dec

Please sign in to comment.