I guess this is what you are looking for:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(example\.com)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
I have no idea about that mozilla exception you mention. A caching issue maybe? You 'd need to take a closer look at the log files and maybe you have to enable rewrite logging to see what exactly is going on inside the rewriting engine...