Bug 1257246: Update toolkit/mozapps/extensions for eslint 2. r=aswan
authorDave Townsend <dtownsend@oxymoronical.com>
Tue, 05 Apr 2016 11:32:12 -0700
changeset 316118 4a108098012bf930f133f5ef582f559671fc89b5
parent 316117 09680d0b42ac693951425f85c9279156a3bbf44a
child 316119 5e40adeb0332005944a6249befae7a33c4e811db
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1257246
milestone48.0a1
Bug 1257246: Update toolkit/mozapps/extensions for eslint 2. r=aswan Most of this is fixing functions that in some cases return a value but then can also run to completion without returning anything. ESLint 2 catches this where previous versions didn't. Unless there was an obvious other choice I just made these functions return undefined at the end which is effectively what already happens. MozReview-Commit-ID: CRpZy873GP6
toolkit/mozapps/extensions/AddonManager.jsm
toolkit/mozapps/extensions/addonManager.js
toolkit/mozapps/extensions/internal/AddonRepository.jsm
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/mozapps/extensions/nsBlocklistService.js
toolkit/mozapps/extensions/test/browser/browser_bug590347.js
toolkit/mozapps/extensions/test/mochitest/test_bug887098.html
toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -784,16 +784,17 @@ var AddonManagerInternal = {
     logger.debug(`Provider finished startup: ${providerName(aProvider)}`);
   },
 
   _getProviderByName(aName) {
     for (let provider of this.providers) {
       if (providerName(provider) == aName)
         return provider;
     }
+    return undefined;
   },
 
   /**
    * Initializes the AddonManager, loading any known providers and initializing
    * them.
    */
   startup: function() {
     try {
--- a/toolkit/mozapps/extensions/addonManager.js
+++ b/toolkit/mozapps/extensions/addonManager.js
@@ -170,16 +170,17 @@ amManager.prototype = {
           };
         }
 
         return this.installAddonsFromWebpage(payload.mimetype,
           aMessage.target, payload.triggeringPrincipal, payload.uris,
           payload.hashes, payload.names, payload.icons, callback);
       }
     }
+    return undefined;
   },
 
   classID: Components.ID("{4399533d-08d1-458c-a87a-235f74451cfa}"),
   _xpcom_factory: {
     createInstance: function(aOuter, aIid) {
       if (aOuter != null)
         throw Components.Exception("Component does not support aggregation",
                                    Cr.NS_ERROR_NO_AGGREGATION);
--- a/toolkit/mozapps/extensions/internal/AddonRepository.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonRepository.jsm
@@ -627,29 +627,31 @@ this.AddonRepository = {
       AddonManager.getAllAddons(resolve));
 
     // Filter the hotfix out of our list of add-ons
     allAddons = allAddons.filter(a => a.id != AddonManager.hotfixID);
 
     // Completely remove cache if caching is not enabled
     if (!this.cacheEnabled) {
       logger.debug("Clearing cache because it is disabled");
-      return this._clearCache();
+      yield this._clearCache();
+      return;
     }
 
     let ids = allAddons.map(a => a.id);
     logger.debug("Repopulate add-on cache with " + ids.toSource());
 
     let addonsToCache = yield new Promise((resolve, reject) =>
       getAddonsToCache(ids, resolve));
 
     // Completely remove cache if there are no add-ons to cache
     if (addonsToCache.length == 0) {
       logger.debug("Clearing cache because 0 add-ons were requested");
-      return this._clearCache();
+      yield this._clearCache();
+      return;
     }
 
     yield new Promise((resolve, reject) =>
       this._beginGetAddons(addonsToCache, {
         searchSucceeded: aAddons => {
           this._addons = new Map();
           for (let addon of aAddons) {
             this._addons.set(addon.id, addon);
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -2807,16 +2807,17 @@ this.XPIProvider = {
         }
       );
       return done;
     }
     else {
       logger.debug("Notifying XPI shutdown observers");
       Services.obs.notifyObservers(null, "xpi-provider-shutdown", null);
     }
+    return undefined;
   },
 
   /**
    * Applies any pending theme change to the preferences.
    */
   applyThemeChange: function() {
     if (!Preferences.get(PREF_DSS_SWITCHPENDING, false))
       return;
@@ -2901,36 +2902,39 @@ this.XPIProvider = {
     // Ensure any changes to the add-ons list are flushed to disk
     Services.prefs.setBoolPref(PREF_PENDING_OPERATIONS,
                                !XPIDatabase.writeAddonsList());
   },
 
   updateSystemAddons: Task.async(function*() {
     let systemAddonLocation = XPIProvider.installLocationsByName[KEY_APP_SYSTEM_ADDONS];
     if (!systemAddonLocation)
-      return undefined;
+      return;
 
     // Don't do anything in safe mode
     if (Services.appinfo.inSafeMode)
-      return undefined;
+      return;
 
     // Download the list of system add-ons
     let url = Preferences.get(PREF_SYSTEM_ADDON_UPDATE_URL, null);
-    if (!url)
-      return systemAddonLocation.cleanDirectories();
+    if (!url) {
+      yield systemAddonLocation.cleanDirectories();
+      return;
+    }
 
     url = UpdateUtils.formatUpdateURL(url);
 
     logger.info(`Starting system add-on update check from ${url}.`);
     let addonList = yield ProductAddonChecker.getProductAddonList(url);
 
     // If there was no list then do nothing.
     if (!addonList) {
       logger.info("No system add-ons list was returned.");
-      return systemAddonLocation.cleanDirectories();
+      yield systemAddonLocation.cleanDirectories();
+      return;
     }
 
     addonList = new Map(
       addonList.map(spec => [spec.id, { spec, path: null, addon: null }]));
 
     let getAddonsInLocation = (location) => {
       return new Promise(resolve => {
         XPIDatabase.getAddonsInLocation(location, resolve);
@@ -2952,26 +2956,28 @@ this.XPIProvider = {
 
       return true;
     };
 
     // If this matches the current set in the profile location then do nothing.
     let updatedAddons = addonMap(yield getAddonsInLocation(KEY_APP_SYSTEM_ADDONS));
     if (setMatches(addonList, updatedAddons)) {
       logger.info("Retaining existing updated system add-ons.");
-      return systemAddonLocation.cleanDirectories();
+      yield systemAddonLocation.cleanDirectories();
+      return;
     }
 
     // If this matches the current set in the default location then reset the
     // updated set.
     let defaultAddons = addonMap(yield getAddonsInLocation(KEY_APP_SYSTEM_DEFAULTS));
     if (setMatches(addonList, defaultAddons)) {
       logger.info("Resetting system add-ons.");
       systemAddonLocation.resetAddonSet();
-      return systemAddonLocation.cleanDirectories();
+      yield systemAddonLocation.cleanDirectories();
+      return;
     }
 
     // Download all the add-ons
     // Bug 1204158: If we already have some of these locally then just use those
     let downloadAddon = Task.async(function*(item) {
       try {
         let sourceAddon = updatedAddons.get(item.spec.id);
         if (sourceAddon && sourceAddon.version == item.spec.version) {
@@ -5631,16 +5637,17 @@ AddonInstall.prototype = {
     }
 
     this.addon._repositoryAddon = repoAddon;
     this.name = this.name || this.addon._repositoryAddon.name;
     this.addon.compatibilityOverrides = repoAddon ?
                                     repoAddon.compatibilityOverrides :
                                     null;
     this.addon.appDisabled = !isUsableAddon(this.addon);
+    return undefined;
   }),
 
   observe: function(aSubject, aTopic, aData) {
     // Network is going offline
     this.cancel();
   },
 
   /**
@@ -7383,18 +7390,19 @@ PROP_LOCALE_SINGLE.forEach(function(aPro
         let value = Preferences.get(pref, null, Ci.nsIPrefLocalizedString);
         if (value)
           result = value;
       }
       catch (e) {
       }
     }
 
+    let rest;
     if (result == null)
-      [result, ] = chooseValue(addon, addon.selectedLocale, aProp);
+      [result, ...rest] = chooseValue(addon, addon.selectedLocale, aProp);
 
     if (aProp == "creator")
       return result ? new AddonManagerPrivate.AddonAuthor(result) : null;
 
     return result;
   });
 });
 
--- a/toolkit/mozapps/extensions/nsBlocklistService.js
+++ b/toolkit/mozapps/extensions/nsBlocklistService.js
@@ -375,16 +375,17 @@ Blocklist.prototype = {
                                             aMsg.data.appVersion,
                                             aMsg.data.toolkitVersion);
       case "Blocklist:content-blocklist-updated":
         Services.obs.notifyObservers(null, "content-blocklist-updated", null);
         break;
       default:
         throw new Error("Unknown blocklist message received from content: " + aMsg.name);
     }
+    return undefined;
   },
 
   /* See nsIBlocklistService */
   isAddonBlocklisted: function(addon, appVersion, toolkitVersion) {
     return this.getAddonBlocklistState(addon, appVersion, toolkitVersion) ==
                    Ci.nsIBlocklistService.STATE_BLOCKED;
   },
 
--- a/toolkit/mozapps/extensions/test/browser/browser_bug590347.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug590347.js
@@ -46,16 +46,17 @@ function get_list_view_warning_node() {
   }
   ok(found, "Test add-on node should have been found.");
   return item.ownerDocument.getAnonymousElementByAttribute(item, "anonid", "warning");
 }
 
 function get_detail_view_warning_node(aManagerWindow) {
   if(aManagerWindow)
     return aManagerWindow.document.getElementById("detail-warning");
+  return undefined;
 }
 
 function test() {
   waitForExplicitFinish();
 
   gProvider = new MockProvider();
 
   gProvider.createAddons([{
--- a/toolkit/mozapps/extensions/test/mochitest/test_bug887098.html
+++ b/toolkit/mozapps/extensions/test/mochitest/test_bug887098.html
@@ -7,16 +7,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <meta charset="utf-8">
   <title>Test for Bug 887098</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
 
   /** Test for Bug 887098 **/
   SimpleTest.waitForExplicitFinish();
+  /* globals $,evalRef */
 
   function loaded() {
     var iwin = $('ifr').contentWindow;
     var href = SpecialPowers.wrap(iwin).location.href;
     if (/file_empty/.test(href)) {
       window.evalRef = iwin.eval;
       window.installTriggerRef = iwin.InstallTrigger; // Force lazy instantiation.
       // about: is privileged, so we need to be privileged to load it.
--- a/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js
@@ -10,16 +10,17 @@ function mockAddonProvider(name) {
     shutdownCallback: null,
 
     startup() { },
     shutdown() {
       this.hasShutdown = true;
       shutdownOrder.push(this.name);
       if (this.shutdownCallback)
         return this.shutdownCallback();
+      return undefined;
     },
     getAddonByID(id, callback) {
       if (this.hasShutdown) {
         this.unsafeAccess = true;
       }
       callback(null);
     },