mirror of
https://github.com/servo/servo.git
synced 2025-08-15 02:15:33 +01:00
Update web-platform-tests to revision 2b758296541cf4f2209b8c2352cf6c7890c97be3
This commit is contained in:
parent
2304f02123
commit
835d593cd0
118 changed files with 3269 additions and 703 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue