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

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

Issue 1440873004: Extension SW - add basic push messaging tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync @ tott 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/push_messaging/sw.js
diff --git a/chrome/test/data/extensions/api_test/service_worker/push_messaging/sw.js b/chrome/test/data/extensions/api_test/service_worker/push_messaging/sw.js
new file mode 100644
index 0000000000000000000000000000000000000000..8623382cfbf3a85de44a179e313711ef964ef9ec
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/service_worker/push_messaging/sw.js
@@ -0,0 +1,24 @@
+// 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;
+var pushData;
+
+function maybeFinish() {
+ if (port && pushData) {
+ port.postMessage(pushData);
+ }
+}
+
+this.onpush = function(e) {
+ pushData = e.data.text();
+ maybeFinish();
+};
+
+this.onmessage = function(e) {
+ if (e.data == 'waitForPushMessaging') {
+ port = e.ports[0];
+ maybeFinish();
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698