I have a browser extension that is working perfectly in chrome. when I ported it across to firefox, the following snippet of code, which runs in the extensions background thread, throws an exception.
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/firebase-messaging-sw.js',{
updateViaCache: 'none'
})
.then(function(registration) {
console.log('Registration successful, scope is:', registration.scope);
}).catch(function(err) {
console.log('Service worker registration failed, error:', err);
});
}
The error is as follows: DOMException: "The operation is insecure."
I am experiencing this issue in Firefox 70.0.1 and so I believe that these existing answers around cookie expiration settings out of date (??): Firefox: Service Worker: SecurityError: DOMException: The Operation is insecure
I have tried every combination of change to the manifest.json that I can think of and the manifest currently looks like this:
"permissions": ["storage", "contextMenus", "tabs", "notifications", "*://localhost/*"],
"content_security_policy": "script-src 'self' '<MY-SHA256>' https://www.gstatic.com https://storage.googleapis.com; object-src 'self'",
"background": {
"page": "background.html",
"persistent": true
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["/assets/js/browser-polyfill.min.js","/load.js"]
}],
"web_accessible_resources" : ["*.html",
"https://sitecontent.loopworks.com/scripts/fa-5-11-2/js/all.js",
"https://www.gstatic.com/firebasejs/6.5.0/firebase.js",
"https://www.gstatic.com/firebasejs/6.5.0/firebase-messaging.js"
]
This is the content of the backgound page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script src="/assets/js/firebase.js"></script>
<script src="/assets/js/firebase-messaging.js"></script>
<script src="/assets/js/browser-polyfill.min.js"></script>
<script src="/background.js"></script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
</body>
</html>
I'm absolutely stuck here so would really appreciate any suggestions.