OLD | NEW |
(Empty) | |
| 1 var port = null; |
| 2 |
| 3 self.onmessage = function(e) { |
| 4 port = e.data.port; |
| 5 port.onmessage = on_message; |
| 6 port.postMessage('ready'); |
| 7 }; |
| 8 |
| 9 function on_message(e) { |
| 10 var url = e.data; |
| 11 var client; |
| 12 |
| 13 self.clients.matchAll({ includeUncontrolled : true }).then(function(cs) { |
| 14 cs.forEach(function(c) { c.frameType == 'nested' && (client = c); }); |
| 15 return client.navigate(url); |
| 16 }) |
| 17 .then(function(c) { |
| 18 if (!c) |
| 19 port.postMessage(c); |
| 20 else |
| 21 port.postMessage(c.url); |
| 22 }) |
| 23 .catch(function(e) { |
| 24 port.postMessage(e.name); |
| 25 }); |
| 26 } |
OLD | NEW |