OLD | NEW |
---|---|
(Empty) | |
1 var port; | |
2 var resolve; | |
3 | |
4 oninstall = function(e) { | |
5 e.waitUntil(new Promise(function(r) { resolve = r; })); | |
6 }; | |
7 | |
8 onactivate = function(e) { | |
9 port.postMessage('ping'); | |
10 e.waitUntil(new Promise(function(r) { resolve = r; })); | |
11 }; | |
12 | |
13 onmessage = function(e) { | |
14 var message = e.data; | |
15 if (Object(message) === message) { | |
16 if ('port' in message) { | |
17 if (message.from === 'registering doc') | |
18 port = message.port; | |
19 var response = 'Ack for: ' + message.from; | |
20 try { | |
21 message.port.postMessage(response); | |
22 } catch(e) {} | |
23 try { | |
24 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.
| |
25 } catch (e) {} | |
26 } | |
27 } | |
28 | |
29 if (resolve) { | |
30 resolve(); | |
31 resolve = null; | |
32 } | |
33 }; | |
OLD | NEW |