Firefox: Service Worker: SecurityError: DOMException: The Operation is insecure

The same error message also appears in Firefox, if the serviceworker's file is delivered with a wrong MIME-Type. In that case setting the right MIME-Type fixes the problem. Wrong MIME-Type can happen, if you deliver the serviceworker's file dynamically e.g. using PHP.

Correct MIME-Type must be

Content-Type: application/javascript; charset=UTF-8

Did you check the cookie setting in about:preferences#privacy, it must be 'keep until they expire', if you have 'keep until I close firefox' selected sw will not register.

enter image description here

you can find details on this thread:

You can keep "Delete cookies and site data when Firefox is closed" checked, as long as you create an exception for your site. (Tested in Firefox 78.0.2):

Delete cookies and site data when Firefox is closed

Click on Manage Permissions... and enter a URL (e.g. localhost:8000). Click Allow, then click Save Changes in the bottom right corner. Service workers (and cookies etc.) should now work for this URL, but not for other URLs.

Developers, note that localhost is not the same as e.g. localhost:8000 (you need to specify the port number).