The following web-extension code in my background script background.js
works fine on Opera and Chrome triggering appropriate webpage on Install, Update and Uninstall but does nothing in firefox. The same is shown as compatible here - https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/onInstalled
Manifest.json
has:
"background" : {
"scripts" : ["includes/background.js"]
},
background.js
has :
//CHECK INSTALL, UPDATE, UNINSTALL
chrome.runtime.onInstalled.addListener(function (details) {
if (details.reason == "install") {
chrome.tabs.create({
url : "https://www.example.com/install.html"
});
}
if (details.reason == "update") {
chrome.tabs.create({
url : "https://www.example.com/update.html"
});
}
});
chrome.runtime.setUninstallURL("http://www.example.com/uninstall.html");
You have installed your add-on as a temporary add-on through about:debugging
. The documentation states:
This event is not triggered for temporarily installed add-ons.
Thus, the event won't fire. You will need to install your add-on as a normal, non-temporary add-on. There are multiple ways for you to do so. The official way is to install Firefox Developer Edition, or Firefox Nightly and set xpinstall.signatures.required
to false
in about:config
. If you want to do so in the release version of Firefox, you can entirely disable add-on signature checking in Firefox. The process to do so is described in the linked answer (also listed below). You may also the information in the Documentation link below helpful in installing your add-on as a normal add-on.