The listener of the onMessage event of a content script seems to be malfunctioning after a back navigation. To demonstrate the case clearer, I've created a minimal reproducible case here: https://github.com/southp/orion-onmessage-exp
The extension does a simple message passing between the content script and the background service worker script. Each step is represented by a console log in the corresponding dev console:
- Pressing "k", the content script sends the message, "ping", to the service worker. (log: 1. -----Ready to send ping!)
- Received "ping", the service worker sends "ping" to the content script using the tab id + frame id. (log: 2. -----Ready to send pong!)
- Received "pong", the content script sends "smash" to the serivce worker. (log: 3. ------ Pong received. Ready to smash!)
- Received "smash", the service worker prints the final message to confirm the message exchanging has completed. (log: 4. SCORE!)
Steps to reproduce
- Clone and install the above extension.
- Open the service worker dev console of the extension.
- Visit https://example.com, just to be simple.
- Press "k". The logs No.1 & 3 will show in the web page console, while No.2 & 4 will show in the extension dev console.
- Now, click on a random link, and then navigate back.
- Press k again. This time the log 3 & 4 won't show, indicating the onMessage event listener of the content script is malfunctioning somehow.
Upon my test, sometimes there will be an uncaught exception stating that there is no receiving end, but sometimes there is none.
After back navigation, the full 14 message exchanging steps should still work.
Version 0.99.135-beta (WebKit 622.1.15.19.2)
Sequoia (15)