1

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");
iLearn2016
  • 85
  • 9
  • Maybe an error occurs before that code runs. Check the debugger console for your extension. – wOxxOm Mar 26 '17 at 16:34
  • No error on the console :( – iLearn2016 Mar 27 '17 at 05:21
  • In what version of Firefox are you testing? – Makyen Mar 27 '17 at 05:43
  • @Makyen FF 52.0.1 (32 bit), also, just found that removing addon from the `about:addons` triggers the uninstall-page, still no luck with install and update trigger. Can it be the fact that `Install` is not triggered when in `Debug` mode!! – iLearn2016 Mar 27 '17 at 05:46
  • Have you actually *fully installed* your add-on? Specifically: Have you installed it as a temporary add-on (i.e. through `about:debugging`)? If so, [it is documented](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/onInstalled#Compatibility_notes) that it will not work. The event is not fired for temporary add-ons. – Makyen Mar 27 '17 at 05:46
  • @Makyen Yes, that was the cause, missed that crucial information :(, how to test it with FULL-INSTALL without signing? – iLearn2016 Mar 27 '17 at 05:56
  • I guess this - https://wiki.mozilla.org/Add-ons/Extension_Signing will help. – iLearn2016 Mar 27 '17 at 06:01

1 Answers1

2

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.

Makyen
  • 31,849
  • 12
  • 86
  • 121