Do you ever trigger a "message" event on the window? This code just adds the eventlistener, but if the event never occurs it wont run the code.
If you are just doing a request for external data then you probably don't need to set an eventlistener, you can do a request and then in the response promise edit whatever needs editing?