1 2 3 4 5 6 7 8 9 10 11 12
function ok(aCondition, aMessage) { return new Promise(function(resolve, reject) { self.clients.matchAll().then(function(res) { if (!res.length) { reject(); return; } res[0].postMessage({status: "callback", data: "ok", condition: aCondition, message: aMessage}); resolve(); }); }); }