OLD | NEW |
(Empty) | |
| 1 var client = null; |
| 2 |
| 3 function initializeClient() { |
| 4 return self.clients.getAll().then(function(clients) { |
| 5 client = clients[0]; |
| 6 }); |
| 7 } |
| 8 |
| 9 function testWithClick() { |
| 10 var notification = new Notification('My Notification'); |
| 11 notification.addEventListener('show', function() { |
| 12 client.postMessage('click'); |
| 13 }); |
| 14 |
| 15 notification.addEventListener('click', function() { |
| 16 client.focus().catch(function() { |
| 17 client.postMessage('focus() outside of a notificationclick failed'); |
| 18 client.postMessage('quit'); |
| 19 }); |
| 20 }); |
| 21 |
| 22 notification.addEventListener('error', function() { |
| 23 client.postMessage('quit'); |
| 24 }); |
| 25 |
| 26 client.postMessage('quit'); |
| 27 } |
| 28 |
| 29 function testWithNoClick() { |
| 30 client.focus().catch(function() { |
| 31 client.postMessage('focus() outside of a notificationclick failed'); |
| 32 testWithClick(); |
| 33 }); |
| 34 } |
| 35 |
| 36 self.onmessage = function(e) { |
| 37 switch(e.data) { |
| 38 case "start": |
| 39 initializeClient().then(testWithNoClick); |
| 40 break; |
| 41 } |
| 42 } |
OLD | NEW |