Bug 1277295 Remove obsolete reference to storage service r=gps,kmag

MozReview-Commit-ID: 27BEb2XGQkZ

--HG--
extra : rebase_source : 4abfe29abfb7b8e8b7a11fcbf68ce12f8419be40
This commit is contained in:
Andrew Swan 2016-06-24 13:14:35 -07:00
Родитель c31c1d4b33
Коммит 97f5aada1f
2 изменённых файлов: 6 добавлений и 13 удалений

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

@ -1252,22 +1252,13 @@ function loadManifestFromRDF(aUri, aStream) {
}
function defineSyncGUID(aAddon) {
// Load the storage service before NSS (nsIRandomGenerator),
// to avoid a SQLite initialization error (bug 717904).
let storage = Services.storage;
// Define .syncGUID as a lazy property which is also settable
Object.defineProperty(aAddon, "syncGUID", {
get: () => {
// Generate random GUID used for Sync.
// This was lifted from util.js:makeGUID() from services-sync.
let rng = Cc["@mozilla.org/security/random-generator;1"].
createInstance(Ci.nsIRandomGenerator);
let bytes = rng.generateRandomBytes(9);
let byte_string = bytes.map(byte => String.fromCharCode(byte)).join("");
// Base64 encode
let guid = btoa(byte_string).replace(/\+/g, '-')
.replace(/\//g, '_');
let guid = Cc["@mozilla.org/uuid-generator;1"]
.getService(Ci.nsIUUIDGenerator)
.generateUUID().toString();
delete aAddon.syncGUID;
aAddon.syncGUID = guid;

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

@ -22,6 +22,8 @@ function run_test() {
run_next_test();
}
const UUID_PATTERN = /^\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}$/i;
add_test(function test_getter_and_setter() {
// Our test add-on requires a restart.
let listener = {
@ -35,7 +37,7 @@ add_test(function test_getter_and_setter() {
do_check_neq(addon, null);
do_check_neq(addon.syncGUID, null);
do_check_true(addon.syncGUID.length >= 9);
do_check_true(UUID_PATTERN.test(addon.syncGUID));
let oldGUID = addon.SyncGUID;
let newGUID = "foo";