blob: 6f7008bddcdfa044dbedd2e8f2aceb89ec980a71 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
var saw_activate_event = false
self.addEventListener('activate', function() {
saw_activate_event = true;
});
self.addEventListener('message', function(event) {
var port = event.data.port;
event.waitUntil(self.skipWaiting()
.then(function(result) {
if (result !== undefined) {
port.postMessage('FAIL: Promise should be resolved with undefined');
return;
}
if (!saw_activate_event) {
port.postMessage(
'FAIL: Promise should be resolved after activate event is dispatched');
return;
}
if (self.registration.active.state !== 'activating') {
port.postMessage(
'FAIL: Promise should be resolved before ServiceWorker#state is set to activated');
return;
}
port.postMessage('PASS');
})
.catch(function(e) {
port.postMessage('FAIL: unexpected exception: ' + e);
}));
});
|