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

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

Issue 2877543003: [ServiceWorker] Allow waitUntil to be called multiple times asynchronously (Closed)
Patch Set: Address comments from falken@ Created 3 years, 7 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 function match_query(query_string) { 1 function match_query(query_string) {
2 return self.location.search.substr(1) == query_string; 2 return self.location.search.substr(1) == query_string;
3 } 3 }
4 4
5 function receive_event(event_name) { 5 function receive_event(event_name) {
6 return new Promise(function(resolve) { 6 return new Promise(function(resolve) {
7 self.addEventListener(event_name, resolve, false); 7 var handler = function(e) {
8 resolve(e);
9 // To allow waitUntil to be called inside execution of the microtask
10 // enqueued by above resolve function.
11 e.waitUntil(Promise.resolve());
12 };
13 self.addEventListener(event_name, handler, false);
8 }); 14 });
9 } 15 }
10 16
11 function navigate_test(e) { 17 function navigate_test(e) {
12 var port = e.data.port; 18 var port = e.data.port;
13 var url = e.data.url; 19 var url = e.data.url;
14 20
15 return clients.matchAll({ includeUncontrolled : true }) 21 return clients.matchAll({ includeUncontrolled : true })
16 .then(function(client_list) { 22 .then(function(client_list) {
17 for (var i = 0; i < client_list.length; i++) { 23 for (var i = 0; i < client_list.length; i++) {
(...skipping 18 matching lines...) Expand all
36 // If the query string is "?installing", then do test on installing worker. 42 // If the query string is "?installing", then do test on installing worker.
37 // This is only for in-scope-but-not-controlled test. 43 // This is only for in-scope-but-not-controlled test.
38 receive_event('install').then(function(e) { 44 receive_event('install').then(function(e) {
39 e.waitUntil(receive_event('message').then(navigate_test)); 45 e.waitUntil(receive_event('message').then(navigate_test));
40 }); 46 });
41 } else { 47 } else {
42 receive_event('message').then(function(e) { 48 receive_event('message').then(function(e) {
43 e.waitUntil(navigate_test(e)); 49 e.waitUntil(navigate_test(e));
44 }); 50 });
45 } 51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698