runtime.onInstalled, does previousVersion work for updates from SDK add-on?

Hi,

I am developing a WebExtension version of one of my add-ons. My add-on is currently a SDK based add-on. In the WebExtension world there is a runtime.onInstalled event and a previousVersion property. Does this work for updates from SDK to WebExtension?

Example: The SDK add-on has the version number 6.0.0, the WebExtension version will have the version number 7.0.0.

If I do something like:

const addon = {
    onInstalledHandler (details) {
        if (details.reason === 'update' && parseFloat(details.previousVersion) < 7) {
            // do something
        }
    },
}

browser.runtime.onInstalled.addListener(addon.onInstalledHandler);

… does this work? Is details.previousVersion defined and contains the version number 6.0.0?

(it’s not about data migration, I won’t migrate any data. I want to show a compat notice for users of the old version and don’t show it for new users)

I have a second questions and that’s why I have to ask the first question: how can I test the update from SDK to WebExtension?

I don’t know the details of previousVersion, but I think it should work just the same independently of the previous version using the SDK or WebExtensions.

As for the update, you can just have the SDK version installed and then try installing the new WebExtensions version by drag-and-dropping it into the Add-ons Manager. You will need to disable signing enforcement to test this, or upload both versions to be signed as unlisted versions on AMO.

1 Like

Thank you very much, Jorge!