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(); |
+ } |
+}; |