Bug 1012466 - Properly synchronize experiments shutdown with the AddonManager by using its shutdown barrier. r=bsmedberg,a=lmandel
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Tue, 08 Jul 2014 17:36:24 +0200
changeset 208079 c2c33b7f9006f72455d7cc3373c2df650f01ee6a
parent 208078 eba99269ef53fc360a6846f3d21a04f1024cc5c7
child 208080 a87021ee40b84c7d52793b5e0108fc75dcfbb499
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, lmandel
bugs1012466
milestone32.0a2
Bug 1012466 - Properly synchronize experiments shutdown with the AddonManager by using its shutdown barrier. r=bsmedberg,a=lmandel
browser/experiments/Experiments.jsm
browser/experiments/test/xpcshell/test_api.js
browser/experiments/test/xpcshell/test_conditions.js
browser/experiments/test/xpcshell/test_healthreport.js
--- a/browser/experiments/Experiments.jsm
+++ b/browser/experiments/Experiments.jsm
@@ -417,20 +417,19 @@ Experiments.Experiments.prototype = {
     this._log.trace("enabled=" + gExperimentsEnabled + ", " + this.enabled);
 
     gPrefs.observe(PREF_LOGGING, configureLogging);
     gPrefs.observe(PREF_MANIFEST_URI, this.updateManifest, this);
     gPrefs.observe(PREF_ENABLED, this._toggleExperimentsEnabled, this);
 
     gPrefsTelemetry.observe(PREF_TELEMETRY_ENABLED, this._telemetryStatusChanged, this);
 
-    AsyncShutdown.profileBeforeChange.addBlocker("Experiments.jsm shutdown",
-      this.uninit.bind(this),
-      this._getState.bind(this)
-    );
+    AddonManager.shutdown.addBlocker("Experiments.jsm shutdown",
+                                     this.uninit.bind(this),
+                                     this._getState.bind(this));
 
     this._registerWithAddonManager();
 
     this._loadTask = this._loadFromCache();
 
     return this._loadTask.then(
       () => {
         this._log.trace("_loadTask finished ok");
--- a/browser/experiments/test/xpcshell/test_api.js
+++ b/browser/experiments/test/xpcshell/test_api.js
@@ -1521,19 +1521,18 @@ add_task(function* testEnabledAfterResta
   let fromManifest = yield experiments.getExperiments();
   Assert.equal(fromManifest.length, 1, "A single experiment is known.");
 
   addons = yield getExperimentAddons();
   Assert.equal(addons.length, 1, "A single experiment add-on is installed.");
   Assert.ok(addons[0].isActive, "That experiment is active.");
 
   dump("Restarting Addon Manager\n");
-  experiments._unregisterWithAddonManager();
   restartManager();
-  experiments._registerWithAddonManager();
+  experiments = new Experiments.Experiments(gPolicy);
 
   addons = yield getExperimentAddons();
   Assert.equal(addons.length, 1, "The experiment is still there after restart.");
   Assert.ok(addons[0].userDisabled, "But it is disabled.");
   Assert.equal(addons[0].isActive, false, "And not active.");
 
   yield experiments.updateManifest();
   Assert.ok(addons[0].isActive, "It activates when the manifest is evaluated.");
@@ -1580,17 +1579,16 @@ add_task(function* test_foreignUninstall
   Assert.equal(addons.length, 0, "Experiment add-on should have been removed.");
 
   experimentList = yield experiments.getExperiments();
   Assert.equal(experimentList.length, 1, "A single experiment is known.");
   Assert.equal(experimentList[0].id, EXPERIMENT1_ID, "Experiment 1 should be the sole entry.");
   Assert.ok(!experimentList[0].active, "Experiment 1 should not be active anymore.");
 
   // Fake restart behaviour.
-  yield experiments.uninit();
   restartManager();
   experiments = new Experiments.Experiments(gPolicy);
   yield experiments.updateManifest();
 
   let addons = yield getExperimentAddons();
   Assert.equal(addons.length, 0, "No experiment add-ons installed.");
 
   experimentList = yield experiments.getExperiments();
--- a/browser/experiments/test/xpcshell/test_conditions.js
+++ b/browser/experiments/test/xpcshell/test_conditions.js
@@ -63,18 +63,16 @@ add_task(function* test_setup() {
     locale: () => "en-US",
     healthReportPayload: () => Promise.resolve(payload),
     random: () => 0.5,
   });
 
   Services.prefs.setBoolPref(PREF_EXPERIMENTS_ENABLED, true);
   Services.prefs.setIntPref(PREF_LOGGING_LEVEL, 0);
   Services.prefs.setBoolPref(PREF_LOGGING_DUMP, true);
-
-  let experiments = new Experiments.Experiments();
 });
 
 function arraysEqual(a, b) {
   if (a.length !== b.length) {
     return false;
   }
 
   for (let i=0; i<a.length; ++i) {
--- a/browser/experiments/test/xpcshell/test_healthreport.js
+++ b/browser/experiments/test/xpcshell/test_healthreport.js
@@ -1,16 +1,17 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 Cu.import("resource://gre/modules/Metrics.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
 Cu.import("resource:///modules/experiments/Experiments.jsm");
+Cu.import("resource://testing-common/AddonManagerTesting.jsm");
 Cu.import("resource://testing-common/services/healthreport/utils.jsm");
 Cu.import("resource://testing-common/services-common/logging.js");
 
 const kMeasurementVersion = 2;
 
 function getStorageAndProvider(name) {
   return Task.spawn(function* get() {
     let storage = yield Metrics.Storage(name);
@@ -23,16 +24,17 @@ function getStorageAndProvider(name) {
 
 function run_test() {
   run_next_test();
 }
 
 add_test(function setup() {
   do_get_profile();
   initTestLogging();
+  loadAddonManager();
 
   Services.prefs.setBoolPref(PREF_EXPERIMENTS_ENABLED, true);
   Services.prefs.setBoolPref(PREF_TELEMETRY_ENABLED, true);
   Services.prefs.setBoolPref(PREF_HEALTHREPORT_ENABLED, true);
 
   run_next_test();
 });