Webextensions: addon options not persisted to local firefox storage during installation

Dear all,

during the migration process to Webextensions I found an issue (BUG)
related to the “default” settings for an addon (FKA addon preferences).

Issue:

  • The default settings for an addon are not persisted to the
    local firefox storage during addon installation via:
    [about:debugging]->[Load addon temporary]->[addon.xpi]

Feature request:

  • the addon provided “options.html” page has to be loaded once during addon installation to store the default addon settings to the local firefox storage.

Best regards
Dipl.-Ing. M. Türschmann

Managing the add-ons settings is entirely application logic. If your application requires the settings page to be opened at least once in order to work, then that is by your design and you should change that design.

Hi,

If your application requires the settings page to be opened at least
once in order to work …

you dont see the problem:

With the Addon SDK and simple prefs, the default values for the addon
were transferred during the addon installation from the package.json
file to the local firefox storage.

I was expecting that WebExtension would do what any other plug-in
manager for any other software is offering: either an unique function
entry point or similiar for default values registration during the addon
installation.

For now WebExtension doesnt register default addon values. This causes
addon developer to integrate "default value check and registration"
functionality into the addon, which is overhead that causes a
signifikant time delay for the firefox start: at every firefox start it
is necessary to check all parameters that they are persisted to local
storage.

The load of the settings page during addon installation is one way to
accomplish the goal of “default value registration”.

Best regards
Dipl.-Ing. M. Türschmann

For

an unique function entry point […] during the addon installation.

see browser.runtime.onInstalled. You probably need to attach the listener synchronously to make sure you don’t miss the event:

Even though I still don’t get why people insist on writing default values to their options storage. That creates overhead too.

There is a third option here: the browser.storage.*.get() method accepts an object as parameter instead of an array or single key. You can specify the default value as the value of the key you want to retrieve. This means that you’ll have to pass your default values you’re expecting whenever getting data from storage.