As I understand it, there is currently an intrinsic conflict between dynamic and non-dynamic themes which is outlined in this bug:
Define behaviour of theme.reset()
and on the Mozilla documentation here: theme.reset(). This causes a situation where:
- A user installs a theme
- A user installs a webextension which overrides the theme dynamically
- A user switches to a non-themed tab, extension calls
browser.theme.reset()
- The user no longer sees their desired theme from step 1 but the default instead
I would like to alter this behavior in my extension. I think I should be able to get the whole theme with browser.theme.getCurrent()
as soon as my extension starts up, and then store it somewhere, then anywhere I call browser.theme.reset()
instead retrieve the stored theme and re-apply it with browser.theme.update()
. However it turns out most of the ways I attempt it turn out to be brittle. The obvious flaw is that if the user closes and re-opens their browser while using an extension which has triggered a dynamic theme which is visible, the theme that gets stored is the first theme that is active, undermining the users intent and in some cases the functionality of the extension. Updating the theme for every theme event except for theme events where the theme object equals one of the theme objects from the extension works better as long as only one of your extensions is doing dynamic theming. But both approaches get close to working well. Has anybody else figured this one out yet?