Safari WebExtension runtime.onInstalled API not working

Hi,
It seems that the browser.runtime.onInstalled API is not working on Safari WebExtenison.

According to MDN, that API is supported, but according to my test, either installing it or toggling enable/disable checkbox on the Preference menu, the event listener is not called.

Not sure it is my testing issue or it is actually not supported.

Thanks!
From my reading of the spec, the onInstalled event is only supposed to be fired when an extension version update happens. Toggling the disable/enable checkbox will unload and reload your background page, but I wouldn't expect the onInstalled event to fire. Can you use the onload event of the background page instead?

If this isn't how you think this should work, please file feedback at https://feedbackassistant.apple.com and let me know the feedback ID that you file?

Thanks!


Hi bweinstein,
From the MDN, the event will be trigger when installed or upgraded. Yes, I have created the feedback 8695776
Thank you

For Safari 15 on iOS this appears to be very unreliable. The onInstalled is not consistently invoked and in repeated tests it only occasionally runs. It's almost like the background page is being terminated before the onInstalled handler finishes. Perhaps related to async calls.

Safari WebExtension runtime.onInstalled API not working
 
 
Q