yyx990803 / register-service-worker

A script to simplify service worker registration with hooks for common events.
MIT License
638 stars 58 forks source link

Script Throwing "Securityerror: The Operation Is Insecure" on Firefox Under Certain Circumstances #45

Closed j0Shi82 closed 3 years ago

j0Shi82 commented 3 years ago

Hey!

Users that have chosen to "delete cookies and site data when Firefox is closed" are getting Securityerror: The Operation Is Insecure when trying to access navigator.serviceWorker functionality. This is because FireFox doesn't allow any kind of access when the option is set.

It seems like all you have to do is add catches to the serviceWorker.ready calls and emit them as you already do with other errors. It's confusing because ready is not supposed to get rejected at all, but does in this special case.

This is something you can easily work around, but you might consider adding it to your script. It is non-critical. The errors shows up in the console, but has no effect on user experience at all.

Cheers!