Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/client-id-worker.js

Issue 1668473002: ServiceWorker: Wait for the completion of async tasks on ExtendableMessageEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 self.onmessage = function(e) { 1 self.onmessage = function(e) {
2 var port = e.data.port; 2 var port = e.data.port;
3 var message = []; 3 var message = [];
4 4
5 Promise.resolve() 5 var promise = Promise.resolve()
6 .then(function() { 6 .then(function() {
7 // 1st matchAll() 7 // 1st matchAll()
8 return self.clients.matchAll().then(function(clients) { 8 return self.clients.matchAll().then(function(clients) {
9 clients.forEach(function(client) { 9 clients.forEach(function(client) {
10 message.push(client.id); 10 message.push(client.id);
11 }); 11 });
12 }); 12 });
13 }) 13 })
14 .then(function() { 14 .then(function() {
15 // 2nd matchAll() 15 // 2nd matchAll()
16 return self.clients.matchAll().then(function(clients) { 16 return self.clients.matchAll().then(function(clients) {
17 clients.forEach(function(client) { 17 clients.forEach(function(client) {
18 message.push(client.id); 18 message.push(client.id);
19 }); 19 });
20 }); 20 });
21 }) 21 })
22 .then(function() { 22 .then(function() {
23 // Send an array containing ids of clients from 1st and 2nd matchAll() 23 // Send an array containing ids of clients from 1st and 2nd matchAll()
24 port.postMessage(message); 24 port.postMessage(message);
25 }); 25 });
26 e.waitUntil(promise);
26 }; 27 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698