Open Bug 1639331 Opened 4 years ago Updated 2 years ago

EPM does not update when preferences are changed outside EPM

Categories

(WebExtensions :: General, enhancement, P2)

enhancement

Tracking

(Not tracked)

People

(Reporter: mixedpuppy, Unassigned)

References

(Blocks 1 open bug)

Details

Any time a preference is changed using the preferences API the settings become out of sync with what the ExtensionPreferencesManager expects. We currently do not observe those changes.

An example where this happens is bug 1631676, where setting the dfpi pref potentially sets the cookie behavior pref. If an extension had set the cookie behavior pref, we are now out of sync.

A solution to this is:

For all EPM settings that are stored, we add an observer for the pref. If we observe a pref change that is not due to a call to an EPM api, we change the setting to user-controlled.

The trick here will be using some flag to know that an EPM api is the cause of the pref change.

Fortunately, EPM sets prefs in one place[1] so we should be able to figure outsomething.

We also need to examine prefs on startup and compare those to any that EPM claims is extension controlled. If the prefs do not match our expectation, then we need to change the setting to user-controlled.

When we make any of these changes, we also need to Management.emit(extension-setting-changed:${name}); so that extensions monitoring the settings will get notified.

[1] https://searchfox.org/mozilla-central/rev/61fceb7c0729773f544a9656f474e36cd636e5ea/toolkit/components/extensions/ExtensionPreferencesManager.jsm#156

Severity: S2 → S3

(In reply to Shane Caraveo (:mixedpuppy) from comment #0)

Any time a preference is changed using the preferences API the settings become out of sync with what the ExtensionPreferencesManager expects. We currently do not observe those changes.

Can you clarify the problem? The original code here was designed to work even when prefs were changed externally. This is briefly documented here: https://searchfox.org/mozilla-central/rev/5e4d4827aa005d031580d2d17a01bae1af138b2e/toolkit/components/extensions/ExtensionPreferencesManager.jsm#182-185

The original code here was designed to work even when prefs were changed externally.

That only applies when something uses EPM to change the setting. EPM does not observe changes made otherwise.

Given a setting "X" which has both an extension API, and user interface in about:preferences;

An extension sets "X" to something
about:preferences now has an extension controlled note, with button to disable extension.
the extension API will claim the extension has control
"X" is changed elsewhere, either via some code, or about:config

expected:
about:preferences no longer claims an extension controls the setting
the extension API will claim the setting is user controlled

actual:
about:preferences claims an extension controls the setting
the extension API will claim the extension has control

You need to log in before you can comment on or make changes to this bug.