I try to postMessage
between a web application and the corresponding service worker. The service worker is successfully registered and working so far.
Unfortunately, I noticed some strange behavior:
- The
navigator.serviceWorker.controller
is alwaysnull
. - At the service worker side, I implemented
postMessage
as follows:
self.addEventListener('message', function (evt) {
console.log('postMessage received', evt);
});
Unfortunately, the important fields to post back to the origin evt.origin=''
and evt.source=null
do not contain the desired values. Nonetheless, I always received the sent evt.data
.
Do you know how to post back?
Thank you very much!
Andi