Update web-platform-tests to revision 824f0c1df556305042b8aa8073c32e9ef86c3efa

This commit is contained in:
WPT Sync Bot 2018-10-18 21:30:10 -04:00
parent bcafe4188f
commit d0eccdba1a
131 changed files with 3087 additions and 705 deletions

View file

@ -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})));
});

View file

@ -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);