Bug 1226386: Switch to fat arrow functions where it makes sense. r=rhelmer
authorDave Townsend <dtownsend@oxymoronical.com>
Fri, 20 Nov 2015 10:06:14 -0800
changeset 308815 0fb853fdfcc8dc55bc7351d521ed2662aead3af4
parent 308814 067cde34cbadeec62ccbec0b2d24b2e4f4f83f9f
child 308816 1462234985f0243b2933f9ef216ef81482a76eab
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhelmer
bugs1226386
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1226386: Switch to fat arrow functions where it makes sense. r=rhelmer Both for brevity and to remove the use of |self = this|.
toolkit/mozapps/extensions/AddonManager.jsm
toolkit/mozapps/extensions/ChromeManifestParser.jsm
toolkit/mozapps/extensions/LightweightThemeManager.jsm
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/content/extensions.xml
toolkit/mozapps/extensions/internal/AddonRepository.jsm
toolkit/mozapps/extensions/internal/AddonRepository_SQLiteMigrator.jsm
toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm
toolkit/mozapps/extensions/internal/GMPProvider.jsm
toolkit/mozapps/extensions/internal/PluginProvider.jsm
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/mozapps/extensions/nsBlocklistService.js
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -1071,21 +1071,18 @@ var AddonManagerInternal = {
           }
 
           this.types[aType.id] = {
             type: aType,
             providers: [aProvider]
           };
 
           let typeListeners = this.typeListeners.slice(0);
-          for (let listener of typeListeners) {
-            safeCall(function() {
-              listener.onTypeAdded(aType);
-            });
-          }
+          for (let listener of typeListeners)
+            safeCall(() => listener.onTypeAdded(aType));
         }
         else {
           this.types[aType.id].providers.push(aProvider);
         }
       }, this);
     }
 
     // If we're registering after startup call this provider's startup.
@@ -1116,21 +1113,18 @@ var AddonManagerInternal = {
 
     for (let type in this.types) {
       this.types[type].providers = this.types[type].providers.filter(p => p != aProvider);
       if (this.types[type].providers.length == 0) {
         let oldType = this.types[type].type;
         delete this.types[type];
 
         let typeListeners = this.typeListeners.slice(0);
-        for (let listener of typeListeners) {
-          safeCall(function() {
-            listener.onTypeRemoved(oldType);
-          });
-        }
+        for (let listener of typeListeners)
+          safeCall(() => listener.onTypeRemoved(oldType));
       }
     }
 
     // If we're unregistering after startup but before shutting down,
     // remove the blocker for this provider's shutdown and call it.
     // If we're already shutting down, just let gShutdownBarrier call it to avoid races.
     if (gStarted && !gShutdownInProgress) {
       logger.debug("Unregistering shutdown blocker for " + providerName(aProvider));
@@ -2201,19 +2195,18 @@ var AddonManagerInternal = {
                                  Cr.NS_ERROR_INVALID_ARG);
 
     if (!Array.isArray(aInstalls))
       throw Components.Exception("aInstalls must be an array",
                                  Cr.NS_ERROR_INVALID_ARG);
 
     if (!("@mozilla.org/addons/web-install-listener;1" in Cc)) {
       logger.warn("No web installer available, cancelling all installs");
-      aInstalls.forEach(function(aInstall) {
-        aInstall.cancel();
-      });
+      for (let install of aInstalls)
+        install.cancel();
       return;
     }
 
     // When a chrome in-content UI has loaded a <browser> inside to host a
     // website we want to do our security checks on the inner-browser but
     // notify front-end that install events came from the outer-browser (the
     // main tab's browser). Check this by seeing if the browser we've been
     // passed is in a content type docshell and if so get the outer-browser.
@@ -2251,36 +2244,33 @@ var AddonManagerInternal = {
       // The installs may start now depending on the web install listener,
       // listen for the browser navigating to a new origin and cancel the
       // installs in that case.
       new BrowserListener(aBrowser, aInstallingPrincipal, aInstalls);
 
       if (!this.isInstallAllowed(aMimetype, aInstallingPrincipal)) {
         if (weblistener.onWebInstallBlocked(topBrowser, aInstallingPrincipal.URI,
                                             aInstalls, aInstalls.length)) {
-          aInstalls.forEach(function(aInstall) {
-            aInstall.install();
-          });
+          for (let install of aInstalls)
+            install.install();
         }
       }
       else if (weblistener.onWebInstallRequested(topBrowser, aInstallingPrincipal.URI,
                                                  aInstalls, aInstalls.length)) {
-        aInstalls.forEach(function(aInstall) {
-          aInstall.install();
-        });
+        for (let install of aInstalls)
+          install.install();
       }
     }
     catch (e) {
       // In the event that the weblistener throws during instantiation or when
       // calling onWebInstallBlocked or onWebInstallRequested all of the
       // installs should get cancelled.
       logger.warn("Failure calling web installer", e);
-      aInstalls.forEach(function(aInstall) {
-        aInstall.cancel();
-      });
+      for (let install of aInstalls)
+        install.cancel();
     }
   },
 
   /**
    * Adds a new InstallListener if the listener is not already registered.
    *
    * @param  aListener
    *         The InstallListener to add
@@ -2607,18 +2597,17 @@ var AddonManagerInternal = {
    * @param  aListener
    *         The listener to add
    */
   addManagerListener: function(aListener) {
     if (!aListener || typeof aListener != "object")
       throw Components.Exception("aListener must be an AddonManagerListener object",
                                  Cr.NS_ERROR_INVALID_ARG);
 
-    if (!this.managerListeners.some(function(i) {
-      return i == aListener; }))
+    if (!this.managerListeners.some(i => i == aListener))
       this.managerListeners.push(aListener);
   },
 
   /**
    * Removes an AddonManagerListener if the listener is registered.
    *
    * @param  aListener
    *         The listener to remove
@@ -2643,18 +2632,17 @@ var AddonManagerInternal = {
    * @param  aListener
    *         The AddonListener to add
    */
   addAddonListener: function(aListener) {
     if (!aListener || typeof aListener != "object")
       throw Components.Exception("aListener must be an AddonListener object",
                                  Cr.NS_ERROR_INVALID_ARG);
 
-    if (!this.addonListeners.some(function(i) {
-      return i == aListener; }))
+    if (!this.addonListeners.some(i => i == aListener))
       this.addonListeners.push(aListener);
   },
 
   /**
    * Removes an AddonListener if the listener is registered.
    *
    * @param  aListener
    *         The AddonListener to remove
@@ -2679,18 +2667,17 @@ var AddonManagerInternal = {
    * @param  aListener
    *         The TypeListener to add
    */
   addTypeListener: function(aListener) {
     if (!aListener || typeof aListener != "object")
       throw Components.Exception("aListener must be a TypeListener object",
                                  Cr.NS_ERROR_INVALID_ARG);
 
-    if (!this.typeListeners.some(function(i) {
-      return i == aListener; }))
+    if (!this.typeListeners.some(i => i == aListener))
       this.typeListeners.push(aListener);
   },
 
   /**
    * Removes an TypeListener if the listener is registered.
    *
    * @param  aListener
    *         The TypeListener to remove
--- a/toolkit/mozapps/extensions/ChromeManifestParser.jsm
+++ b/toolkit/mozapps/extensions/ChromeManifestParser.jsm
@@ -147,13 +147,11 @@ this.ChromeManifestParser = {
   *
   * @param  aManifest
   *         Manifest data, as returned by ChromeManifestParser.parseSync().
   * @param  aType
   *         Instruction type to filter by.
   * @return True if any matching instructions were found in the manifest.
   */
   hasType: function(aManifest, aType) {
-    return aManifest.some(function(aEntry) {
-      return aEntry.type == aType;
-    });
+    return aManifest.some(entry => entry.type == aType);
   }
 };
--- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm
+++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm
@@ -253,30 +253,29 @@ this.LightweightThemeManager = {
     req.mozBackgroundRequest = true;
     req.overrideMimeType("text/plain");
     req.open("GET", theme.updateURL, true);
     // Prevent the request from reading from the cache.
     req.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
     // Prevent the request from writing to the cache.
     req.channel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;
 
-    var self = this;
-    req.addEventListener("load", function() {
+    req.addEventListener("load", () => {
       if (req.status != 200)
         return;
 
-      let newData = self.parseTheme(req.responseText, theme.updateURL);
+      let newData = this.parseTheme(req.responseText, theme.updateURL);
       if (!newData ||
           newData.id != theme.id ||
           _version(newData) == _version(theme))
         return;
 
-      var currentTheme = self.currentTheme;
+      var currentTheme = this.currentTheme;
       if (currentTheme && currentTheme.id == theme.id)
-        self.currentTheme = newData;
+        this.currentTheme = newData;
     }, false);
 
     req.send(null);
   },
 
   /**
    * Switches to a new lightweight theme.
    *
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -419,41 +419,36 @@ else {
   gHistory = FakeHistory;
 }
 
 var gEventManager = {
   _listeners: {},
   _installListeners: [],
 
   initialize: function() {
-    var self = this;
     const ADDON_EVENTS = ["onEnabling", "onEnabled", "onDisabling",
                           "onDisabled", "onUninstalling", "onUninstalled",
                           "onInstalled", "onOperationCancelled",
                           "onUpdateAvailable", "onUpdateFinished",
                           "onCompatibilityUpdateAvailable",
                           "onPropertyChanged"];
     for (let evt of ADDON_EVENTS) {
       let event = evt;
-      self[event] = function(...aArgs) {
-        self.delegateAddonEvent(event, aArgs);
-      };
+      this[event] = (...aArgs) => this.delegateAddonEvent(event, aArgs);
     }
 
     const INSTALL_EVENTS = ["onNewInstall", "onDownloadStarted",
                             "onDownloadEnded", "onDownloadFailed",
                             "onDownloadProgress", "onDownloadCancelled",
                             "onInstallStarted", "onInstallEnded",
                             "onInstallFailed", "onInstallCancelled",
                             "onExternalInstall"];
     for (let evt of INSTALL_EVENTS) {
       let event = evt;
-      self[event] = function(...aArgs) {
-        self.delegateInstallEvent(event, aArgs);
-      };
+      this[event] = (...aArgs) => this.delegateInstallEvent(event, aArgs);
     }
 
     AddonManager.addManagerListener(this);
     AddonManager.addInstallListener(this);
     AddonManager.addAddonListener(this);
 
     this.refreshGlobalWarning();
     this.refreshAutoUpdateDefault();
@@ -969,23 +964,22 @@ var gViewController = {
         document.getElementById("updates-noneFound").hidden = true;
         document.getElementById("updates-progress").hidden = false;
         document.getElementById("updates-manualUpdatesFound-btn").hidden = true;
 
         var pendingChecks = 0;
         var numUpdated = 0;
         var numManualUpdates = 0;
         var restartNeeded = false;
-        var self = this;
-
-        function updateStatus() {
+
+        let updateStatus = () => {
           if (pendingChecks > 0)
             return;
 
-          self.inProgress = false;
+          this.inProgress = false;
           gViewController.updateCommand("cmd_findAllUpdates");
           document.getElementById("updates-progress").hidden = true;
           gUpdatesView.maybeRefresh();
 
           if (numManualUpdates > 0 && numUpdated == 0) {
             document.getElementById("updates-manualUpdatesFound-btn").hidden = false;
             return;
           }
@@ -1765,24 +1759,23 @@ var gCategories = {
     } catch (e) { }
 
     // If there was no last view or no existing category matched the last view
     // then the list will default to selecting the search category and we never
     // want to show that as the first view so switch to the default category
     if (!this.node.selectedItem || this.node.selectedItem == this._search)
       this.node.value = gViewDefault;
 
-    var self = this;
-    this.node.addEventListener("select", function() {
-      self.maybeHideSearch();
-      gViewController.loadView(self.node.selectedItem.value);
+    this.node.addEventListener("select", () => {
+      this.maybeHideSearch();
+      gViewController.loadView(this.node.selectedItem.value);
     }, false);
 
-    this.node.addEventListener("click", function(aEvent) {
-      var selectedItem = self.node.selectedItem;
+    this.node.addEventListener("click", (aEvent) => {
+      var selectedItem = this.node.selectedItem;
       if (aEvent.target.localName == "richlistitem" &&
           aEvent.target == selectedItem) {
         var viewId = selectedItem.value;
 
         if (gViewController.parseViewId(viewId).type == "search") {
           viewId += encodeURIComponent(gHeader.searchQuery);
         }
 
@@ -1854,21 +1847,20 @@ var gCategories = {
       try {
         startHidden = Services.prefs.getBoolPref(prefName);
       }
       catch (e) {
         // Default to hidden
         startHidden = true;
       }
 
-      var self = this;
       gPendingInitializations++;
-      getAddonsAndInstalls(aType.id, function(aAddonsList, aInstallsList) {
+      getAddonsAndInstalls(aType.id, (aAddonsList, aInstallsList) => {
         var hidden = (aAddonsList.length == 0 && aInstallsList.length == 0);
-        var item = self.get(aViewId);
+        var item = this.get(aViewId);
 
         // Don't load view that is becoming hidden
         if (hidden && aViewId == gViewController.currentViewId)
           gViewController.loadView(gViewDefault);
 
         item.hidden = hidden;
         Services.prefs.setBoolPref(prefName, hidden);
 
@@ -1889,19 +1881,19 @@ var gCategories = {
           onInstallEnded: function(aInstall, aAddon) {
             this._maybeShowCategory(aAddon);
           },
 
           onExternalInstall: function(aAddon, aExistingAddon, aRequiresRestart) {
             this._maybeShowCategory(aAddon);
           },
 
-          _maybeShowCategory: function(aAddon) {
+          _maybeShowCategory: aAddon => {
             if (aType.id == aAddon.type) {
-              self.get(aViewId).hidden = false;
+              this.get(aViewId).hidden = false;
               Services.prefs.setBoolPref(prefName, false);
               gEventManager.unregisterInstallListener(this);
             }
           }
         });
 
         notifyInitialized();
       });
@@ -2083,32 +2075,30 @@ var gDiscoverView = {
       compatMode = "ignore";
     else if (AddonManager.strictCompatibility)
       compatMode = "strict";
 
     var url = Services.prefs.getCharPref(PREF_DISCOVERURL);
     url = url.replace("%COMPATIBILITY_MODE%", compatMode);
     url = Services.urlFormatter.formatURL(url);
 
-    var self = this;
-
-    function setURL(aURL) {
+    let setURL = (aURL) => {
       try {
-        self.homepageURL = Services.io.newURI(aURL, null, null);
+        this.homepageURL = Services.io.newURI(aURL, null, null);
       } catch (e) {
-        self.showError();
+        this.showError();
         notifyInitialized();
         return;
       }
 
-      self._browser.homePage = self.homepageURL.spec;
-      self._browser.addProgressListener(self);
-
-      if (self.loaded)
-        self._loadURL(self.homepageURL.spec, false, notifyInitialized);
+      this._browser.homePage = this.homepageURL.spec;
+      this._browser.addProgressListener(this);
+
+      if (this.loaded)
+        this._loadURL(this.homepageURL.spec, false, notifyInitialized);
       else
         notifyInitialized();
     }
 
     if (Services.prefs.getBoolPref(PREF_GETADDONS_CACHE_ENABLED) == false) {
       setURL(url);
       return;
     }
@@ -2384,57 +2374,56 @@ var gSearchView = {
     this._lastQuery = aQuery;
 
     if (AddonRepository.isSearching)
       AddonRepository.cancelSearch();
 
     while (this._listBox.firstChild.localName == "richlistitem")
       this._listBox.removeChild(this._listBox.firstChild);
 
-    var self = this;
     gCachedAddons = {};
     this._pendingSearches = 2;
     this._sorters.setSort("relevancescore", false);
 
     var elements = [];
 
-    function createSearchResults(aObjsList, aIsInstall, aIsRemote) {
+    let createSearchResults = (aObjsList, aIsInstall, aIsRemote) => {
       for (let index in aObjsList) {
         let obj = aObjsList[index];
         let score = aObjsList.length - index;
         if (!aIsRemote && aQuery.length > 0) {
-          score = self.getMatchScore(obj, aQuery);
+          score = this.getMatchScore(obj, aQuery);
           if (score == 0)
             continue;
         }
 
         let item = createItem(obj, aIsInstall, aIsRemote);
         item.setAttribute("relevancescore", score);
         if (aIsRemote) {
           gCachedAddons[obj.id] = obj;
           if (obj.purchaseURL)
-            self._sorters.showprice = true;
+            this._sorters.showprice = true;
         }
 
         elements.push(item);
       }
     }
 
-    function finishSearch(createdCount) {
+    let finishSearch = (createdCount) => {
       if (elements.length > 0) {
-        sortElements(elements, [self._sorters.sortBy], self._sorters.ascending);
+        sortElements(elements, [this._sorters.sortBy], this._sorters.ascending);
         for (let element of elements)
-          self._listBox.insertBefore(element, self._listBox.lastChild);
-        self.updateListAttributes();
+          this._listBox.insertBefore(element, this._listBox.lastChild);
+        this.updateListAttributes();
       }
 
-      self._pendingSearches--;
-      self.updateView();
-
-      if (!self.isSearching)
+      this._pendingSearches--;
+      this.updateView();
+
+      if (!this.isSearching)
         gViewController.notifyViewChanged();
     }
 
     getAddonsAndInstalls(null, function(aAddons, aInstalls) {
       if (gViewController && aRequest != gViewController.currentViewRequest)
         return;
 
       createSearchResults(aAddons, false, false);
@@ -2448,34 +2437,34 @@ var gSearchView = {
     } catch(e) {}
 
     if (maxRemoteResults <= 0) {
       finishSearch(0);
       return;
     }
 
     AddonRepository.searchAddons(aQuery, maxRemoteResults, {
-      searchFailed: function() {
+      searchFailed: () => {
         if (gViewController && aRequest != gViewController.currentViewRequest)
           return;
 
-        self._lastRemoteTotal = 0;
+        this._lastRemoteTotal = 0;
 
         // XXXunf Better handling of AMO search failure. See bug 579502
         finishSearch(0); // Silently fail
       },
 
-      searchSucceeded: function(aAddonsList, aAddonCount, aTotalResults) {
+      searchSucceeded: (aAddonsList, aAddonCount, aTotalResults) => {
         if (gViewController && aRequest != gViewController.currentViewRequest)
           return;
 
         if (aTotalResults > maxRemoteResults)
-          self._lastRemoteTotal = aTotalResults;
+          this._lastRemoteTotal = aTotalResults;
         else
-          self._lastRemoteTotal = 0;
+          this._lastRemoteTotal = 0;
 
         var createdCount = createSearchResults(aAddonsList, false, true);
         finishSearch(createdCount);
       }
     });
   },
 
   showLoading: function(aLoading) {
@@ -2657,20 +2646,19 @@ var gListView = {
   _emptyNotice: null,
   _type: null,
 
   initialize: function() {
     this.node = document.getElementById("list-view");
     this._listBox = document.getElementById("addon-list");
     this._emptyNotice = document.getElementById("addon-list-empty");
 
-    var self = this;
-    this._listBox.addEventListener("keydown", function(aEvent) {
+    this._listBox.addEventListener("keydown", (aEvent) => {
       if (aEvent.keyCode == aEvent.DOM_VK_RETURN) {
-        var item = self._listBox.selectedItem;
+        var item = this._listBox.selectedItem;
         if (item)
           item.showInDetailView();
       }
     }, false);
 
     document.getElementById("signing-learn-more").setAttribute("href",
       Services.urlFormatter.formatURLPref("app.support.baseURL") + "unsigned-addons");
 
@@ -2867,19 +2855,18 @@ var gDetailView = {
   _loadingTimer: null,
   _autoUpdate: null,
 
   initialize: function() {
     this.node = document.getElementById("detail-view");
 
     this._autoUpdate = document.getElementById("detail-autoUpdate");
 
-    var self = this;
-    this._autoUpdate.addEventListener("command", function() {
-      self._addon.applyBackgroundUpdates = self._autoUpdate.value;
+    this._autoUpdate.addEventListener("command", () => {
+      this._addon.applyBackgroundUpdates = this._autoUpdate.value;
     }, true);
   },
 
   shutdown: function() {
     AddonManager.removeManagerListener(this);
   },
 
   onUpdateModeChanged: function() {
@@ -3106,44 +3093,43 @@ var gDetailView = {
   show: function(aAddonId, aRequest) {
     let index = aAddonId.indexOf("/preferences");
     let scrollToPreferences = false;
     if (index >= 0) {
       aAddonId = aAddonId.substring(0, index);
       scrollToPreferences = true;
     }
 
-    var self = this;
-    this._loadingTimer = setTimeout(function() {
-      self.node.setAttribute("loading-extended", true);
+    this._loadingTimer = setTimeout(() => {
+      this.node.setAttribute("loading-extended", true);
     }, LOADING_MSG_DELAY);
 
     var view = gViewController.currentViewId;
 
-    AddonManager.getAddonByID(aAddonId, function(aAddon) {
+    AddonManager.getAddonByID(aAddonId, (aAddon) => {
       if (gViewController && aRequest != gViewController.currentViewRequest)
         return;
 
       if (aAddon) {
-        self._updateView(aAddon, false, scrollToPreferences);
+        this._updateView(aAddon, false, scrollToPreferences);
         return;
       }
 
       // Look for an add-on pending install
-      AddonManager.getAllInstalls(function(aInstalls) {
+      AddonManager.getAllInstalls(aInstalls => {
         for (let install of aInstalls) {
           if (install.state == AddonManager.STATE_INSTALLED &&
               install.addon.id == aAddonId) {
-            self._updateView(install.addon, false);
+            this._updateView(install.addon, false);
             return;
           }
         }
 
         if (aAddonId in gCachedAddons) {
-          self._updateView(gCachedAddons[aAddonId], true);
+          this._updateView(gCachedAddons[aAddonId], true);
           return;
         }
 
         // This might happen due to session restore restoring us back to an
         // add-on that doesn't exist but otherwise shouldn't normally happen.
         // Either way just revert to the default view.
         gViewController.replaceView(gViewDefault);
       });
@@ -3558,85 +3544,83 @@ var gUpdatesView = {
 
   hide: function() {
     this._updateSelected.hidden = true;
     this._categoryItem.disabled = this._categoryItem.badgeCount == 0;
     doPendingUninstalls(this._listBox);
   },
 
   _showRecentUpdates: function(aRequest) {
-    var self = this;
-    AddonManager.getAllAddons(function(aAddonsList) {
+    AddonManager.getAllAddons((aAddonsList) => {
       if (gViewController && aRequest != gViewController.currentViewRequest)
         return;
 
       var elements = [];
       let threshold = Date.now() - UPDATES_RECENT_TIMESPAN;
       for (let addon of aAddonsList) {
         if (addon.hidden || !addon.updateDate || addon.updateDate.getTime() < threshold)
           continue;
 
         elements.push(createItem(addon));
       }
 
-      self.showEmptyNotice(elements.length == 0);
+      this.showEmptyNotice(elements.length == 0);
       if (elements.length > 0) {
-        sortElements(elements, [self._sorters.sortBy], self._sorters.ascending);
+        sortElements(elements, [this._sorters.sortBy], this._sorters.ascending);
         for (let element of elements)
-          self._listBox.appendChild(element);
+          this._listBox.appendChild(element);
       }
 
       gViewController.notifyViewChanged();
     });
   },
 
   _showAvailableUpdates: function(aIsRefresh, aRequest) {
     /* Disable the Update Selected button so it can't get clicked
        before everything is initialized asynchronously.
        It will get re-enabled by maybeDisableUpdateSelected(). */
     this._updateSelected.disabled = true;
 
-    var self = this;
-    AddonManager.getAllInstalls(function(aInstallsList) {
+    AddonManager.getAllInstalls((aInstallsList) => {
       if (!aIsRefresh && gViewController && aRequest &&
           aRequest != gViewController.currentViewRequest)
         return;
 
       if (aIsRefresh) {
-        self.showEmptyNotice(false);
-        self._updateSelected.hidden = true;
-
-        while (self._listBox.childNodes.length > 0)
-          self._listBox.removeChild(self._listBox.firstChild);
+        this.showEmptyNotice(false);
+        this._updateSelected.hidden = true;
+
+        while (this._listBox.childNodes.length > 0)
+          this._listBox.removeChild(this._listBox.firstChild);
       }
 
       var elements = [];
 
       for (let install of aInstallsList) {
-        if (!self.isManualUpdate(install))
+        if (!this.isManualUpdate(install))
           continue;
 
         let item = createItem(install.existingAddon);
         item.setAttribute("upgrade", true);
-        item.addEventListener("IncludeUpdateChanged", function() {
-          self.maybeDisableUpdateSelected();
+        item.addEventListener("IncludeUpdateChanged", () => {
+          this.maybeDisableUpdateSelected();
         }, false);
         elements.push(item);
       }
 
-      self.showEmptyNotice(elements.length == 0);
+      this.showEmptyNotice(elements.length == 0);
       if (elements.length > 0) {
-        self._updateSelected.hidden = false;
-        sortElements(elements, [self._sorters.sortBy], self._sorters.ascending);
+        this._updateSelected.hidden = false;
+        sortElements(elements, [this._sorters.sortBy], this._sorters.ascending);
         for (let element of elements)
-          self._listBox.appendChild(element);
+          this._listBox.appendChild(element);
       }
 
       // ensure badge count is in sync
-      self._categoryItem.badgeCount = self._listBox.itemCount;
+      this._categoryItem.badgeCount = this._listBox.itemCount;
 
       gViewController.notifyViewChanged();
     });
   },
 
   showEmptyNotice: function(aShow) {
     this._emptyNotice.hidden = !aShow;
     this._listBox.hidden = aShow;
@@ -3654,24 +3638,23 @@ var gUpdatesView = {
     if (gViewController.currentViewId == "addons://updates/available")
       this._showAvailableUpdates(true);
     this.updateAvailableCount();
   },
 
   updateAvailableCount: function(aInitializing) {
     if (aInitializing)
       gPendingInitializations++;
-    var self = this;
-    AddonManager.getAllInstalls(function(aInstallsList) {
-      var count = aInstallsList.filter(function(aInstall) {
-        return self.isManualUpdate(aInstall, true);
+    AddonManager.getAllInstalls((aInstallsList) => {
+      var count = aInstallsList.filter(aInstall => {
+        return this.isManualUpdate(aInstall, true);
       }).length;
-      self._categoryItem.disabled = gViewController.currentViewId != "addons://updates/available" &&
+      this._categoryItem.disabled = gViewController.currentViewId != "addons://updates/available" &&
                                     count == 0;
-      self._categoryItem.badgeCount = count;
+      this._categoryItem.badgeCount = count;
       if (aInitializing)
         notifyInitialized();
     });
   },
 
   maybeDisableUpdateSelected: function() {
     for (let item of this._listBox.childNodes) {
       if (item.includeUpdate) {
--- a/toolkit/mozapps/extensions/content/extensions.xml
+++ b/toolkit/mozapps/extensions/content/extensions.xml
@@ -1119,28 +1119,27 @@
             this._description.value = this.mAddon.description;
           else
             this._description.hidden = true;
 
           if (!("applyBackgroundUpdates" in this.mAddon) ||
               (this.mAddon.applyBackgroundUpdates == AddonManager.AUTOUPDATE_DISABLE ||
                (this.mAddon.applyBackgroundUpdates == AddonManager.AUTOUPDATE_DEFAULT &&
                 !AddonManager.autoUpdateDefault))) {
-            var self = this;
-            AddonManager.getAllInstalls(function(aInstallsList) {
+            AddonManager.getAllInstalls(aInstallsList => {
               // This can return after the binding has been destroyed,
               // so try to detect that and return early
-              if (!("onNewInstall" in self))
+              if (!("onNewInstall" in this))
                 return;
               for (let install of aInstallsList) {
                 if (install.existingAddon &&
-                    install.existingAddon.id == self.mAddon.id &&
+                    install.existingAddon.id == this.mAddon.id &&
                     install.state == AddonManager.STATE_AVAILABLE) {
-                  self.onNewInstall(install);
-                  self.onIncludeUpdateChanged();
+                  this.onNewInstall(install);
+                  this.onIncludeUpdateChanged();
                 }
               }
             });
           }
         ]]></body>
       </method>
 
       <method name="_showStatus">
@@ -1408,60 +1407,59 @@
             }
           }
         ]]></body>
       </method>
 
       <method name="_fetchReleaseNotes">
         <parameter name="aURI"/>
         <body><![CDATA[
-          var self = this;
           if (!aURI || this._relNotesLoaded) {
             sendToggleEvent();
             return;
           }
 
           var relNotesData = null, transformData = null;
 
           this._relNotesLoaded = true;
           this._relNotesLoading.hidden = false;
           this._relNotesError.hidden = true;
 
-          function sendToggleEvent() {
+          let sendToggleEvent = () => {
             var event = document.createEvent("Events");
             event.initEvent("RelNotesToggle", true, true);
-            self.dispatchEvent(event);
+            this.dispatchEvent(event);
           }
 
-          function showRelNotes() {
+          let showRelNotes = () => {
             if (!relNotesData || !transformData)
               return;
 
-            self._relNotesLoading.hidden = true;
+            this._relNotesLoading.hidden = true;
 
             var processor = Components.classes["@mozilla.org/document-transformer;1?type=xslt"]
                                       .createInstance(Components.interfaces.nsIXSLTProcessor);
             processor.flags |= Components.interfaces.nsIXSLTProcessorPrivate.DISABLE_ALL_LOADS;
 
             processor.importStylesheet(transformData);
             var fragment = processor.transformToFragment(relNotesData, document);
-            self._relNotes.appendChild(fragment);
-            if (self.hasAttribute("show-relnotes")) {
-              var container = self._relNotesContainer;
+            this._relNotes.appendChild(fragment);
+            if (this.hasAttribute("show-relnotes")) {
+              var container = this._relNotesContainer;
               container.style.height = container.scrollHeight + "px";
             }
             sendToggleEvent();
           }
 
-          function handleError() {
+          let handleError = () => {
             dataReq.abort();
             styleReq.abort();
-            self._relNotesLoading.hidden = true;
-            self._relNotesError.hidden = false;
-            self._relNotesLoaded = false; // allow loading to be re-tried
+            this._relNotesLoading.hidden = true;
+            this._relNotesError.hidden = false;
+            this._relNotesLoaded = false; // allow loading to be re-tried
             sendToggleEvent();
           }
 
           function handleResponse(aEvent) {
             var req = aEvent.target;
             var ct = req.getResponseHeader("content-type");
             if ((!ct || ct.indexOf("text/html") < 0) &&
                 req.responseXML &&
--- a/toolkit/mozapps/extensions/internal/AddonRepository.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonRepository.jsm
@@ -630,36 +630,35 @@ this.AddonRepository = {
     if (!this.cacheEnabled) {
       logger.debug("Clearing cache because it is disabled");
       return this._clearCache();
     }
 
     let ids = [a.id for (a of allAddons)];
     logger.debug("Repopulate add-on cache with " + ids.toSource());
 
-    let self = this;
     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 new Promise((resolve, reject) =>
-      self._beginGetAddons(addonsToCache, {
-        searchSucceeded: function(aAddons) {
-          self._addons = new Map();
+      this._beginGetAddons(addonsToCache, {
+        searchSucceeded: aAddons => {
+          this._addons = new Map();
           for (let addon of aAddons) {
-            self._addons.set(addon.id, addon);
+            this._addons.set(addon.id, addon);
           }
           AddonDatabase.repopulate(aAddons, resolve);
         },
-        searchFailed: function() {
+        searchFailed: () => {
           logger.warn("Search failed when repopulating cache");
           resolve();
         }
       }, aSendPerformance, aTimeout));
 
     // Always call AddonManager updateAddonRepositoryData after we refill the cache
     yield new Promise((resolve, reject) =>
       AddonManagerPrivate.updateAddonRepositoryData(resolve));
@@ -678,33 +677,32 @@ this.AddonRepository = {
   cacheAddons: function(aIds, aCallback) {
     logger.debug("cacheAddons: enabled " + this.cacheEnabled + " IDs " + aIds.toSource());
     if (!this.cacheEnabled) {
       if (aCallback)
         aCallback();
       return;
     }
 
-    let self = this;
-    getAddonsToCache(aIds, function(aAddons) {
+    getAddonsToCache(aIds, aAddons => {
       // If there are no add-ons to cache, act as if caching is disabled
       if (aAddons.length == 0) {
         if (aCallback)
           aCallback();
         return;
       }
 
-      self.getAddonsByIDs(aAddons, {
-        searchSucceeded: function(aAddons) {
+      this.getAddonsByIDs(aAddons, {
+        searchSucceeded: aAddons => {
           for (let addon of aAddons) {
-            self._addons.set(addon.id, addon);
+            this._addons.set(addon.id, addon);
           }
           AddonDatabase.insertAddons(aAddons, aCallback);
         },
-        searchFailed: function() {
+        searchFailed: () => {
           logger.warn("Search failed when adding add-ons to cache");
           if (aCallback)
             aCallback();
         }
       });
     });
   },
 
@@ -824,23 +822,22 @@ this.AddonRepository = {
                                            startupInfo.process;
           }
         }
       }
     }
 
     let url = this._formatURLPref(pref, params);
 
-    let self = this;
-    function handleResults(aElements, aTotalResults, aCompatData) {
+    let  handleResults = (aElements, aTotalResults, aCompatData) => {
       // Don't use this._parseAddons() so that, for example,
       // incompatible add-ons are not filtered out
       let results = [];
-      for (let i = 0; i < aElements.length && results.length < self._maxResults; i++) {
-        let result = self._parseAddon(aElements[i], null, aCompatData);
+      for (let i = 0; i < aElements.length && results.length < this._maxResults; i++) {
+        let result = this._parseAddon(aElements[i], null, aCompatData);
         if (result == null)
           continue;
 
         // Ignore add-on if it wasn't actually requested
         let idIndex = ids.indexOf(result.addon.id);
         if (idIndex == -1)
           continue;
 
@@ -869,17 +866,17 @@ this.AddonRepository = {
           addon: addon,
           xpiURL: null,
           xpiHash: null
         };
         results.push(result);
       }
 
       // aTotalResults irrelevant
-      self._reportSuccess(results, -1);
+      this._reportSuccess(results, -1);
     }
 
     this._beginSearch(url, ids.length, aCallback, handleResults, aTimeout);
   },
 
   /**
    * Performs the daily background update check.
    *
@@ -905,21 +902,20 @@ this.AddonRepository = {
   retrieveRecommendedAddons: function(aMaxResults, aCallback) {
     let url = this._formatURLPref(PREF_GETADDONS_GETRECOMMENDED, {
       API_VERSION : API_VERSION,
 
       // Get twice as many results to account for potential filtering
       MAX_RESULTS : 2 * aMaxResults
     });
 
-    let self = this;
-    function handleResults(aElements, aTotalResults) {
-      self._getLocalAddonIds(function(aLocalAddonIds) {
+    let handleResults = (aElements, aTotalResults) => {
+      this._getLocalAddonIds(aLocalAddonIds => {
         // aTotalResults irrelevant
-        self._parseAddons(aElements, -1, aLocalAddonIds);
+        this._parseAddons(aElements, -1, aLocalAddonIds);
       });
     }
 
     this._beginSearch(url, aMaxResults, aCallback, handleResults);
   },
 
   /**
    * Begins a search for add-ons in this repository. Results will be passed to
@@ -944,20 +940,19 @@ this.AddonRepository = {
       TERMS : encodeURIComponent(aSearchTerms),
       // Get twice as many results to account for potential filtering
       MAX_RESULTS : 2 * aMaxResults,
       COMPATIBILITY_MODE : compatMode,
     };
 
     let url = this._formatURLPref(PREF_GETADDONS_GETSEARCHRESULTS, substitutions);
 
-    let self = this;
-    function handleResults(aElements, aTotalResults) {
-      self._getLocalAddonIds(function(aLocalAddonIds) {
-        self._parseAddons(aElements, aTotalResults, aLocalAddonIds);
+    let handleResults = (aElements, aTotalResults) => {
+      this._getLocalAddonIds(aLocalAddonIds => {
+        this._parseAddons(aElements, aTotalResults, aLocalAddonIds);
       });
     }
 
     this._beginSearch(url, aMaxResults, aCallback, handleResults);
   },
 
   // Posts results to the callback
   _reportSuccess: function(aResults, aTotalResults) {
@@ -1041,17 +1036,16 @@ this.AddonRepository = {
       addon: addon,
       xpiURL: null,
       xpiHash: null
     };
 
     if (aCompatData && guid in aCompatData)
       addon.compatibilityOverrides = aCompatData[guid].compatRanges;
 
-    let self = this;
     for (let node = aElement.firstChild; node; node = node.nextSibling) {
       if (!(node instanceof Ci.nsIDOMElement))
         continue;
 
       let localName = node.localName;
 
       // Handle case where the wanted string value is located in text content
       // but only if the content is not empty
@@ -1112,18 +1106,18 @@ this.AddonRepository = {
               break;
             default:
               logger.info("Unknown type id " + id + " found when parsing response for GUID " + guid);
           }
           break;
         case "authors":
           let authorNodes = node.getElementsByTagName("author");
           for (let authorNode of authorNodes) {
-            let name = self._getDescendantTextContent(authorNode, "name");
-            let link = self._getDescendantTextContent(authorNode, "link");
+            let name = this._getDescendantTextContent(authorNode, "name");
+            let link = this._getDescendantTextContent(authorNode, "link");
             if (name == null || link == null)
               continue;
 
             let author = new AddonManagerPrivate.AddonAuthor(name, link);
             if (addon.creator == null)
               addon.creator = author;
             else {
               if (addon.developers == null)
@@ -1131,32 +1125,32 @@ this.AddonRepository = {
 
               addon.developers.push(author);
             }
           }
           break;
         case "previews":
           let previewNodes = node.getElementsByTagName("preview");
           for (let previewNode of previewNodes) {
-            let full = self._getUniqueDescendant(previewNode, "full");
+            let full = this._getUniqueDescendant(previewNode, "full");
             if (full == null)
               continue;
 
-            let fullURL = self._getTextContent(full);
+            let fullURL = this._getTextContent(full);
             let fullWidth = full.getAttribute("width");
             let fullHeight = full.getAttribute("height");
 
             let thumbnailURL, thumbnailWidth, thumbnailHeight;
-            let thumbnail = self._getUniqueDescendant(previewNode, "thumbnail");
+            let thumbnail = this._getUniqueDescendant(previewNode, "thumbnail");
             if (thumbnail) {
-              thumbnailURL = self._getTextContent(thumbnail);
+              thumbnailURL = this._getTextContent(thumbnail);
               thumbnailWidth = thumbnail.getAttribute("width");
               thumbnailHeight = thumbnail.getAttribute("height");
             }
-            let caption = self._getDescendantTextContent(previewNode, "caption");
+            let caption = this._getDescendantTextContent(previewNode, "caption");
             let screenshot = new AddonManagerPrivate.AddonScreenshot(fullURL, fullWidth, fullHeight,
                                                                      thumbnailURL, thumbnailWidth,
                                                                      thumbnailHeight, caption);
 
             if (addon.screenshots == null)
               addon.screenshots = [];
 
             if (previewNode.getAttribute("primary") == 1)
@@ -1250,38 +1244,35 @@ this.AddonRepository = {
           break;
       }
     }
 
     return result;
   },
 
   _parseAddons: function(aElements, aTotalResults, aSkip) {
-    let self = this;
     let results = [];
 
-    function isSameApplication(aAppNode) {
-      return self._getTextContent(aAppNode) == Services.appinfo.ID;
-    }
+    let isSameApplication = aAppNode => this._getTextContent(aAppNode) == Services.appinfo.ID;
 
     for (let i = 0; i < aElements.length && results.length < this._maxResults; i++) {
       let element = aElements[i];
 
       let tags = this._getUniqueDescendant(element, "compatible_applications");
       if (tags == null)
         continue;
 
       let applications = tags.getElementsByTagName("appID");
-      let compatible = Array.some(applications, function(aAppNode) {
+      let compatible = Array.some(applications, aAppNode => {
         if (!isSameApplication(aAppNode))
           return false;
 
         let parent = aAppNode.parentNode;
-        let minVersion = self._getDescendantTextContent(parent, "min_version");
-        let maxVersion = self._getDescendantTextContent(parent, "max_version");
+        let minVersion = this._getDescendantTextContent(parent, "min_version");
+        let maxVersion = this._getDescendantTextContent(parent, "max_version");
         if (minVersion == null || maxVersion == null)
           return false;
 
         let currentVersion = Services.appinfo.version;
         return (Services.vc.compare(minVersion, currentVersion) <= 0 &&
                 ((!AddonManager.strictCompatibility) ||
                  Services.vc.compare(currentVersion, maxVersion) <= 0));
       });
@@ -1330,34 +1321,34 @@ this.AddonRepository = {
     // Immediately report success if no AddonInstall instances to create
     let pendingResults = results.length;
     if (pendingResults == 0) {
       this._reportSuccess(results, aTotalResults);
       return;
     }
 
     // Create an AddonInstall for each result
-    results.forEach(function(aResult) {
-      let addon = aResult.addon;
-      let callback = function(aInstall) {
+    for (let result of results) {
+      let addon = result.addon;
+      let callback = aInstall => {
         addon.install = aInstall;
         pendingResults--;
         if (pendingResults == 0)
-          self._reportSuccess(results, aTotalResults);
+          this._reportSuccess(results, aTotalResults);
       }
 
-      if (aResult.xpiURL) {
-        AddonManager.getInstallForURL(aResult.xpiURL, callback,
-                                      "application/x-xpinstall", aResult.xpiHash,
+      if (result.xpiURL) {
+        AddonManager.getInstallForURL(result.xpiURL, callback,
+                                      "application/x-xpinstall", result.xpiHash,
                                       addon.name, addon.icons, addon.version);
       }
       else {
         callback(null);
       }
-    });
+    }
   },
 
   // Parses addon_compatibility nodes, that describe compatibility overrides.
   _parseAddonCompatElement: function(aResultObj, aElement) {
     let guid = this._getDescendantTextContent(aElement, "guid");
     if (!guid) {
         logger.debug("Compatibility override is missing guid.");
       return;
@@ -1493,17 +1484,16 @@ this.AddonRepository = {
       aHandleResults(elements, totalResults, compatData);
     }, false);
     this._request.send(null);
   },
 
   // Gets the id's of local add-ons, and the sourceURI's of local installs,
   // passing the results to aCallback
   _getLocalAddonIds: function(aCallback) {
-    let self = this;
     let localAddonIds = {ids: null, sourceURIs: null};
 
     AddonManager.getAllAddons(function(aAddons) {
       localAddonIds.ids = aAddons.map(a => a.id);
       if (localAddonIds.sourceURIs)
         aCallback(localAddonIds);
     });
 
--- a/toolkit/mozapps/extensions/internal/AddonRepository_SQLiteMigrator.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonRepository_SQLiteMigrator.jsm
@@ -156,163 +156,162 @@ this.AddonRepository_SQLiteMigrator = {
   /**
    * Asynchronously retrieve all add-ons from the database, and pass it
    * to the specified callback
    *
    * @param  aCallback
    *         The callback to pass the add-ons back to
    */
   _retrieveStoredData: function(aCallback) {
-    let self = this;
     let addons = {};
 
     // Retrieve all data from the addon table
-    function getAllAddons() {
-      self.getAsyncStatement("getAllAddons").executeAsync({
-        handleResult: function(aResults) {
+    let getAllAddons = () => {
+      this.getAsyncStatement("getAllAddons").executeAsync({
+        handleResult: aResults => {
           let row = null;
           while ((row = aResults.getNextRow())) {
             let internal_id = row.getResultByName("internal_id");
-            addons[internal_id] = self._makeAddonFromAsyncRow(row);
+            addons[internal_id] = this._makeAddonFromAsyncRow(row);
           }
         },
 
-        handleError: self.asyncErrorLogger,
+        handleError: this.asyncErrorLogger,
 
         handleCompletion: function(aReason) {
           if (aReason != Ci.mozIStorageStatementCallback.REASON_FINISHED) {
             logger.error("Error retrieving add-ons from database. Returning empty results");
             aCallback({});
             return;
           }
 
           getAllDevelopers();
         }
       });
     }
 
     // Retrieve all data from the developer table
-    function getAllDevelopers() {
-      self.getAsyncStatement("getAllDevelopers").executeAsync({
-        handleResult: function(aResults) {
+    let getAllDevelopers = () => {
+      this.getAsyncStatement("getAllDevelopers").executeAsync({
+        handleResult: aResults => {
           let row = null;
           while ((row = aResults.getNextRow())) {
             let addon_internal_id = row.getResultByName("addon_internal_id");
             if (!(addon_internal_id in addons)) {
               logger.warn("Found a developer not linked to an add-on in database");
               continue;
             }
 
             let addon = addons[addon_internal_id];
             if (!addon.developers)
               addon.developers = [];
 
-            addon.developers.push(self._makeDeveloperFromAsyncRow(row));
+            addon.developers.push(this._makeDeveloperFromAsyncRow(row));
           }
         },
 
-        handleError: self.asyncErrorLogger,
+        handleError: this.asyncErrorLogger,
 
         handleCompletion: function(aReason) {
           if (aReason != Ci.mozIStorageStatementCallback.REASON_FINISHED) {
             logger.error("Error retrieving developers from database. Returning empty results");
             aCallback({});
             return;
           }
 
           getAllScreenshots();
         }
       });
     }
 
     // Retrieve all data from the screenshot table
-    function getAllScreenshots() {
-      self.getAsyncStatement("getAllScreenshots").executeAsync({
-        handleResult: function(aResults) {
+    let getAllScreenshots = () => {
+      this.getAsyncStatement("getAllScreenshots").executeAsync({
+        handleResult: aResults => {
           let row = null;
           while ((row = aResults.getNextRow())) {
             let addon_internal_id = row.getResultByName("addon_internal_id");
             if (!(addon_internal_id in addons)) {
               logger.warn("Found a screenshot not linked to an add-on in database");
               continue;
             }
 
             let addon = addons[addon_internal_id];
             if (!addon.screenshots)
               addon.screenshots = [];
-            addon.screenshots.push(self._makeScreenshotFromAsyncRow(row));
+            addon.screenshots.push(this._makeScreenshotFromAsyncRow(row));
           }
         },
 
-        handleError: self.asyncErrorLogger,
+        handleError: this.asyncErrorLogger,
 
         handleCompletion: function(aReason) {
           if (aReason != Ci.mozIStorageStatementCallback.REASON_FINISHED) {
             logger.error("Error retrieving screenshots from database. Returning empty results");
             aCallback({});
             return;
           }
 
           getAllCompatOverrides();
         }
       });
     }
 
-    function getAllCompatOverrides() {
-      self.getAsyncStatement("getAllCompatOverrides").executeAsync({
-        handleResult: function(aResults) {
+    let getAllCompatOverrides = () => {
+      this.getAsyncStatement("getAllCompatOverrides").executeAsync({
+        handleResult: aResults => {
           let row = null;
           while ((row = aResults.getNextRow())) {
             let addon_internal_id = row.getResultByName("addon_internal_id");
             if (!(addon_internal_id in addons)) {
               logger.warn("Found a compatibility override not linked to an add-on in database");
               continue;
             }
 
             let addon = addons[addon_internal_id];
             if (!addon.compatibilityOverrides)
               addon.compatibilityOverrides = [];
-            addon.compatibilityOverrides.push(self._makeCompatOverrideFromAsyncRow(row));
+            addon.compatibilityOverrides.push(this._makeCompatOverrideFromAsyncRow(row));
           }
         },
 
-        handleError: self.asyncErrorLogger,
+        handleError: this.asyncErrorLogger,
 
         handleCompletion: function(aReason) {
           if (aReason != Ci.mozIStorageStatementCallback.REASON_FINISHED) {
             logger.error("Error retrieving compatibility overrides from database. Returning empty results");
             aCallback({});
             return;
           }
 
           getAllIcons();
         }
       });
     }
 
-    function getAllIcons() {
-      self.getAsyncStatement("getAllIcons").executeAsync({
-        handleResult: function(aResults) {
+    let getAllIcons = () => {
+      this.getAsyncStatement("getAllIcons").executeAsync({
+        handleResult: aResults => {
           let row = null;
           while ((row = aResults.getNextRow())) {
             let addon_internal_id = row.getResultByName("addon_internal_id");
             if (!(addon_internal_id in addons)) {
               logger.warn("Found an icon not linked to an add-on in database");
               continue;
             }
 
             let addon = addons[addon_internal_id];
-            let { size, url } = self._makeIconFromAsyncRow(row);
+            let { size, url } = this._makeIconFromAsyncRow(row);
             addon.icons[size] = url;
             if (size == 32)
               addon.iconURL = url;
           }
         },
 
-        handleError: self.asyncErrorLogger,
+        handleError: this.asyncErrorLogger,
 
         handleCompletion: function(aReason) {
           if (aReason != Ci.mozIStorageStatementCallback.REASON_FINISHED) {
             logger.error("Error retrieving icons from database. Returning empty results");
             aCallback({});
             return;
           }
 
--- a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm
@@ -577,20 +577,19 @@ function UpdateParser(aId, aUpdateKey, a
     this.request.open("GET", this.url, true);
     this.request.channel.notificationCallbacks = new CertUtils.BadCertHandler(!requireBuiltIn);
     this.request.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
     // Prevent the request from writing to cache.
     this.request.channel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;
     this.request.overrideMimeType("text/plain");
     this.request.setRequestHeader("Moz-XPI-Update", "1", true);
     this.request.timeout = TIMEOUT;
-    var self = this;
-    this.request.addEventListener("load", function(event) { self.onLoad() }, false);
-    this.request.addEventListener("error", function(event) { self.onError() }, false);
-    this.request.addEventListener("timeout", function(event) { self.onTimeout() }, false);
+    this.request.addEventListener("load", () => this.onLoad(), false);
+    this.request.addEventListener("error", () => this.onError(), false);
+    this.request.addEventListener("timeout", () => this.onTimeout(), false);
     this.request.send(null);
   }
   catch (e) {
     logger.error("Failed to request update manifest", e);
   }
 }
 
 UpdateParser.prototype = {
--- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/GMPProvider.jsm
@@ -282,19 +282,17 @@ GMPWrapper.prototype = {
       return this._updateTask;
     }
 
     this._updateTask = Task.spawn(function*() {
       this._log.trace("findUpdates() - updateTask");
       try {
         let installManager = new GMPInstallManager();
         let gmpAddons = yield installManager.checkForAddons();
-        let update = gmpAddons.find(function(aAddon) {
-          return aAddon.id === this._plugin.id;
-        }, this);
+        let update = gmpAddons.find(addon => addon.id === this._plugin.id);
         if (update && update.isValid && !update.isInstalled) {
           this._log.trace("findUpdates() - found update for " +
                           this._plugin.id + ", installing");
           yield installManager.installAddon(update);
         } else {
           this._log.trace("findUpdates() - no updates for " + this._plugin.id);
         }
         this._log.info("findUpdates() - updateTask succeeded for " +
--- a/toolkit/mozapps/extensions/internal/PluginProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/PluginProvider.jsm
@@ -141,21 +141,18 @@ var PluginProvider = {
       return;
     }
 
     if (!this.plugins)
       this.buildPluginList();
 
     let results = [];
 
-    for (let id in this.plugins) {
-      this.getAddonByID(id, function(aAddon) {
-        results.push(aAddon);
-      });
-    }
+    for (let id in this.plugins)
+      this.getAddonByID(id, (addon) => results.push(addon));
 
     aCallback(results);
   },
 
   /**
    * Called to get Addons that have pending operations.
    *
    * @param  aTypes
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -4113,37 +4113,36 @@ this.XPIProvider = {
 
   /**
    * Update the repositoryAddon property for all add-ons.
    *
    * @param  aCallback
    *         Function to call when operation is complete.
    */
   updateAddonRepositoryData: function(aCallback) {
-    let self = this;
-    XPIDatabase.getVisibleAddons(null, function(aAddons) {
+    XPIDatabase.getVisibleAddons(null, aAddons => {
       let pending = aAddons.length;
       logger.debug("updateAddonRepositoryData found " + pending + " visible add-ons");
       if (pending == 0) {
         aCallback();
         return;
       }
 
       function notifyComplete() {
         if (--pending == 0)
           aCallback();
       }
 
       for (let addon of aAddons) {
-        AddonRepository.getCachedAddonByID(addon.id, function(aRepoAddon) {
+        AddonRepository.getCachedAddonByID(addon.id, aRepoAddon => {
           if (aRepoAddon) {
             logger.debug("updateAddonRepositoryData got info for " + addon.id);
             addon._repositoryAddon = aRepoAddon;
             addon.compatibilityOverrides = aRepoAddon.compatibilityOverrides;
-            self.updateAddonDisabledState(addon);
+            this.updateAddonDisabledState(addon);
           }
 
           notifyComplete();
         });
       };
     });
   },
 
@@ -5042,56 +5041,55 @@ AddonInstall.prototype = {
              this.hash.data + ")");
         this.state = AddonManager.STATE_DOWNLOAD_FAILED;
         this.error = AddonManager.ERROR_INCORRECT_HASH;
         aCallback(this);
         return;
       }
     }
 
-    let self = this;
     this.loadManifest(this.file).then(() => {
-      XPIDatabase.getVisibleAddonForID(self.addon.id, function(aAddon) {
-        self.existingAddon = aAddon;
+      XPIDatabase.getVisibleAddonForID(this.addon.id, aAddon => {
+        this.existingAddon = aAddon;
         if (aAddon)
-          applyBlocklistChanges(aAddon, self.addon);
-        self.addon.updateDate = Date.now();
-        self.addon.installDate = aAddon ? aAddon.installDate : self.addon.updateDate;
-
-        if (!self.addon.isCompatible) {
+          applyBlocklistChanges(aAddon, this.addon);
+        this.addon.updateDate = Date.now();
+        this.addon.installDate = aAddon ? aAddon.installDate : this.addon.updateDate;
+
+        if (!this.addon.isCompatible) {
           // TODO Should we send some event here?
-          self.state = AddonManager.STATE_CHECKING;
-          new UpdateChecker(self.addon, {
-            onUpdateFinished: function(aAddon) {
-              self.state = AddonManager.STATE_DOWNLOADED;
-              XPIProvider.installs.push(self);
+          this.state = AddonManager.STATE_CHECKING;
+          new UpdateChecker(this.addon, {
+            onUpdateFinished: aAddon => {
+              this.state = AddonManager.STATE_DOWNLOADED;
+              XPIProvider.installs.push(this);
               AddonManagerPrivate.callInstallListeners("onNewInstall",
-                                                       self.listeners,
-                                                       self.wrapper);
-
-              aCallback(self);
+                                                       this.listeners,
+                                                       this.wrapper);
+
+              aCallback(this);
             }
           }, AddonManager.UPDATE_WHEN_ADDON_INSTALLED);
         }
         else {
-          XPIProvider.installs.push(self);
+          XPIProvider.installs.push(this);
           AddonManagerPrivate.callInstallListeners("onNewInstall",
-                                                   self.listeners,
-                                                   self.wrapper);
-
-          aCallback(self);
+                                                   this.listeners,
+                                                   this.wrapper);
+
+          aCallback(this);
         }
       });
     }, ([error, message]) => {
       logger.warn("Invalid XPI", message);
       this.state = AddonManager.STATE_DOWNLOAD_FAILED;
       this.error = error;
       AddonManagerPrivate.callInstallListeners("onNewInstall",
-                                               self.listeners,
-                                               self.wrapper);
+                                               this.listeners,
+                                               this.wrapper);
 
       aCallback(this);
     });
   },
 
   /**
    * Initialises this install to be a download from a remote url.
    *
@@ -5697,28 +5695,25 @@ AddonInstall.prototype = {
         this.crypto = null;
         if (this.hash && calculatedHash != this.hash.data) {
           this.downloadFailed(AddonManager.ERROR_INCORRECT_HASH,
                               "Downloaded file hash (" + calculatedHash +
                               ") did not match provided hash (" + this.hash.data + ")");
           return;
         }
 
-        let self = this;
         this.loadManifest(this.file).then(() => {
-          if (self.addon.isCompatible) {
-            self.downloadCompleted();
+          if (this.addon.isCompatible) {
+            this.downloadCompleted();
           }
           else {
             // TODO Should we send some event here (bug 557716)?
-            self.state = AddonManager.STATE_CHECKING;
-            new UpdateChecker(self.addon, {
-              onUpdateFinished: function(aAddon) {
-                self.downloadCompleted();
-              }
+            this.state = AddonManager.STATE_CHECKING;
+            new UpdateChecker(this.addon, {
+              onUpdateFinished: aAddon => this.downloadCompleted(),
             }, AddonManager.UPDATE_WHEN_ADDON_INSTALLED);
           }
         }, ([error, message]) => {
           this.downloadFailed(error, message);
         });
       }
       else {
         if (aRequest instanceof Ci.nsIHttpChannel)
@@ -5760,44 +5755,43 @@ AddonInstall.prototype = {
       logger.debug("downloadFailed: listener changed AddonInstall state for " +
           this.sourceURI.spec + " to " + this.state);
   },
 
   /**
    * Notify listeners that the download completed.
    */
   downloadCompleted: function() {
-    let self = this;
-    XPIDatabase.getVisibleAddonForID(this.addon.id, function(aAddon) {
+    XPIDatabase.getVisibleAddonForID(this.addon.id, aAddon => {
       if (aAddon)
-        self.existingAddon = aAddon;
-
-      self.state = AddonManager.STATE_DOWNLOADED;
-      self.addon.updateDate = Date.now();
-
-      if (self.existingAddon) {
-        self.addon.existingAddonID = self.existingAddon.id;
-        self.addon.installDate = self.existingAddon.installDate;
-        applyBlocklistChanges(self.existingAddon, self.addon);
+        this.existingAddon = aAddon;
+
+      this.state = AddonManager.STATE_DOWNLOADED;
+      this.addon.updateDate = Date.now();
+
+      if (this.existingAddon) {
+        this.addon.existingAddonID = this.existingAddon.id;
+        this.addon.installDate = this.existingAddon.installDate;
+        applyBlocklistChanges(this.existingAddon, this.addon);
       }
       else {
-        self.addon.installDate = self.addon.updateDate;
+        this.addon.installDate = this.addon.updateDate;
       }
 
       if (AddonManagerPrivate.callInstallListeners("onDownloadEnded",
-                                                   self.listeners,
-                                                   self.wrapper)) {
+                                                   this.listeners,
+                                                   this.wrapper)) {
         // If a listener changed our state then do not proceed with the install
-        if (self.state != AddonManager.STATE_DOWNLOADED)
+        if (this.state != AddonManager.STATE_DOWNLOADED)
           return;
 
-        self.install();
-
-        if (self.linkedInstalls) {
-          for (let install of self.linkedInstalls) {
+        this.install();
+
+        if (this.linkedInstalls) {
+          for (let install of this.linkedInstalls) {
             if (install.state == AddonManager.STATE_DOWNLOADED)
               install.install();
           }
         }
       }
     });
   },
 
@@ -6363,19 +6357,18 @@ UpdateChecker.prototype = {
           logger.debug("Found an existing AddonInstall for " + this.addon.id);
           sendUpdateAvailableMessages(this, currentInstall);
         }
         else
           sendUpdateAvailableMessages(this, null);
         return;
       }
 
-      let self = this;
-      AddonInstall.createUpdate(function(aInstall) {
-        sendUpdateAvailableMessages(self, aInstall);
+      AddonInstall.createUpdate(aInstall => {
+        sendUpdateAvailableMessages(this, aInstall);
       }, this.addon, update);
     }
     else {
       sendUpdateAvailableMessages(this, null);
     }
   },
 
   /**
@@ -7525,25 +7518,24 @@ Object.assign(MutableDirectoryInstallLoc
    *         otherwise they will only be copied
    * @return an nsIFile indicating where the add-on was installed to
    */
   installAddon: function(aId, aSource, aExistingAddonID, aCopy) {
     let trashDir = this.getTrashDir();
 
     let transaction = new SafeInstallOperation();
 
-    let self = this;
-    function moveOldAddon(aId) {
-      let file = self._directory.clone();
+    let moveOldAddon = aId => {
+      let file = this._directory.clone();
       file.append(aId);
 
       if (file.exists())
         transaction.moveUnder(file, trashDir);
 
-      file = self._directory.clone();
+      file = this._directory.clone();
       file.append(aId + ".xpi");
       if (file.exists()) {
         flushJarCache(file);
         transaction.moveUnder(file, trashDir);
       }
     }
 
     // If any of these operations fails the finally block will clean up the
--- a/toolkit/mozapps/extensions/nsBlocklistService.js
+++ b/toolkit/mozapps/extensions/nsBlocklistService.js
@@ -610,21 +610,18 @@ Blocklist.prototype = {
     var request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
                   createInstance(Ci.nsIXMLHttpRequest);
     request.open("GET", uri.spec, true);
     request.channel.notificationCallbacks = new gCertUtils.BadCertHandler();
     request.overrideMimeType("text/xml");
     request.setRequestHeader("Cache-Control", "no-cache");
     request.QueryInterface(Components.interfaces.nsIJSXMLHttpRequest);
 
-    var self = this;
-    request.addEventListener("error", function(event) {
-                                      self.onXMLError(event); }, false);
-    request.addEventListener("load", function(event) {
-                                     self.onXMLLoad(event);  }, false);
+    request.addEventListener("error", event => this.onXMLError(event), false);
+    request.addEventListener("load", event => this.onXMLLoad(event), false);
     request.send(null);
 
     // When the blocklist loads we need to compare it to the current copy so
     // make sure we have loaded it.
     if (!this._isBlocklistLoaded())
       this._loadBlocklist();
   },
 
@@ -1230,36 +1227,34 @@ Blocklist.prototype = {
 
     var addonList = [];
 
     // A helper function that reverts the prefs passed to default values.
     function resetPrefs(prefs) {
       for (let pref of prefs)
         gPref.clearUserPref(pref);
     }
-    var self = this;
     const types = ["extension", "theme", "locale", "dictionary", "service"];
-    AddonManager.getAddonsByTypes(types, function(addons) {
-
+    AddonManager.getAddonsByTypes(types, addons => {
       for (let addon of addons) {
         let oldState = Ci.nsIBlocklistService.STATE_NOTBLOCKED;
         if (oldAddonEntries)
-          oldState = self._getAddonBlocklistState(addon, oldAddonEntries);
-        let state = self.getAddonBlocklistState(addon);
+          oldState = this._getAddonBlocklistState(addon, oldAddonEntries);
+        let state = this.getAddonBlocklistState(addon);
 
         LOG("Blocklist state for " + addon.id + " changed from " +
             oldState + " to " + state);
 
         // We don't want to re-warn about add-ons
         if (state == oldState)
           continue;
 
         if (state === Ci.nsIBlocklistService.STATE_BLOCKED) {
           // It's a hard block. We must reset certain preferences.
-          let prefs = self._getAddonPrefs(addon);
+          let prefs = this._getAddonPrefs(addon);
           resetPrefs(prefs);
          }
 
         // Ensure that softDisabled is false if the add-on is not soft blocked
         if (state != Ci.nsIBlocklistService.STATE_SOFTBLOCKED)
           addon.softDisabled = false;
 
         // Don't warn about add-ons becoming unblocked.
@@ -1281,31 +1276,31 @@ Blocklist.prototype = {
 
         addonList.push({
           name: addon.name,
           version: addon.version,
           icon: addon.iconURL,
           disable: false,
           blocked: state == Ci.nsIBlocklistService.STATE_BLOCKED,
           item: addon,
-          url: self.getAddonBlocklistURL(addon),
+          url: this.getAddonBlocklistURL(addon),
         });
       }
 
       AddonManagerPrivate.updateAddonAppDisabledStates();
 
       var phs = Cc["@mozilla.org/plugin/host;1"].
                 getService(Ci.nsIPluginHost);
       var plugins = phs.getPluginTags();
 
       for (let plugin of plugins) {
         let oldState = -1;
         if (oldPluginEntries)
-          oldState = self._getPluginBlocklistState(plugin, oldPluginEntries);
-        let state = self.getPluginBlocklistState(plugin);
+          oldState = this._getPluginBlocklistState(plugin, oldPluginEntries);
+        let state = this.getPluginBlocklistState(plugin);
         LOG("Blocklist state for " + plugin.name + " changed from " +
             oldState + " to " + state);
         // We don't want to re-warn about items
         if (state == oldState)
           continue;
 
         if (oldState == Ci.nsIBlocklistService.STATE_BLOCKED) {
           if (state == Ci.nsIBlocklistService.STATE_SOFTBLOCKED)
@@ -1319,70 +1314,70 @@ Blocklist.prototype = {
                    state != Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE) {
             addonList.push({
               name: plugin.name,
               version: plugin.version,
               icon: "chrome://mozapps/skin/plugins/pluginGeneric.png",
               disable: false,
               blocked: state == Ci.nsIBlocklistService.STATE_BLOCKED,
               item: plugin,
-              url: self.getPluginBlocklistURL(plugin),
+              url: this.getPluginBlocklistURL(plugin),
             });
           }
         }
       }
 
       if (addonList.length == 0) {
-        self._notifyObserversBlocklistUpdated();
+        this._notifyObserversBlocklistUpdated();
         return;
       }
 
       if ("@mozilla.org/addons/blocklist-prompt;1" in Cc) {
         try {
           let blockedPrompter = Cc["@mozilla.org/addons/blocklist-prompt;1"]
                                  .getService(Ci.nsIBlocklistPrompt);
           blockedPrompter.prompt(addonList);
         } catch (e) {
           LOG(e);
         }
-        self._notifyObserversBlocklistUpdated();
+        this._notifyObserversBlocklistUpdated();
         return;
       }
 
       var args = {
         restart: false,
         list: addonList
       };
       // This lets the dialog get the raw js object
       args.wrappedJSObject = args;
 
       /*
         Some tests run without UI, so the async code listens to a message
         that can be sent programatically
       */
-      let applyBlocklistChanges = function() {
+      let applyBlocklistChanges = () => {
         for (let addon of addonList) {
           if (!addon.disable)
             continue;
 
           if (addon.item instanceof Ci.nsIPluginTag)
             addon.item.enabledState = Ci.nsIPluginTag.STATE_DISABLED;
           else {
             // This add-on is softblocked.
             addon.item.softDisabled = true;
             // We must revert certain prefs.
-            let prefs = self._getAddonPrefs(addon.item);
+            let prefs = this._getAddonPrefs(addon.item);
             resetPrefs(prefs);
           }
         }
 
         if (args.restart)
           restartApp();
 
-        self._notifyObserversBlocklistUpdated();
+        this._notifyObserversBlocklistUpdated();
         Services.obs.removeObserver(applyBlocklistChanges, "addon-blocklist-closed");
       }
 
       Services.obs.addObserver(applyBlocklistChanges, "addon-blocklist-closed", false);
 
       if (getPref("getBoolPref", PREF_BLOCKLIST_SUPPRESSUI, false)) {
         applyBlocklistChanges();
         return;