mirror of
https://github.com/roytam1/mozilla45esr.git
synced 2026-05-26 06:25:03 +00:00
checkin upstream patch: Bug 1277295 - Extension installation failing with NS_ERROR_XPC_GS_RETURNED_FAILURE for Services.storage
This commit is contained in:
@@ -1247,22 +1247,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";
|
||||
|
||||
Reference in New Issue
Block a user