How to sync preferences of a bootstrapped extension via Sync?

Hi there,

My extension is bootstrapped and I want to use Firefox Sync to sync some of its preferences (e.g. extensions.foo.bar). So I have added the corresponding preferences (e.g. services.sync.prefs.sync.extensions.foo.bar = true).

Then, I created two Firefox profiles, A, B, and start testing the Firefox Sync feature:

  1. My extension has been installed in both side, but disabled in profile B;
  2. All “user set” preferences of my extension are cleared in profile B;
  3. The Sync account is set in profile A, and the “user set” preferences are synced;
  4. Then, set the Sync account in profile B, but only services.sync.prefs.sync.extensions.foo.xxx are synced to profile B;
  5. Run the Sync in profile A, then all extensions.foo.xxx are synced as empty and reset to default!

What’s wrong?

Should I add an alert box to tell my users that “Your settings may be cleared whenever you setup Sync in another device”? :expressionless:

2 Likes

Awesome question that I think more addon devs should deal with. Syncability. Im not sure about this myself but looking forward to the answer. I also am curious about how to sync file stores which addons use like addon sdk simple-storage, in case answerer knows :slight_smile:

Seems that I’m facing with the bug that have been arisen for at least 3 years.
https://bugzilla.mozilla.org/show_bug.cgi?id=753289

The fix to this bug is to sort incoming record in the prefs engine to update services.sync.prefs.sync.extensions.foo.xxx first

Thank you so much, onemen. :clap:
I’ll look into it later.
I think your wonderful TMP is doing the same workaround, right?

No.

Currently all extensions safer from this bug.

Adding a patch to an extension is not enough, if user create new profile and enable sync in the new profile before adding all extensions then the preferences from extensions that are not installed yet will be remove from the sync server, thus will set to default in all other profiles (devices)

i’m going to post my propose patch to bug 753289

2 Likes

Yea, I’ve encountered this problem and been stuck into it.
So finally, it seems better that I should wait for the bug 753289 being fixed, rather than provide a terribly buggy sync feature, which may clear all user settings permanently…

Bug 753289 was fixed landed on Firefox 43

I’m really confused on how you’re supposed to “sync preferences of a bootstrapped extension via Sync”, as the title of this thread asks, because the documentation is located in the “Archive of obsolete content” and has a scary striped warning border all around it.

https://developer.mozilla.org/en-US/docs/Archive/Mozilla/Firefox_Sync

Does anyone know if that documentation really is supposed to be marked as obsolete? I can’t find any other way to let Firefox Sync sync the preferences of my add-on.

1 Like

The old Sync service was replaced with a new service that uses Firefox Accounts. I don’t see any documentation around its sync feature, though.

1 Like

Thank you so much for clarifying!

Hi Simon.
Do you mean that you have tried services.sync.prefs.sync.<pref> but not work?

I’ve had a feature request to “enable Firefox Sync for my add-ons’s prefs” for some time, but since I don’t use Firefox Sync myself it hasn’t been prioritized … then, when finally looking into it, I noticed the MDN docs being maked as obsolete. That made me wonder if the docs were accidentally marked as obsolete, because as far as I could tell Firefox Sync was not deprecated. However, no I’ve asked and know for sure. I won’t spend time on something that I don’t use myself and that is marked as obsolete. So I haven’t even tried services.sync.prefs.sync<pref>. Too lazy :wink: