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

Side by Side Diff: LayoutTests/http/tests/serviceworker/resources/end-to-end-worker.js

Issue 238993003: ServiceWorker: "minimal" end-to-end sample as a W3C test (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Clarify registration promise chain Created 6 years, 8 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698