App focus When the app has the browser focus, the received message is handled through the onMessage callback in index.html. When the app does not have browser focus then the setBackgroundMessageHandler callback in firebase-messaging-sw.js is where the received message is handled.
https://firebase.google.com/docs/cloud-messaging/js/client
https://github.com/firebase/quickstart-js/tree/master/messaging