Update web-platform-tests to revision 2b758296541cf4f2209b8c2352cf6c7890c97be3

This commit is contained in:
WPT Sync Bot 2018-10-22 21:28:54 -04:00
parent 2304f02123
commit 835d593cd0
118 changed files with 3269 additions and 703 deletions

View file

@ -13,10 +13,33 @@ async function getFetchResult(record) {
}
function handleBackgroundFetchEvent(event) {
let matchFunction = null;
switch (event.registration.id) {
case 'matchexistingrequest':
matchFunction = event.registration.match.bind(
event.registration, '/background-fetch/resources/feature-name.txt');
break;
case 'matchmissingrequest':
matchFunction = event.registration.match.bind(
event.registration, '/background-fetch/resources/missing.txt');
break;
default:
matchFunction = event.registration.matchAll.bind(event.registration);
break;
}
event.waitUntil(
event.registration.matchAll()
matchFunction()
// Format `match(All)?` function results.
.then(records => {
if (!records) return []; // Nothing was matched.
if (!records.map) return [records]; // One entry was returned.
return records; // Already in a list.
})
// Extract responses.
.then(records =>
Promise.all(records.map(record => getFetchResult(record))))
// Clone registration and send message.
.then(results => {
const registrationCopy = cloneRegistration(event.registration);
sendMessageToDocument(