Bug 1252871 - Move and sort methods imported from AddonTestUtils r=aswan
☠☠ backed out by c2b23c06acfe ☠ ☠
authorMatthew Wein <mwein@mozilla.com>
Mon, 26 Sep 2016 10:36:51 -0700
changeset 320052 9c2c3780aa4c599699b7bc87ef15566cadc8ccf0
parent 320051 5cb98008b3e36900ae4e786052d945c1001cb488
child 320053 c2a511511a72010f07159a768a268c53e3090389
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1252871
milestone52.0a1
Bug 1252871 - Move and sort methods imported from AddonTestUtils r=aswan MozReview-Commit-ID: EvffSUxQkWQ
toolkit/mozapps/extensions/test/xpcshell/head_addons.js
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
@@ -51,16 +51,43 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource://testing-common/httpd.js");
 XPCOMUtils.defineLazyModuleGetter(this, "MockAsyncShutdown",
                                   "resource://testing-common/AddonTestUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "MockRegistrar",
                                   "resource://testing-common/MockRegistrar.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "MockRegistry",
                                   "resource://testing-common/MockRegistry.jsm");
 
+const {
+  awaitPromise,
+  createAppInfo,
+  createInstallRDF,
+  createTempWebExtensionFile,
+  createUpdateRDF,
+  getFileForAddon,
+  manuallyInstall,
+  manuallyUninstall,
+  promiseAddonByID,
+  promiseAddonEvent,
+  promiseAddonsByIDs,
+  promiseAddonsWithOperationsByTypes,
+  promiseCompleteAllInstalls,
+  promiseConsoleOutput,
+  promiseInstallAllFiles,
+  promiseInstallFile,
+  promiseRestartManager,
+  promiseSetExtensionModifiedTime,
+  promiseShutdownManager,
+  promiseStartupManager,
+  promiseWriteProxyFileToDir,
+  registerDirectory,
+  setExtensionModifiedTime,
+  writeFilesToZip
+} = AddonTestUtils;
+
 // WebExtension wrapper for ease of testing
 ExtensionTestUtils.init(this);
 
 AddonTestUtils.init(this);
 AddonTestUtils.overrideCertDB();
 
 Object.defineProperty(this, "gAppInfo", {
   get() {
@@ -311,18 +338,16 @@ function isNightlyChannel() {
   try {
     channel = Services.prefs.getCharPref("app.update.channel");
   }
   catch (e) { }
 
   return channel != "aurora" && channel != "beta" && channel != "release" && channel != "esr";
 }
 
-var {createAppInfo} = AddonTestUtils;
-
 /**
  * Tests that an add-on does appear in the crash report annotations, if
  * crash reporting is enabled. The test will fail if the add-on is not in the
  * annotation.
  * @param  aId
  *         The ID of the add-on
  * @param  aVersion
  *         The version of the add-on
@@ -571,21 +596,16 @@ function do_check_compatibilityoverride(
 }
 
 function do_check_icons(aActual, aExpected) {
   for (var size in aExpected) {
     do_check_eq(remove_port(aActual[size]), remove_port(aExpected[size]));
   }
 }
 
-var {promiseStartupManager} = AddonTestUtils;
-var {promiseRestartManager} = AddonTestUtils;
-var {promiseShutdownManager} = AddonTestUtils;
-var {awaitPromise} = AddonTestUtils;
-
 function startupManager(aAppChanged) {
   promiseStartupManager(aAppChanged);
 }
 
 /**
  * Restarts the add-on manager as if the host application was restarted.
  *
  * @param  aNewVersion
@@ -618,19 +638,16 @@ function check_startup_changes(aType, aI
   ids.sort();
   var changes = AddonManager.getStartupChanges(aType);
   changes = changes.filter(aEl => /@tests.mozilla.org$/.test(aEl));
   changes.sort();
 
   do_check_eq(JSON.stringify(ids), JSON.stringify(changes));
 }
 
-var {createUpdateRDF} = AddonTestUtils;
-var {createInstallRDF} = AddonTestUtils;
-
 /**
  * Writes an install.rdf manifest into a directory using the properties passed
  * in a JS object. The objects should contain a property for each property to
  * appear in the RDF. The object may contain an array of objects with id,
  * minVersion and maxVersion in the targetApplications property to give target
  * application compatibility.
  *
  * @param   aData
@@ -730,18 +747,16 @@ function writeInstallRDFForExtension(aDa
  */
 function promiseWriteWebManifestForExtension(aData, aDir, aId = aData.applications.gecko.id) {
   let files = {
     "manifest.json": JSON.stringify(aData),
   }
   return AddonTestUtils.promiseWriteFilesToExtension(aDir.path, aId, files);
 }
 
-var {writeFilesToZip} = AddonTestUtils;
-
 /**
  * Creates an XPI file for some manifest data in the temporary directory and
  * returns the nsIFile for it. The file will be deleted when the test completes.
  *
  * @param   aData
  *          The object holding data about the add-on
  * @return  A file pointing to the created XPI file
  */
@@ -752,28 +767,16 @@ function createTempXPIFile(aData, aExtra
   if (typeof aExtraFile == "object")
     Object.assign(files, aExtraFile);
   else if (aExtraFile)
     files[aExtraFile] = "";
 
   return AddonTestUtils.createTempXPIFile(files);
 }
 
-var {createTempWebExtensionFile} = AddonTestUtils;
-
-var {setExtensionModifiedTime} = AddonTestUtils;
-var {promiseSetExtensionModifiedTime} = AddonTestUtils;
-
-var {manuallyInstall} = AddonTestUtils;
-var {manuallyUninstall} = AddonTestUtils;
-
-var {getFileForAddon} = AddonTestUtils;
-
-var {registerDirectory} = AddonTestUtils;
-
 var gExpectedEvents = {};
 var gExpectedInstalls = [];
 var gNext = null;
 
 function getExpectedEvent(aId) {
   if (!(aId in gExpectedEvents))
     do_throw("Wasn't expecting events for " + aId);
   if (gExpectedEvents[aId].length == 0)
@@ -1014,35 +1017,29 @@ function ensure_test_completed() {
     if (gExpectedEvents[i].length > 0)
       do_throw("Didn't see all the expected events for " + i);
   }
   gExpectedEvents = {};
   if (gExpectedInstalls)
     do_check_eq(gExpectedInstalls.length, 0);
 }
 
-var {promiseAddonEvent} = AddonTestUtils;
-
-var {promiseCompleteAllInstalls} = AddonTestUtils;
-
 /**
  * A helper method to install an array of AddonInstall to completion and then
  * call a provided callback.
  *
  * @param   aInstalls
  *          The array of AddonInstalls to install
  * @param   aCallback
  *          The callback to call when all installs have finished
  */
 function completeAllInstalls(aInstalls, aCallback) {
   promiseCompleteAllInstalls(aInstalls).then(aCallback);
 }
 
-var {promiseInstallFile, promiseInstallAllFiles} = AddonTestUtils;
-
 /**
  * A helper method to install an array of files and call a callback after the
  * installs are completed.
  *
  * @param   aFiles
  *          The array of files to install
  * @param   aCallback
  *          The callback to call when all installs have finished
@@ -1269,22 +1266,16 @@ function saveJSON(aData, aFile) {
 function callback_soon(aFunction) {
   return function(...args) {
     do_execute_soon(function() {
       aFunction.apply(null, args);
     }, aFunction.name ? "delayed callback " + aFunction.name : "delayed callback");
   }
 }
 
-var {promiseAddonsByIDs} = AddonTestUtils;
-
-var {promiseAddonByID} = AddonTestUtils;
-
-var {promiseAddonsWithOperationsByTypes} = AddonTestUtils;
-
 /**
  * Returns a promise that will be resolved when an add-on update check is
  * complete. The value resolved will be an AddonInstall if a new version was
  * found.
  */
 function promiseFindAddonUpdates(addon, reason = AddonManager.UPDATE_WHEN_PERIODIC_UPDATE) {
   return new Promise((resolve, reject) => {
     let result = {};
@@ -1329,19 +1320,15 @@ function promiseFindAddonUpdates(addon, 
           result.error = error;
           reject(result);
         }
       }
     }, reason);
   });
 }
 
-var {promiseConsoleOutput} = AddonTestUtils;
-
-var {promiseWriteProxyFileToDir} = AddonTestUtils;
-
 function writeProxyFileToDir(aDir, aAddon, aId) {
   awaitPromise(promiseWriteProxyFileToDir(aDir, aAddon, aId));
 
   let file = aDir.clone();
   file.append(aId);
   return file
 }