Index: LayoutTests/http/tests/serviceworker/resources/end-to-end-worker.js |
diff --git a/LayoutTests/http/tests/serviceworker/resources/end-to-end-worker.js b/LayoutTests/http/tests/serviceworker/resources/end-to-end-worker.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4ac2e2e2893084945d36672632014f6dee05ef61 |
--- /dev/null |
+++ b/LayoutTests/http/tests/serviceworker/resources/end-to-end-worker.js |
@@ -0,0 +1,33 @@ |
+var port; |
+var resolve; |
+ |
+oninstall = function(e) { |
+ e.waitUntil(new Promise(function(r) { resolve = r; })); |
+}; |
+ |
+onactivate = function(e) { |
+ port.postMessage('ping'); |
+ e.waitUntil(new Promise(function(r) { resolve = r; })); |
+}; |
+ |
+onmessage = function(e) { |
+ var message = e.data; |
+ if (Object(message) === message) { |
+ if ('port' in message) { |
+ if (message.from === 'registering doc') |
+ port = message.port; |
+ var response = 'Ack for: ' + message.from; |
+ try { |
+ message.port.postMessage(response); |
+ } catch(e) {} |
+ try { |
+ message.source.postMessage(response, '*'); |
kinuko
2014/04/16 03:28:38
Let's remove this from our first end-to-end test f
jsbell
2014/04/16 17:04:19
Done.
|
+ } catch (e) {} |
+ } |
+ } |
+ |
+ if (resolve) { |
+ resolve(); |
+ resolve = null; |
+ } |
+}; |