Bug 1277295 Remove obsolete reference to storage service r=gps,kmag
authorAndrew Swan <aswan@mozilla.com>
Fri, 24 Jun 2016 13:14:35 -0700
changeset 302713 5f93302810d063dae0f3f2c243008986027a90fe
parent 302712 6e994818e8f60192ca953c7b48adbc368b64f5f4
child 302714 1e12af97993d0c98ce029bf35b23b19bac0434ca
push id78842
push useraswan@mozilla.com
push dateMon, 27 Jun 2016 17:05:38 +0000
treeherdermozilla-inbound@5f93302810d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps, kmag
bugs1277295
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1277295 Remove obsolete reference to storage service r=gps,kmag MozReview-Commit-ID: 27BEb2XGQkZ
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -1247,32 +1247,23 @@ function loadManifestFromRDF(aUri, aStre
 
   // icons will be filled by the calling function
   addon.icons = {};
 
   return addon;
 }
 
 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;
       return guid;
     },
     set: (val) => {
       delete aAddon.syncGUID;
       aAddon.syncGUID = val;
--- a/toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
@@ -17,30 +17,32 @@ function run_test() {
   Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
 
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
   startupManager();
 
   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 = {
     onInstallEnded: function onInstallEnded() {
      AddonManager.removeInstallListener(listener);
      // never restart directly inside an onInstallEnded handler!
      do_execute_soon(function getter_setter_install_ended() {
       restartManager();
 
       AddonManager.getAddonByID(addonId, function(addon) {
 
         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";
 
         addon.syncGUID = newGUID;
         do_check_eq(newGUID, addon.syncGUID);
 
         // Verify change made it to DB.