Chromium Code Reviews| OLD | NEW |
|---|---|
| 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()); | |
|
falken
2017/05/24 08:24:18
ditto: this is tricky and i'm not sure what the im
| |
| 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 Loading... | |
| 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 } |
| OLD | NEW |