OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 var port = null; |
| 6 this.onsync = function(e) { |
| 7 if (port) { |
| 8 e.waitUntil(new Promise(function(resolve) { |
| 9 // Add a small delay to respond so we can exercise and test the |
| 10 // offline->online transition. |
| 11 // NOTE: the following setTimeout() is not a requirement for this test. It |
| 12 // is here to just demonstrate that the test passes with a bit of |
| 13 // asynchrony. |
| 14 setTimeout(function() { |
| 15 port.postMessage('SYNC: ' + e.tag); |
| 16 resolve(); |
| 17 }, 0); |
| 18 })); |
| 19 } |
| 20 }; |
| 21 |
| 22 this.onmessage = function(e) { |
| 23 port = e.ports[0]; |
| 24 }; |
OLD | NEW |