| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Returns a promise that will be resolved with an activated Service | 5 // Returns a promise that will be resolved with an activated Service |
| 6 // Worker, or rejects when the Service Worker could not be started. There | 6 // Worker, or rejects when the Service Worker could not be started. There |
| 7 // will be a message port to and from the worker in |messagePort|. | 7 // will be a message port to and from the worker in |messagePort|. |
| 8 function GetActivatedServiceWorker(script, scope) { | 8 function GetActivatedServiceWorker(script, scope) { |
| 9 return navigator.serviceWorker.getRegistration(scope) | 9 return navigator.serviceWorker.getRegistration(scope) |
| 10 .then(function(registration) { | 10 .then(function(registration) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 }); | 37 }); |
| 38 | 38 |
| 39 registration.active.postMessage(channel.port2, | 39 registration.active.postMessage(channel.port2, |
| 40 [ channel.port2 ]); | 40 [ channel.port2 ]); |
| 41 | 41 |
| 42 messagePort = channel.port1; | 42 messagePort = channel.port1; |
| 43 messagePort.start(); | 43 messagePort.start(); |
| 44 }); | 44 }); |
| 45 }); | 45 }); |
| 46 } | 46 } |
| OLD | NEW |