Bug 1012466 - Test cleanups. r=bsmedberg,a=lmandel
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Wed, 09 Jul 2014 15:17:36 +0200
changeset 208080 a87021ee40b84c7d52793b5e0108fc75dcfbb499
parent 208079 c2c33b7f9006f72455d7cc3373c2df650f01ee6a
child 208081 687586ef14b4da7229520f57730b51a713dfe09f
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 - Test cleanups. r=bsmedberg,a=lmandel
browser/experiments/Experiments.jsm
browser/experiments/test/xpcshell/test_api.js
browser/experiments/test/xpcshell/test_cache.js
browser/experiments/test/xpcshell/test_disableExperiments.js
browser/experiments/test/xpcshell/test_fetch.js
browser/experiments/test/xpcshell/test_telemetry.js
--- a/browser/experiments/Experiments.jsm
+++ b/browser/experiments/Experiments.jsm
@@ -541,26 +541,27 @@ Experiments.Experiments.prototype = {
       ]);
     }
 
   },
 
   _unregisterWithAddonManager: function () {
     this._log.trace("Unregistering instance with Addon Manager.");
 
+    this._log.trace("Removing install listener from add-on manager.");
+    AddonManager.removeInstallListener(this);
+    this._log.trace("Removing addon listener from add-on manager.");
+    AddonManager.removeAddonListener(this);
+
     if (gAddonProvider) {
       this._log.trace("Unregistering previous experiment add-on provider.");
       AddonManagerPrivate.unregisterProvider(gAddonProvider);
       gAddonProvider = null;
     }
 
-    this._log.trace("Removing install listener from add-on manager.");
-    AddonManager.removeInstallListener(this);
-    this._log.trace("Removing addon listener from add-on manager.");
-    AddonManager.removeAddonListener(this);
     this._log.trace("Finished unregistering with addon manager.");
   },
 
   /*
    * Change the PreviousExperimentsProvider that this instance uses.
    * For testing only.
    */
   _setPreviousExperimentsProvider: function (provider) {
--- a/browser/experiments/test/xpcshell/test_api.js
+++ b/browser/experiments/test/xpcshell/test_api.js
@@ -31,20 +31,19 @@ function uninstallExperimentAddons() {
     for (let a of addons) {
       yield AddonTestUtils.uninstallAddonByID(a.id);
     }
   });
 }
 
 function testCleanup(experimentsInstance) {
   return Task.spawn(function* () {
-    yield experimentsInstance.uninit();
+    yield promiseRestartManager();
+    yield uninstallExperimentAddons();
     yield removeCacheFile();
-    yield uninstallExperimentAddons();
-    restartManager();
   });
 }
 
 function run_test() {
   run_next_test();
 }
 
 add_task(function* test_setup() {
@@ -344,17 +343,17 @@ add_task(function* test_getActiveExperim
   defineNow(gPolicy, now);
 
   let experiments = new Experiments.Experiments(gPolicy);
   yield experiments.updateManifest();
 
   Assert.equal(experiments.getActiveExperimentID(), EXPERIMENT1_ID,
                "getActiveExperimentID should return the active experiment1");
 
-  yield experiments.uninit();
+  yield promiseRestartManager();
   Assert.equal(experiments.getActiveExperimentID(), EXPERIMENT1_ID,
                "getActiveExperimentID should return the active experiment1 after uninit()");
 
   yield testCleanup(experiments);
 });
 
 // Test that we handle the experiments addon already being
 // installed properly.
@@ -1521,17 +1520,17 @@ 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");
-  restartManager();
+  yield promiseRestartManager();
   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();
@@ -1579,17 +1578,17 @@ 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.
-  restartManager();
+  yield promiseRestartManager();
   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();
   Assert.equal(experimentList.length, 1, "A single experiment is known.");
--- a/browser/experiments/test/xpcshell/test_cache.js
+++ b/browser/experiments/test/xpcshell/test_cache.js
@@ -160,30 +160,30 @@ add_task(function* test_cache() {
   defineNow(gPolicy, now);
 
   let experiments = new Experiments.Experiments(gPolicy);
   yield experiments.updateManifest();
   let list = yield experiments.getExperiments();
   Assert.equal(list.length, 0, "Experiment list should be empty.");
   checkExperimentSerializations(experiments._experiments.values());
 
-  yield experiments.uninit();
+  yield promiseRestartManager();
   experiments = new Experiments.Experiments(gPolicy);
 
   yield experiments._run();
   list = yield experiments.getExperiments();
   Assert.equal(list.length, 0, "Experiment list should be empty.");
   checkExperimentSerializations(experiments._experiments.values());
 
   // Re-init, clock set for experiment 1 to start.
 
   now = futureDate(startDates[0], 5 * MS_IN_ONE_DAY);
   defineNow(gPolicy, now);
 
-  yield experiments.uninit();
+  yield promiseRestartManager();
   experiments = new Experiments.Experiments(gPolicy);
   yield experiments._run();
 
   list = yield experiments.getExperiments();
   Assert.equal(list.length, 1, "Experiment list should have 1 entry now.");
 
   experimentListData[1].active = true;
   experimentListData[1].endDate = now.getTime() + 10 * MS_IN_ONE_DAY;
@@ -197,17 +197,17 @@ add_task(function* test_cache() {
   branch = yield experiments.getExperimentBranch(EXPERIMENT1_ID);
   Assert.strictEqual(branch, "testbranch");
 
   // Re-init, clock set for experiment 1 to stop.
 
   now = futureDate(now, 20 * MS_IN_ONE_DAY);
   defineNow(gPolicy, now);
 
-  yield experiments.uninit();
+  yield promiseRestartManager();
   experiments = new Experiments.Experiments(gPolicy);
   yield experiments._run();
 
   list = yield experiments.getExperiments();
   Assert.equal(list.length, 1, "Experiment list should have 1 entry.");
 
   experimentListData[1].active = false;
   experimentListData[1].endDate = now.getTime();
@@ -217,43 +217,43 @@ add_task(function* test_cache() {
   branch = yield experiments.getExperimentBranch(EXPERIMENT1_ID);
   Assert.strictEqual(branch, "testbranch");
 
   // Re-init, clock set for experiment 2 to start.
 
   now = futureDate(startDates[1], 20 * MS_IN_ONE_DAY);
   defineNow(gPolicy, now);
 
-  yield experiments.uninit();
+  yield promiseRestartManager();
   experiments = new Experiments.Experiments(gPolicy);
   yield experiments._run();
 
   list = yield experiments.getExperiments();
   Assert.equal(list.length, 2, "Experiment list should have 2 entries.");
 
   experimentListData[0].active = true;
   experimentListData[0].endDate = now.getTime() + 10 * MS_IN_ONE_DAY;
   checkExperimentListsEqual(experimentListData, list);
   checkExperimentSerializations(experiments._experiments.values());
 
   // Re-init, clock set for experiment 2 to stop.
 
   now = futureDate(now, 20 * MS_IN_ONE_DAY);
   defineNow(gPolicy, now);
 
-  yield experiments.uninit();
+  yield promiseRestartManager();
   experiments = new Experiments.Experiments(gPolicy);
   yield experiments._run();
 
   list = yield experiments.getExperiments();
   Assert.equal(list.length, 2, "Experiment list should have 2 entries.");
 
   experimentListData[0].active = false;
   experimentListData[0].endDate = now.getTime();
   checkExperimentListsEqual(experimentListData, list);
   checkExperimentSerializations(experiments._experiments.values());
 
   // Cleanup.
 
   yield experiments._toggleExperimentsEnabled(false);
-  yield experiments.uninit();
+  yield promiseRestartManager();
   yield removeCacheFile();
 });
--- a/browser/experiments/test/xpcshell/test_disableExperiments.js
+++ b/browser/experiments/test/xpcshell/test_disableExperiments.js
@@ -179,11 +179,11 @@ add_task(function* test_disableExperimen
   Assert.equal(list.length, 1, "Experiment list should still have 1 entry.");
   Assert.equal(list[0].active, false, "Experiment entry should not be active.");
   addons = yield getExperimentAddons();
   Assert.equal(addons.length, 0, "There should still be no experiment add-on installed.");
 
   // Cleanup.
 
   Services.obs.removeObserver(observer, OBSERVER_TOPIC);
-  yield experiments.uninit();
+  yield promiseRestartManager();
   yield removeCacheFile();
 });
--- a/browser/experiments/test/xpcshell/test_fetch.js
+++ b/browser/experiments/test/xpcshell/test_fetch.js
@@ -40,34 +40,34 @@ function run_test() {
 add_task(function* test_fetchAndCache() {
   Services.prefs.setCharPref(PREF_MANIFEST_URI, gHttpRoot + "experiments_1.manifest");
   let ex = new Experiments.Experiments(gPolicy);
 
   Assert.equal(ex._experiments, null, "There should be no cached experiments yet.");
   yield ex.updateManifest();
   Assert.notEqual(ex._experiments.size, 0, "There should be cached experiments now.");
 
-  yield ex.uninit();
+  yield promiseRestartManager();
 });
 
 add_task(function* test_checkCache() {
   let ex = new Experiments.Experiments(gPolicy);
   yield ex.notify();
   Assert.notEqual(ex._experiments.size, 0, "There should be cached experiments now.");
 
-  yield ex.uninit();
+  yield promiseRestartManager();
 });
 
 add_task(function* test_fetchInvalid() {
   yield removeCacheFile();
 
   Services.prefs.setCharPref(PREF_MANIFEST_URI, gHttpRoot + "experiments_1.manifest");
   let ex = new Experiments.Experiments(gPolicy);
   yield ex.updateManifest();
   Assert.notEqual(ex._experiments.size, 0, "There should be experiments");
 
   Services.prefs.setCharPref(PREF_MANIFEST_URI, gHttpRoot + "invalid.manifest");
   yield ex.updateManifest()
   Assert.notEqual(ex._experiments.size, 0, "There should still be experiments: fetch failure shouldn't remove them.");
 
-  yield ex.uninit();
+  yield promiseRestartManager();
 });
 
--- a/browser/experiments/test/xpcshell/test_telemetry.js
+++ b/browser/experiments/test/xpcshell/test_telemetry.js
@@ -325,11 +325,11 @@ add_task(function* test_telemetryBasics(
   expectedLogLength += 1;
   log = TelemetryLog.entries();
   Assert.equal(log.length, expectedLogLength, "Telemetry log should have " + expectedLogLength + " entries.");
   checkEvent(log[log.length-1], TLOG.TERMINATION_KEY,
              [TLOG.TERMINATION.RECHECK, EXPERIMENT4_ID, "os"]);
 
   // Cleanup.
 
-  yield experiments.uninit();
+  yield promiseRestartManager();
   yield removeCacheFile();
 });