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

Unified Diff: chrome/test/data/extensions/api_test/service_worker/sync/sw.js

Issue 1445603003: Extension SW - add test for ServiceWorkerRegistration.sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix after r360068 Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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..2c1b05a18ccbc4b84316ecde1e73c5d400eec259
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/service_worker/sync/sw.js
@@ -0,0 +1,23 @@
+// 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) {
+ // Add a small delay to respond so we can exercise and test the
+ // offline->online transition.
+ // NOTE: the following 5ms delay is not a requirement for this test. It is
Devlin 2015/11/17 19:21:17 I still don't really like the 5ms delay here. If
lazyboy 2015/11/17 21:41:28 Changed to 0ms. Done.
+ // here to just demonstrate that the test passes with a bit of asynchrony.
+ setTimeout(function() {
+ port.postMessage('SYNC: ' + e.tag);
+ resolve();
+ }, 5);
+ }));
+ }
+};
+
+this.onmessage = function(e) {
+ port = e.ports[0];
+};

Powered by Google App Engine
This is Rietveld 408576698