The extension has code to handle various issues related to:
- Handling the loading of a new page or reloading a page
- Initalization of the background script on Browser startup
- Handling a re-install of the extension
- Handling the disabling and re-enabling of the extension
Each browser has slightly different behavior in some of these cases.
Safari has a bug where, if the background page only includes a script of type module then it sometimes doesn't recognise that the background script has registered a listener and never awakens it.
It works OK after an install or re-enable for the rest of that run of Safari (not sure if this is the case if the background gets unloaded because it is not persistent). However, if Safari is quit and restarted the background script never registers its listener.
As of April 2022 Firefox and Safari automatically reload the content scripts when the browser is installed or enabled.
Chrome does not. So I have code (for Chrome only) to detect both events and to re-inject the content scripts
When testing all this code we have to test all these situations in all browsers/platforms:
- Check normal usage works
- Quit browser and restart and check popups and content menus
- Install new version and check same
- Disable and renable the extenion and check same
- Stress test with using Cmd+R to reload page and quickly clicking popup
- There are several case to test, some sites (FMP particularly) can say that load is complete but the page is not updated with the record data yet.