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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting-installed.https.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 self.state = 'starting'; 1 self.state = 'starting';
2 2
3 self.addEventListener('install', function() { 3 self.addEventListener('install', function() {
4 self.state = 'installing'; 4 self.state = 'installing';
5 }); 5 });
6 6
7 self.addEventListener('activate', function() {
8 self.state = 'activating';
9 });
10
7 self.addEventListener('message', function(event) { 11 self.addEventListener('message', function(event) {
8 var port = event.data.port; 12 var port = event.data.port;
9 if (self.state !== 'installing') { 13 if (self.state !== 'installing') {
10 port.postMessage('FAIL: Worker should be waiting in installed state'); 14 port.postMessage('FAIL: Worker should be waiting in installed state');
11 return; 15 return;
12 } 16 }
13 self.skipWaiting() 17 event.waitUntil(self.skipWaiting()
14 .then(function(result) { 18 .then(function(result) {
15 if (result !== undefined) { 19 if (result !== undefined) {
16 port.postMessage('FAIL: Promise should be resolved with undefined'); 20 port.postMessage('FAIL: Promise should be resolved with undefined');
17 return; 21 return;
18 } 22 }
23
24 if (self.state === 'activating') {
25 port.postMessage(
26 'FAIL: Promise should be resolved before worker is activated');
27 return;
28 }
29
19 port.postMessage('PASS'); 30 port.postMessage('PASS');
20 }) 31 })
21 .catch(function(e) { 32 .catch(function(e) {
22 port.postMessage('FAIL: unexpected exception: ' + e); 33 port.postMessage('FAIL: unexpected exception: ' + e);
23 }); 34 }));
24 }); 35 });
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting-installed.https.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698