mirror of
https://github.com/servo/servo.git
synced 2025-08-15 18:35:33 +01:00
Update web-platform-tests to revision 824f0c1df556305042b8aa8073c32e9ef86c3efa
This commit is contained in:
parent
bcafe4188f
commit
d0eccdba1a
131 changed files with 3087 additions and 705 deletions
|
@ -0,0 +1,23 @@
|
|||
importScripts('sw-helpers.js');
|
||||
|
||||
async function getFetchResult(record) {
|
||||
try {
|
||||
await record.responseReady;
|
||||
} catch (e) {
|
||||
return {
|
||||
response: false,
|
||||
name: e.name,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
response: true,
|
||||
};
|
||||
}
|
||||
self.addEventListener('backgroundfetchabort', event => {
|
||||
event.waitUntil(
|
||||
event.registration.matchAll()
|
||||
.then(records =>
|
||||
Promise.all(records.map(record => getFetchResult(record))))
|
||||
.then(results => sendMessageToDocument({results})));
|
||||
});
|
|
@ -2,9 +2,8 @@
|
|||
importScripts('sw-helpers.js');
|
||||
|
||||
async function getFetchResult(record) {
|
||||
response = await record.responseReady;
|
||||
if (!response)
|
||||
return Promise.resolve(null);
|
||||
const response = await record.responseReady.catch(() => null);
|
||||
if (!response) return null;
|
||||
|
||||
return {
|
||||
url: response.url,
|
||||
|
@ -13,7 +12,7 @@ async function getFetchResult(record) {
|
|||
};
|
||||
}
|
||||
|
||||
function handleBackgroundFetchUpdateEvent(event) {
|
||||
function handleBackgroundFetchEvent(event) {
|
||||
event.waitUntil(
|
||||
event.registration.matchAll()
|
||||
.then(records =>
|
||||
|
@ -25,6 +24,6 @@ function handleBackgroundFetchUpdateEvent(event) {
|
|||
}));
|
||||
}
|
||||
|
||||
self.addEventListener('backgroundfetchsuccess', handleBackgroundFetchUpdateEvent);
|
||||
self.addEventListener('backgroundfetchfail', handleBackgroundFetchUpdateEvent);
|
||||
self.addEventListener('backgroundfetchabort', handleBackgroundFetchUpdateEvent);
|
||||
self.addEventListener('backgroundfetchsuccess', handleBackgroundFetchEvent);
|
||||
self.addEventListener('backgroundfetchfail', handleBackgroundFetchEvent);
|
||||
self.addEventListener('backgroundfetchabort', handleBackgroundFetchEvent);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue