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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/skip-waiting-installed-worker.js

Issue 2900183002: Upstream service wrkr "skipWaiting" tests to WPT (Closed)
Patch Set: Improve assertion message Created 3 years, 6 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
OLDNEW
1 // TODO(nhiroki): stop using global states because service workers can be killed 1 // TODO(nhiroki): stop using global states because service workers can be killed
2 // at any point (http://crbug.com/558244). 2 // at any point (http://crbug.com/558244).
3 self.state = 'starting'; 3 self.state = 'starting';
4 4
5 self.addEventListener('install', function() { 5 self.addEventListener('install', function() {
6 self.state = 'installing'; 6 self.state = 'installing';
7 }); 7 });
8 8
9 self.addEventListener('activate', function() { 9 self.addEventListener('activate', function() {
10 self.state = 'activating'; 10 self.state = 'activating';
11 }); 11 });
12 12
13 self.addEventListener('message', function(event) { 13 self.addEventListener('message', function(event) {
14 var port = event.data.port; 14 var port = event.data.port;
15 if (self.state !== 'installing') { 15 if (self.state !== 'installing') {
16 port.postMessage('FAIL: Worker should be waiting in installed state'); 16 port.postMessage('FAIL: Worker should be waiting in installed state');
17 return; 17 return;
18 } 18 }
19 event.waitUntil(self.skipWaiting() 19 event.waitUntil(self.skipWaiting()
20 .then(function(result) { 20 .then(function(result) {
21 if (result !== undefined) { 21 if (result !== undefined) {
22 port.postMessage('FAIL: Promise should be resolved with undefined'); 22 port.postMessage('FAIL: Promise should be resolved with undefined');
23 return; 23 return;
24 } 24 }
25 if (self.state !== 'activating') { 25 if (self.state !== 'activating') {
26 port.postMessage( 26 port.postMessage('This assertion passes in current Chromium ' +
27 'FAIL: Promise should be resolved after worker activated'); 27 '(i.e., self.state is "activating"), ' +
28 'but it should fail. See https://crbug.com/725616');
28 return; 29 return;
29 } 30 }
30 port.postMessage('PASS'); 31 port.postMessage('PASS');
31 }) 32 })
32 .catch(function(e) { 33 .catch(function(e) {
33 port.postMessage('FAIL: unexpected exception: ' + e); 34 port.postMessage('FAIL: unexpected exception: ' + e);
34 })); 35 }));
35 }); 36 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698