Bug 615604 - Make pref GUIDs base64url. r=mconnor

This commit is contained in:
Philipp von Weitershausen 2010-11-30 13:36:01 -08:00
Родитель 835f9d759e
Коммит a84a019b81
3 изменённых файлов: 14 добавлений и 10 удалений

Просмотреть файл

@ -50,6 +50,8 @@ Cu.import("resource://services-sync/type_records/prefs.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://services-sync/ext/Preferences.js");
const PREFS_GUID = Utils.encodeBase64url(Svc.AppInfo.ID);
function PrefsEngine() {
SyncEngine.call(this, "Prefs");
}
@ -64,7 +66,7 @@ PrefsEngine.prototype = {
// No need for a proper timestamp (no conflict resolution needed).
let changedIDs = {};
if (this._tracker.modified)
changedIDs[Svc.AppInfo.ID] = 0;
changedIDs[PREFS_GUID] = 0;
return changedIDs;
},
@ -177,7 +179,7 @@ PrefStore.prototype = {
getAllIDs: function PrefStore_getAllIDs() {
/* We store all prefs in just one WBO, with just one GUID */
let allprefs = {};
allprefs[Svc.AppInfo.ID] = true;
allprefs[PREFS_GUID] = true;
return allprefs;
},
@ -186,13 +188,13 @@ PrefStore.prototype = {
},
itemExists: function FormStore_itemExists(id) {
return (id === Svc.AppInfo.ID);
return (id === PREFS_GUID);
},
createRecord: function createRecord(id, collection) {
let record = new PrefRec(collection, id);
if (id == Svc.AppInfo.ID) {
if (id == PREFS_GUID) {
record.value = this._getAllPrefs();
} else {
record.deleted = true;

Просмотреть файл

@ -3,6 +3,8 @@ Cu.import("resource://services-sync/type_records/prefs.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://services-sync/ext/Preferences.js");
const PREFS_GUID = Utils.encodeBase64url(Svc.AppInfo.ID);
function run_test() {
let store = new PrefsEngine()._store;
let prefs = new Preferences();
@ -27,18 +29,18 @@ function run_test() {
let allIDs = store.getAllIDs();
let ids = [id for (id in allIDs)];
do_check_eq(ids.length, 1);
do_check_eq(ids[0], Svc.AppInfo.ID);
do_check_true(allIDs[Svc.AppInfo.ID], true);
do_check_eq(ids[0], PREFS_GUID);
do_check_true(allIDs[PREFS_GUID], true);
do_check_true(store.itemExists(Svc.AppInfo.ID));
do_check_true(store.itemExists(PREFS_GUID));
do_check_false(store.itemExists("random-gibberish"));
_("Unknown prefs record is created as deleted.");
let record = store.createRecord("random-gibberish", "http://fake/uri");
let record = store.createRecord("random-gibberish", "prefs");
do_check_true(record.deleted);
_("Prefs record contains only prefs that should be synced.");
record = store.createRecord(Svc.AppInfo.ID, "http://fake/uri");
record = store.createRecord(PREFS_GUID, "prefs");
do_check_eq(record.value["testing.int"], 123);
do_check_eq(record.value["testing.string"], "ohai");
do_check_eq(record.value["testing.bool"], true);

Просмотреть файл

@ -21,7 +21,7 @@ function run_test() {
let changedIDs = engine.getChangedIDs();
let ids = [id for (id in changedIDs)];
do_check_eq(ids.length, 1);
do_check_eq(ids[0], Svc.AppInfo.ID);
do_check_eq(ids[0], Utils.encodeBase64url(Svc.AppInfo.ID));
Svc.Prefs.set("engine.prefs.modified", false);
do_check_false(tracker.modified);