Bug 1294811: Fix external tests that import head_addons.js. r?rhelmer draft
authorKris Maglione <maglione.k@gmail.com>
Tue, 16 Aug 2016 17:02:44 -0700
changeset 401943 ec810d830ba95c1d7ccfb8fdf86e99607e8f0fce
parent 401942 2eb3211068da7e93ea1bc2b4a5eac611c6243eb9
child 528612 0b2c12e2b5049d9c7d12f4c73343245b71393812
push id26591
push usermaglione.k@gmail.com
push dateWed, 17 Aug 2016 20:16:11 +0000
reviewersrhelmer
bugs1294811
milestone51.0a1
Bug 1294811: Fix external tests that import head_addons.js. r?rhelmer MozReview-Commit-ID: EWo7Gv9oSsz
browser/experiments/test/xpcshell/head.js
browser/experiments/test/xpcshell/test_api.js
browser/experiments/test/xpcshell/test_telemetry.js
toolkit/components/telemetry/tests/unit/head.js
toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
toolkit/components/telemetry/tests/unit/test_TelemetryTimestamps.js
toolkit/mozapps/extensions/test/AddonManagerTesting.jsm
toolkit/mozapps/extensions/test/browser/browser_experiments.js
--- a/browser/experiments/test/xpcshell/head.js
+++ b/browser/experiments/test/xpcshell/head.js
@@ -4,16 +4,20 @@
 var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Promise.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
 Cu.import("resource://gre/modules/osfile.jsm");
 Cu.import("resource://testing-common/AddonManagerTesting.jsm");
+Cu.import("resource://testing-common/AddonTestUtils.jsm");
+
+XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
+                                  "resource://gre/modules/AddonManager.jsm");
 
 const PREF_EXPERIMENTS_ENABLED  = "experiments.enabled";
 const PREF_LOGGING_LEVEL        = "experiments.logging.level";
 const PREF_LOGGING_DUMP         = "experiments.logging.dump";
 const PREF_MANIFEST_URI         = "experiments.manifest.uri";
 const PREF_FETCHINTERVAL        = "experiments.manifest.fetchIntervalSeconds";
 const PREF_TELEMETRY_ENABLED    = "toolkit.telemetry.enabled";
 
@@ -122,26 +126,26 @@ function futureDate(date, offset) {
 }
 
 function dateToSeconds(date) {
   return date.getTime() / 1000;
 }
 
 var gGlobalScope = this;
 function loadAddonManager() {
-  let ns = {};
-  Cu.import("resource://gre/modules/Services.jsm", ns);
-  let head = "../../../../toolkit/mozapps/extensions/test/xpcshell/head_addons.js";
-  let file = do_get_file(head);
-  let uri = ns.Services.io.newFileURI(file);
-  ns.Services.scriptloader.loadSubScript(uri.spec, gGlobalScope);
+  AddonTestUtils.init(gGlobalScope);
+  AddonTestUtils.overrideCertDB();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-  startupManager();
+  return AddonTestUtils.promiseStartupManager();
 }
 
+const {
+  promiseRestartManager,
+} = AddonTestUtils;
+
 // Starts the addon manager without creating app info. We can't directly use
 // |loadAddonManager| defined above in test_conditions.js as it would make the test fail.
 function startAddonManagerOnly() {
   let addonManager = Cc["@mozilla.org/addons/integration;1"]
                        .getService(Ci.nsIObserver)
                        .QueryInterface(Ci.nsITimerCallback);
   addonManager.observe(null, "addons-startup", null);
 }
@@ -157,23 +161,18 @@ function getExperimentAddons(previous=fa
     }
   });
 
   return deferred.promise;
 }
 
 function createAppInfo(ID="xpcshell@tests.mozilla.org", name="XPCShell",
                        version="1.0", platformVersion="1.0") {
-  let tmp = {};
-  Cu.import("resource://testing-common/AppInfo.jsm", tmp);
-  tmp.updateAppInfo({
-    ID, name, version, platformVersion,
-    crashReporter: true,
-  });
-  gAppInfo = tmp.getAppInfo();
+  AddonTestUtils.createAppInfo(ID, name, version, platformVersion);
+  gAppInfo = AddonTestUtils.appInfo;
 }
 
 /**
  * Replace the experiments on an Experiments with a new list.
  *
  * This monkeypatches getExperiments(). It doesn't monkeypatch the internal
  * experiments list. So its utility is not as great as it could be.
  */
--- a/browser/experiments/test/xpcshell/test_api.js
+++ b/browser/experiments/test/xpcshell/test_api.js
@@ -23,17 +23,17 @@ var gPolicy              = null;
 var gManifestObject      = null;
 var gManifestHandlerURI  = null;
 var gTimerScheduleOffset = -1;
 
 function uninstallExperimentAddons() {
   return Task.spawn(function* () {
     let addons = yield getExperimentAddons();
     for (let a of addons) {
-      yield AddonTestUtils.uninstallAddonByID(a.id);
+      yield AddonManagerTesting.uninstallAddonByID(a.id);
     }
   });
 }
 
 function testCleanup(experimentsInstance) {
   return Task.spawn(function* () {
     yield promiseRestartManager();
     yield uninstallExperimentAddons();
@@ -407,17 +407,17 @@ add_task(function* test_addonAlreadyInst
   Assert.equal(list[0].id, EXPERIMENT1_ID, "Experiment 1 should be the sole entry.");
   Assert.equal(list[0].active, true, "Experiment 1 should be active.");
 
   let addons = yield getExperimentAddons();
   Assert.equal(addons.length, 1, "1 add-on is installed.");
 
   // Install conflicting addon.
 
-  yield AddonTestUtils.installXPIFromURL(gDataRoot + EXPERIMENT1_XPI_NAME, EXPERIMENT1_XPI_SHA1);
+  yield AddonManagerTesting.installXPIFromURL(gDataRoot + EXPERIMENT1_XPI_NAME, EXPERIMENT1_XPI_SHA1);
   addons = yield getExperimentAddons();
   Assert.equal(addons.length, 1, "1 add-on is installed.");
   list = yield experiments.getExperiments();
   Assert.equal(list.length, 1, "Experiment list should still have 1 entry.");
   Assert.equal(list[0].id, EXPERIMENT1_ID, "Experiment 1 should be the sole entry.");
   Assert.equal(list[0].active, true, "Experiment 1 should be active.");
 
   // Cleanup.
@@ -1402,17 +1402,17 @@ add_task(function* test_unexpectedUninst
   list = yield experiments.getExperiments();
   Assert.equal(list.length, 1, "Experiment list should have 1 entry now.");
   Assert.equal(list[0].id, EXPERIMENT1_ID, "Experiment 1 should be the sole entry.");
   Assert.equal(list[0].active, true, "Experiment 1 should be active.");
 
   // Uninstall the addon through the addon manager instead of stopping it through
   // the experiments API.
 
-  yield AddonTestUtils.uninstallAddonByID(EXPERIMENT1_ID);
+  yield AddonManagerTesting.uninstallAddonByID(EXPERIMENT1_ID);
   yield experiments._mainTask;
 
   yield experiments.notify();
 
   list = yield experiments.getExperiments();
   Assert.equal(list.length, 1, "Experiment list should have 1 entry now.");
   Assert.equal(list[0].id, EXPERIMENT1_ID, "Experiment 1 should be the sole entry.");
   Assert.equal(list[0].active, false, "Experiment 1 should not be active anymore.");
@@ -1428,17 +1428,17 @@ add_task(function* test_unexpectedUninst
 add_task(function* testUnknownExperimentsUninstalled() {
   let experiments = new Experiments.Experiments(gPolicy);
 
   let addons = yield getExperimentAddons();
   Assert.equal(addons.length, 0, "Precondition: No experiment add-ons are present.");
 
   // Simulate us not listening.
   experiments._unregisterWithAddonManager();
-  yield AddonTestUtils.installXPIFromURL(gDataRoot + EXPERIMENT1_XPI_NAME, EXPERIMENT1_XPI_SHA1);
+  yield AddonManagerTesting.installXPIFromURL(gDataRoot + EXPERIMENT1_XPI_NAME, EXPERIMENT1_XPI_SHA1);
   experiments._registerWithAddonManager();
 
   addons = yield getExperimentAddons();
   Assert.equal(addons.length, 1, "Experiment 1 installed via AddonManager");
 
   // Simulate no known experiments.
   gManifestObject = {
     "version": 1,
@@ -1467,17 +1467,17 @@ add_task(function* testForeignExperiment
 
   yield experiments.init();
 
   let addons = yield getExperimentAddons();
   Assert.equal(addons.length, 0, "Precondition: No experiment add-ons present.");
 
   let failed = false;
   try {
-    yield AddonTestUtils.installXPIFromURL(gDataRoot + EXPERIMENT1_XPI_NAME, EXPERIMENT1_XPI_SHA1);
+    yield AddonManagerTesting.installXPIFromURL(gDataRoot + EXPERIMENT1_XPI_NAME, EXPERIMENT1_XPI_SHA1);
   } catch (ex) {
     failed = true;
   }
   Assert.ok(failed, "Add-on install should not have completed successfully");
   addons = yield getExperimentAddons();
   Assert.equal(addons.length, 0, "Add-on install should have been cancelled.");
 
   yield testCleanup(experiments);
@@ -1617,17 +1617,17 @@ add_task(function* test_foreignUninstall
   yield experiments.updateManifest();
   let experimentList = yield experiments.getExperiments();
   Assert.equal(experimentList.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.");
 
-  yield AddonTestUtils.uninstallAddonByID(EXPERIMENT1_ID);
+  yield AddonManagerTesting.uninstallAddonByID(EXPERIMENT1_ID);
   yield experiments._mainTask;
 
   addons = yield getExperimentAddons();
   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.");
--- a/browser/experiments/test/xpcshell/test_telemetry.js
+++ b/browser/experiments/test/xpcshell/test_telemetry.js
@@ -20,28 +20,16 @@ var gHttpServer          = null;
 var gHttpRoot            = null;
 var gDataRoot            = null;
 var gPolicy              = null;
 var gManifestObject      = null;
 var gManifestHandlerURI  = null;
 
 const TLOG = bsp.TELEMETRY_LOG;
 
-var gGlobalScope = this;
-function loadAddonManager() {
-  let ns = {};
-  Cu.import("resource://gre/modules/Services.jsm", ns);
-  let head = "../../../../toolkit/mozapps/extensions/test/xpcshell/head_addons.js";
-  let file = do_get_file(head);
-  let uri = ns.Services.io.newFileURI(file);
-  ns.Services.scriptloader.loadSubScript(uri.spec, gGlobalScope);
-  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-  startupManager();
-}
-
 function checkEvent(event, id, data)
 {
   do_print("Checking message " + id);
   Assert.equal(event[0], id, "id should match");
   Assert.ok(event[1] > 0, "timestamp should be greater than 0");
 
   if (data === undefined) {
    Assert.equal(event.length, 2, "event array should have 2 entries");
--- a/toolkit/components/telemetry/tests/unit/head.js
+++ b/toolkit/components/telemetry/tests/unit/head.js
@@ -2,19 +2,26 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 var { classes: Cc, utils: Cu, interfaces: Ci, results: Cr } = Components;
 
 Cu.import("resource://gre/modules/TelemetryController.jsm", this);
 Cu.import("resource://gre/modules/Services.jsm", this);
 Cu.import("resource://gre/modules/PromiseUtils.jsm", this);
 Cu.import("resource://gre/modules/Task.jsm", this);
+Cu.import("resource://gre/modules/FileUtils.jsm", this);
+Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
 Cu.import("resource://testing-common/httpd.js", this);
 Cu.import("resource://gre/modules/AppConstants.jsm");
 
+XPCOMUtils.defineLazyModuleGetter(this, "AddonTestUtils",
+                                  "resource://testing-common/AddonTestUtils.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "OS",
+                                  "resource://gre/modules/osfile.jsm");
+
 const gIsWindows = AppConstants.platform == "win";
 const gIsMac = AppConstants.platform == "macosx";
 const gIsAndroid = AppConstants.platform == "android";
 const gIsGonk = AppConstants.platform == "gonk";
 const gIsLinux = AppConstants.platform == "linux";
 
 const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
 
@@ -155,41 +162,34 @@ function wrapWithExceptionHandler(f) {
       dump("Caught exception: " + ex.message + "\n");
       dump(ex.stack);
       do_test_finished();
     }
   }
   return wrapper;
 }
 
-function loadAddonManager(ID, name, version, platformVersion) {
-  let ns = {};
-  Cu.import("resource://gre/modules/Services.jsm", ns);
-  let head = "../../../../mozapps/extensions/test/xpcshell/head_addons.js";
-  let file = do_get_file(head);
-  let uri = ns.Services.io.newFileURI(file);
-  ns.Services.scriptloader.loadSubScript(uri.spec, gGlobalScope);
-  createAppInfo(ID, name, version, platformVersion);
+function loadAddonManager(...args) {
+  AddonTestUtils.init(gGlobalScope);
+  AddonTestUtils.overrideCertDB();
+  createAppInfo(...args);
+
   // As we're not running in application, we need to setup the features directory
   // used by system add-ons.
   const distroDir = FileUtils.getDir("ProfD", ["sysfeatures", "app0"], true);
-  registerDirectory("XREAppFeat", distroDir);
-  startupManager();
+  AddonTestUtils.registerDirectory("XREAppFeat", distroDir);
+  return AddonTestUtils.promiseStartupManager();
 }
 
 var gAppInfo = null;
 
-function createAppInfo(ID, name, version, platformVersion) {
-  let tmp = {};
-  Cu.import("resource://testing-common/AppInfo.jsm", tmp);
-  tmp.updateAppInfo({
-    ID, name, version, platformVersion,
-    crashReporter: true,
-  });
-  gAppInfo = tmp.getAppInfo();
+function createAppInfo(ID="xpcshell@tests.mozilla.org", name="XPCShell",
+                       version="1.0", platformVersion="1.0") {
+  AddonTestUtils.createAppInfo(ID, name, version, platformVersion);
+  gAppInfo = AddonTestUtils.appInfo;
 }
 
 // Fake the timeout functions for the TelemetryScheduler.
 function fakeSchedulerTimer(set, clear) {
   let session = Cu.import("resource://gre/modules/TelemetrySession.jsm");
   session.Policy.setSchedulerTickTimeout = set;
   session.Policy.clearSchedulerTickTimeout = clear;
 }
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
@@ -902,36 +902,36 @@ add_task(function* test_addonsWatch_Inte
 
   let assertCheckpoint = (aExpected) => {
     Assert.equal(receivedNotifications, aExpected);
     TelemetryEnvironment.unregisterChangeListener("testWatchAddons_Changes" + aExpected);
   };
 
   // Test for receiving one notification after each change.
   let checkpointPromise = registerCheckpointPromise(1);
-  yield AddonTestUtils.installXPIFromURL(ADDON_INSTALL_URL);
+  yield AddonManagerTesting.installXPIFromURL(ADDON_INSTALL_URL);
   yield checkpointPromise;
   assertCheckpoint(1);
   Assert.ok(ADDON_ID in TelemetryEnvironment.currentEnvironment.addons.activeAddons);
 
   checkpointPromise = registerCheckpointPromise(2);
-  let addon = yield AddonTestUtils.getAddonById(ADDON_ID);
+  let addon = yield AddonManagerTesting.getAddonById(ADDON_ID);
   addon.userDisabled = true;
   yield checkpointPromise;
   assertCheckpoint(2);
   Assert.ok(!(ADDON_ID in TelemetryEnvironment.currentEnvironment.addons.activeAddons));
 
   checkpointPromise = registerCheckpointPromise(3);
   addon.userDisabled = false;
   yield checkpointPromise;
   assertCheckpoint(3);
   Assert.ok(ADDON_ID in TelemetryEnvironment.currentEnvironment.addons.activeAddons);
 
   checkpointPromise = registerCheckpointPromise(4);
-  yield AddonTestUtils.uninstallAddonByID(ADDON_ID);
+  yield AddonManagerTesting.uninstallAddonByID(ADDON_ID);
   yield checkpointPromise;
   assertCheckpoint(4);
   Assert.ok(!(ADDON_ID in TelemetryEnvironment.currentEnvironment.addons.activeAddons));
 
   Assert.equal(receivedNotifications, EXPECTED_NOTIFICATIONS,
                "We must only receive the notifications we expect.");
 });
 
@@ -1012,18 +1012,18 @@ add_task(function* test_addonsWatch_NotI
   let deferred = PromiseUtils.defer();
   TelemetryEnvironment.registerChangeListener("testNotInteresting",
     () => {
       Assert.ok(!receivedNotification, "Should not receive multiple notifications");
       receivedNotification = true;
       deferred.resolve();
     });
 
-  yield AddonTestUtils.installXPIFromURL(DICTIONARY_ADDON_INSTALL_URL);
-  yield AddonTestUtils.installXPIFromURL(INTERESTING_ADDON_INSTALL_URL);
+  yield AddonManagerTesting.installXPIFromURL(DICTIONARY_ADDON_INSTALL_URL);
+  yield AddonManagerTesting.installXPIFromURL(INTERESTING_ADDON_INSTALL_URL);
 
   yield deferred.promise;
   Assert.ok(!("telemetry-dictionary@tests.mozilla.org" in
               TelemetryEnvironment.currentEnvironment.addons.activeAddons),
             "Dictionaries should not appear in active addons.");
 
   TelemetryEnvironment.unregisterChangeListener("testNotInteresting");
 });
@@ -1071,17 +1071,17 @@ add_task(function* test_addonsAndPlugins
     version: FLASH_PLUGIN_VERSION,
     description: FLASH_PLUGIN_DESC,
     blocklisted: false,
     disabled: false,
     clicktoplay: true,
   };
 
   // Install an addon so we have some data.
-  yield AddonTestUtils.installXPIFromURL(ADDON_INSTALL_URL);
+  yield AddonManagerTesting.installXPIFromURL(ADDON_INSTALL_URL);
 
   let data = TelemetryEnvironment.currentEnvironment;
   checkEnvironmentData(data);
 
   // Check addon data.
   Assert.ok(ADDON_ID in data.addons.activeAddons, "We must have one active addon.");
   let targetAddon = data.addons.activeAddons[ADDON_ID];
   for (let f in EXPECTED_ADDON_DATA) {
@@ -1112,17 +1112,17 @@ add_task(function* test_addonsAndPlugins
   Assert.ok(targetPlugin.mimeTypes.find(m => m == PLUGIN_MIME_TYPE1));
   Assert.ok(targetPlugin.mimeTypes.find(m => m == PLUGIN_MIME_TYPE2));
   Assert.ok(!targetPlugin.mimeTypes.find(m => m == "Not There."));
 
   let personaId = (gIsGonk) ? null : PERSONA_ID;
   Assert.equal(data.addons.persona, personaId, "The correct Persona Id must be reported.");
 
   // Uninstall the addon.
-  yield AddonTestUtils.uninstallAddonByID(ADDON_ID);
+  yield AddonManagerTesting.uninstallAddonByID(ADDON_ID);
 });
 
 add_task(function* test_signedAddon() {
   const ADDON_INSTALL_URL = gDataRoot + "signed.xpi";
   const ADDON_ID = "tel-signed-xpi@tests.mozilla.org";
   const ADDON_INSTALL_DATE = truncateToDays(Date.now());
   const EXPECTED_ADDON_DATA = {
     blocklisted: false,
@@ -1141,17 +1141,17 @@ add_task(function* test_signedAddon() {
   };
 
   // Set the clock in the future so our changes don't get throttled.
   gNow = fakeNow(futureDate(gNow, 10 * MILLISECONDS_PER_MINUTE));
   let deferred = PromiseUtils.defer();
   TelemetryEnvironment.registerChangeListener("test_signedAddon", deferred.resolve);
 
   // Install the addon.
-  yield AddonTestUtils.installXPIFromURL(ADDON_INSTALL_URL);
+  yield AddonManagerTesting.installXPIFromURL(ADDON_INSTALL_URL);
 
   yield deferred.promise;
   // Unregister the listener.
   TelemetryEnvironment.unregisterChangeListener("test_signedAddon");
 
   let data = TelemetryEnvironment.currentEnvironment;
   checkEnvironmentData(data);
 
@@ -1168,17 +1168,17 @@ add_task(function* test_addonsFieldsLimi
   const ADDON_ID = "tel-longfields-xpi@tests.mozilla.org";
 
   // Set the clock in the future so our changes don't get throttled.
   gNow = fakeNow(futureDate(gNow, 10 * MILLISECONDS_PER_MINUTE));
 
   // Install the addon and wait for the TelemetryEnvironment to pick it up.
   let deferred = PromiseUtils.defer();
   TelemetryEnvironment.registerChangeListener("test_longFieldsAddon", deferred.resolve);
-  yield AddonTestUtils.installXPIFromURL(ADDON_INSTALL_URL);
+  yield AddonManagerTesting.installXPIFromURL(ADDON_INSTALL_URL);
   yield deferred.promise;
   TelemetryEnvironment.unregisterChangeListener("test_longFieldsAddon");
 
   let data = TelemetryEnvironment.currentEnvironment;
   checkEnvironmentData(data);
 
   // Check that the addon is available and that the string fields are limited.
   Assert.ok(ADDON_ID in data.addons.activeAddons, "Add-on should be in the environment.");
@@ -1250,17 +1250,17 @@ add_task(function* test_collectionWithbr
   brokenAddonProvider.addAddon(BROKEN_MANIFEST);
   yield checkpointPromise;
   assertCheckpoint(1);
 
   // Set the clock in the future so our changes don't get throttled.
   gNow = fakeNow(futureDate(gNow, 10 * MILLISECONDS_PER_MINUTE));
   // Now install an addon which returns the correct information.
   checkpointPromise = registerCheckpointPromise(2);
-  yield AddonTestUtils.installXPIFromURL(ADDON_INSTALL_URL);
+  yield AddonManagerTesting.installXPIFromURL(ADDON_INSTALL_URL);
   yield checkpointPromise;
   assertCheckpoint(2);
 
   // Check that the new environment contains the Social addon installed with the broken
   // manifest and the rest of the data.
   let data = TelemetryEnvironment.currentEnvironment;
   checkEnvironmentData(data, false, true /* expect broken addons*/);
 
@@ -1273,17 +1273,17 @@ add_task(function* test_collectionWithbr
             "The valid addon must be reported.");
   Assert.equal(activeAddons[ADDON_ID].description, EXPECTED_ADDON_DATA.description,
                "The description for the valid addon should be correct.");
 
   // Unregister the broken provider so we don't mess with other tests.
   AddonManagerPrivate.unregisterProvider(brokenAddonProvider);
 
   // Uninstall the valid addon.
-  yield AddonTestUtils.uninstallAddonByID(ADDON_ID);
+  yield AddonManagerTesting.uninstallAddonByID(ADDON_ID);
 });
 
 add_task(function* test_changeThrottling() {
   const PREF_TEST = "toolkit.telemetry.test.pref1";
   const PREFS_TO_WATCH = new Map([
     [PREF_TEST, {what: TelemetryEnvironment.RECORD_PREF_STATE}],
   ]);
   Preferences.reset(PREF_TEST);
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryTimestamps.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryTimestamps.js
@@ -11,26 +11,16 @@ Cu.import('resource://gre/modules/XPCOMU
 
 // The @mozilla/xre/app-info;1 XPCOM object provided by the xpcshell test harness doesn't
 // implement the nsIXULAppInfo interface, which is needed by Services.jsm and
 // TelemetrySession.jsm. updateAppInfo() creates and registers a minimal mock app-info.
 Cu.import("resource://testing-common/AppInfo.jsm");
 updateAppInfo();
 
 var gGlobalScope = this;
-function loadAddonManager() {
-  let ns = {};
-  Cu.import("resource://gre/modules/Services.jsm", ns);
-  let head = "../../../../mozapps/extensions/test/xpcshell/head_addons.js";
-  let file = do_get_file(head);
-  let uri = ns.Services.io.newFileURI(file);
-  ns.Services.scriptloader.loadSubScript(uri.spec, gGlobalScope);
-  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-  startupManager();
-}
 
 function getSimpleMeasurementsFromTelemetryController() {
   return TelemetrySession.getPayload().simpleMeasurements;
 }
 
 function initialiseTelemetry() {
   return TelemetryController.testSetup();
 }
--- a/toolkit/mozapps/extensions/test/AddonManagerTesting.jsm
+++ b/toolkit/mozapps/extensions/test/AddonManagerTesting.jsm
@@ -3,28 +3,28 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // This file is a test-only JSM containing utility methods for
 // interacting with the add-ons manager.
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = [
-  "AddonTestUtils",
+  "AddonManagerTesting",
 ];
 
 const {utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/Promise.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
                                   "resource://gre/modules/AddonManager.jsm");
 
-this.AddonTestUtils = {
+this.AddonManagerTesting = {
   /**
    * Get the add-on that is specified by its ID.
    *
    * @return {Promise<Object>} A promise that resolves returning the found addon or null
    *         if it is not found.
    */
   getAddonById: function (id) {
     return new Promise(resolve => AddonManager.getAddonByID(id, addon => resolve(addon)));
--- a/toolkit/mozapps/extensions/test/browser/browser_experiments.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_experiments.js
@@ -1,15 +1,15 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 Components.utils.import("resource://gre/modules/Promise.jsm", this);
 
-var {AddonTestUtils} = Components.utils.import("resource://testing-common/AddonManagerTesting.jsm", {});
+var {AddonManagerTesting} = Components.utils.import("resource://testing-common/AddonManagerTesting.jsm", {});
 var {HttpServer} = Components.utils.import("resource://testing-common/httpd.js", {});
 
 var gManagerWindow;
 var gCategoryUtilities;
 var gExperiments;
 var gHttpServer;
 
 var gSavedManifestURI;
@@ -249,17 +249,17 @@ add_task(function* testButtonPresence() 
   is_element_hidden(el, "Disable button not visible.");
   // Corresponds to lack of enable permission.
   el = item.ownerDocument.getAnonymousElementByAttribute(item, "anonid", "enable-btn");
   is_element_hidden(el, "Enable button not visible.");
 });
 
 // Remove the add-on we've been testing with.
 add_task(function* testCleanup() {
-  yield AddonTestUtils.uninstallAddonByID("test-experiment1@experiments.mozilla.org");
+  yield AddonManagerTesting.uninstallAddonByID("test-experiment1@experiments.mozilla.org");
   // Verify some conditions, just in case.
   let addons = yield getExperimentAddons();
   Assert.equal(addons.length, 0, "No experiment add-ons are installed.");
 });
 
 // The following tests should ideally live in browser/experiments/. However,
 // they rely on some of the helper functions from head.js, which can't easily
 // be consumed from other directories. So, they live here.