function test() { const Prefs = new PrefsHelper("prefs.helper.test", { float: ["Float", "float"],
json: ["Json", "json"],
jsonWithSpecialChar: ["Json", "jsonWithSpecialChar"],
});
Prefs.registerObserver();
// JSON
Services.prefs.setCharPref("prefs.helper.test.json", '{"a":1}');
is(Prefs.json.a, 1, "The JSON pref value is correctly casted on get.");
Prefs.json = { b: 2 };
is(
Prefs.json.a,
undefined, "The JSON pref value is correctly casted on set (1)."
);
is(Prefs.json.b, 2, "The JSON pref value is correctly casted on set (2).");
// JSON with special character
Services.prefs.setStringPref( "prefs.helper.test.jsonWithSpecialChar",
`{"hello":"おはよう皆!"}`
);
is(
Prefs.jsonWithSpecialChar.hello, "おはよう皆!", "The JSON pref value with a special character is correctly stored."
);
Prefs.jsonWithSpecialChar = { bye: "さよなら!" };
is(
Prefs.jsonWithSpecialChar.hello,
undefined, "The JSON with the special characters pref value is correctly set. (1)"
);
is(
Prefs.jsonWithSpecialChar.bye, "さよなら!", "The JSON with the special characters pref value is correctly set. (2)"
);
// Float
Services.prefs.setCharPref("prefs.helper.test.float", "3.14");
is(Prefs.float, 3.14, "The float pref value is correctly casted on get.");
Prefs.float = 6.28;
is(Prefs.float, 6.28, "The float pref value is correctly casted on set.");
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.12Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.