forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WPT: Update unrecognized-member tests to make them all promotable
This CL updates all wpt/appmanifest/unrecognized-member tests. Now they can be installed. Bug: 1247435 Change-Id: Ic7e541d32df0ebe00167380093ff37f9530b0e03 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3226003 Auto-Submit: Fangzhen Song <songfangzhen@bytedance.com> Reviewed-by: Phillis Tang <phillis@chromium.org> Commit-Queue: Fangzhen Song <songfangzhen@bytedance.com> Cr-Commit-Position: refs/heads/main@{#932812}
- Loading branch information
1 parent
d1dff8e
commit 928c65a
Showing
7 changed files
with
73 additions
and
8 deletions.
There are no files selected for viewing
Binary file added
BIN
+9.61 KB
...blink/web_tests/external/wpt/appmanifest/unrecognized-member/resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions
4
...ests/external/wpt/appmanifest/unrecognized-member/resources/unrecognized-member-manual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
if ('serviceWorker' in navigator) { | ||
navigator.serviceWorker.register( | ||
'unrecognized-member-service-worker.js'); | ||
} |
15 changes: 15 additions & 0 deletions
15
...ts/external/wpt/appmanifest/unrecognized-member/resources/unrecognized-member.webmanifest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
File renamed without changes.
3 changes: 2 additions & 1 deletion
3
...nk/web_tests/external/wpt/appmanifest/unrecognized-member/unrecognized-member-manual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
..._tests/external/wpt/appmanifest/unrecognized-member/unrecognized-member-service-worker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
}); |
7 changes: 0 additions & 7 deletions
7
...nk/web_tests/external/wpt/appmanifest/unrecognized-member/unrecognized-member.webmanifest
This file was deleted.
Oops, something went wrong.