Hi,
Recently I ran into this situation after a content script was injected into a web page. Suppose the user disabled the extension through Safari > Settings > Extension. It seems that the extension (background) session will be closed. However, the content script will be kept alive.
This behavior is similar to Chrome's extension. And in Chrome, I could listen to the onDisconnect event to clean up things in my content script.
I've tried to use the onDisconnect event like this:
port.onDisconnect.addListener(function() {
console.log("Extension disconnected");
});
But it is not working, is there any way to detect that the extension was quitted by the user or is reloading?