Index: chrome/test/data/extensions/api_test/service_worker/sync/sw.js |
diff --git a/chrome/test/data/extensions/api_test/service_worker/sync/sw.js b/chrome/test/data/extensions/api_test/service_worker/sync/sw.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4e641e50e642bfabb2429453c0f0d7fa9ba55655 |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/service_worker/sync/sw.js |
@@ -0,0 +1,20 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+var port = null; |
+this.onsync = function(e) { |
+ if (port) { |
+ e.waitUntil(new Promise(function(resolve) { |
Devlin
2015/11/16 18:12:41
Maybe I'm missing something - when does this resol
lazyboy
2015/11/16 19:30:16
It never did. Fixed.
|
+ // Add a small delay to respond so we can exercise and test the |
+ // offline->online transition. |
Devlin
2015/11/16 18:12:41
"small delays" usually correspond to flakiness. I
lazyboy
2015/11/16 19:30:16
We don't really need it, but this might catch some
|
+ setTimeout(function() { |
+ port.postMessage('SYNC: ' + e.registration.tag); |
+ }, 5); |
+ })); |
+ } |
+}; |
+ |
+this.onmessage = function(e) { |
+ port = e.ports[0]; |
+}; |