Bug 758950 - Part 2b: Use more for...of loops in Add-ons Manager frontend and backend code. r=Unfocused
authorMarcos S. <littledodgeviper@sbcglobal.net>
Mon, 17 Sep 2012 15:14:00 +1200
changeset 107951 cf12bddd0b41b30aed2cbed6e30064572d179096
parent 107950 4eb96cc64a6e6879631b74b20da9cec30b3ea4fa
child 107952 4900ae2923153aa1a3ddbe25f6353d56c52fa319
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersUnfocused
bugs758950
milestone18.0a1
Bug 758950 - Part 2b: Use more for...of loops in Add-ons Manager frontend and backend code. r=Unfocused
toolkit/mozapps/extensions/test/browser/browser_addonrepository_performance.js
toolkit/mozapps/extensions/test/browser/browser_bug557956.js
toolkit/mozapps/extensions/test/browser/browser_bug567127.js
toolkit/mozapps/extensions/test/browser/browser_bug581076.js
toolkit/mozapps/extensions/test/browser/browser_checkAddonCompatibility.js
toolkit/mozapps/extensions/test/browser/browser_discovery.js
toolkit/mozapps/extensions/test/browser/browser_dragdrop.js
toolkit/mozapps/extensions/test/browser/browser_searching.js
toolkit/mozapps/extensions/test/browser/browser_select_selection.js
toolkit/mozapps/extensions/test/browser/browser_sorting.js
toolkit/mozapps/extensions/test/browser/head.js
--- a/toolkit/mozapps/extensions/test/browser/browser_addonrepository_performance.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_addonrepository_performance.js
@@ -9,20 +9,20 @@ Components.utils.import("resource://gre/
 let AddonRepository = tmp.AddonRepository;
 
 var gManagerWindow;
 var gProvider;
 
 function parseParams(aQuery) {
   let params = {};
 
-  aQuery.split("&").forEach(function(aParam) {
-    let [key, value] = aParam.split("=");
+  for (let param of aQuery.split("&")) {
+    let [key, value] = param.split("=");
     params[key] = value;
-  });
+  }
 
   return params;
 }
 
 function test() {
   waitForExplicitFinish();
 
   var gSeenRequest = false;
--- a/toolkit/mozapps/extensions/test/browser/browser_bug557956.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug557956.js
@@ -32,81 +32,81 @@ function test() {
   waitForExplicitFinish();
 
   run_next_test();
 }
 
 function end_test() {
   // Test generates a lot of available installs so just cancel them all
   AddonManager.getAllInstalls(function(aInstalls) {
-    aInstalls.forEach(function(aInstall) {
-      aInstall.cancel();
-    });
+    for (let install of aInstalls)
+      install.cancel();
 
     finish();
   });
 }
 
 function install_test_addons(aCallback) {
   var installs = [];
 
   // Use a blank update URL
   Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "missing.rdf");
 
-  ["browser_bug557956_1",
-   "browser_bug557956_2",
-   "browser_bug557956_3",
-   "browser_bug557956_4",
-   "browser_bug557956_5",
-   "browser_bug557956_6",
-   "browser_bug557956_7",
-   "browser_bug557956_8_1",
-   "browser_bug557956_9_1",
-   "browser_bug557956_10"].forEach(function(aName) {
-    AddonManager.getInstallForURL(TESTROOT + "addons/" + aName + ".xpi", function(aInstall) {
+  let names = ["browser_bug557956_1",
+               "browser_bug557956_2",
+               "browser_bug557956_3",
+               "browser_bug557956_4",
+               "browser_bug557956_5",
+               "browser_bug557956_6",
+               "browser_bug557956_7",
+               "browser_bug557956_8_1",
+               "browser_bug557956_9_1",
+               "browser_bug557956_10"];
+  for (let name of names) {
+    AddonManager.getInstallForURL(TESTROOT + "addons/" + name + ".xpi", function(aInstall) {
       installs.push(aInstall);
     }, "application/x-xpinstall");
-  });
+  }
 
   var listener = {
     installCount: 0,
 
     onInstallEnded: function() {
       this.installCount++;
       if (this.installCount == installs.length) {
         // Switch to the test update URL
         Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "browser_bug557956.rdf");
 
         aCallback();
       }
     }
   };
 
-  installs.forEach(function(aInstall) {
-    aInstall.addListener(listener);
-    aInstall.install();
-  });
+  for (let install of installs) {
+    install.addListener(listener);
+    install.install();
+  }
 }
 
 function uninstall_test_addons(aCallback) {
   AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
                                "addon2@tests.mozilla.org",
                                "addon3@tests.mozilla.org",
                                "addon4@tests.mozilla.org",
                                "addon5@tests.mozilla.org",
                                "addon6@tests.mozilla.org",
                                "addon7@tests.mozilla.org",
                                "addon8@tests.mozilla.org",
                                "addon9@tests.mozilla.org",
                                "addon10@tests.mozilla.org"],
                                function(aAddons) {
-    aAddons.forEach(function(aAddon) {
-      if (aAddon)
-        aAddon.uninstall();
-    });
+    for (let addon of aAddons) {
+      if (addon)
+        addon.uninstall();
+    }
     aCallback();
   });
 }
 
 function open_compatibility_window(aInactiveAddonIds, aCallback) {
   // This will reset the longer timeout multiplier to 2 which will give each
   // test that calls open_compatibility_window a minimum of 60 seconds to
   // complete.
@@ -348,19 +348,18 @@ add_test(function() {
                                  "addon4@tests.mozilla.org",
                                  "addon5@tests.mozilla.org",
                                  "addon6@tests.mozilla.org",
                                  "addon7@tests.mozilla.org",
                                  "addon8@tests.mozilla.org",
                                  "addon9@tests.mozilla.org",
                                  "addon10@tests.mozilla.org"],
                                  function(aAddons) {
-      aAddons.forEach(function(aAddon) {
-        aAddon.userDisabled = true;
-      });
+      for (let addon of aAddons)
+        addon.userDisabled = true;
 
       // These add-ons were inactive in the old application
       var inactiveAddonIds = [
         "addon1@tests.mozilla.org",
         "addon2@tests.mozilla.org",
         "addon3@tests.mozilla.org",
         "addon4@tests.mozilla.org",
         "addon5@tests.mozilla.org",
@@ -384,19 +383,18 @@ add_test(function() {
 // Tests that the right UI shows for when no updates are available
 add_test(function() {
   install_test_addons(function() {
     AddonManager.getAddonsByIDs(["addon7@tests.mozilla.org",
                                  "addon8@tests.mozilla.org",
                                  "addon9@tests.mozilla.org",
                                  "addon10@tests.mozilla.org"],
                                  function(aAddons) {
-      aAddons.forEach(function(aAddon) {
-        aAddon.uninstall();
-      });
+      for (let addon of aAddons)
+        addon.uninstall();
 
       // These add-ons were inactive in the old application
       var inactiveAddonIds = [
         "addon2@tests.mozilla.org",
         "addon4@tests.mozilla.org",
         "addon5@tests.mozilla.org"
       ];
 
@@ -445,22 +443,23 @@ add_test(function() {
                                  "addon4@tests.mozilla.org",
                                  "addon5@tests.mozilla.org",
                                  "addon6@tests.mozilla.org",
                                  "addon7@tests.mozilla.org",
                                  "addon8@tests.mozilla.org",
                                  "addon9@tests.mozilla.org",
                                  "addon10@tests.mozilla.org"],
                                  function(aAddons) {
-      aAddons.forEach(function(aAddon) {
-        if (aAddon.id == "addon10@tests.mozilla.org")
-          is(aAddon.isCompatible, true, "Addon10 should be compatible before compat overrides are refreshed");
+
+      for (let addon of aAddons) {
+        if (addon.id == "addon10@tests.mozilla.org")
+          is(addon.isCompatible, true, "Addon10 should be compatible before compat overrides are refreshed");
         else
-          aAddon.uninstall();
-      });
+          addon.uninstall();
+      }
 
       Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, TESTROOT + "browser_bug557956.xml");
       Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
 
       open_compatibility_window([], function(aWindow) {
         var doc = aWindow.document;
         wait_for_page(aWindow, "mismatch", function(aWindow) {
           var items = get_list_names(doc.getElementById("mismatch.incompatible"));
--- a/toolkit/mozapps/extensions/test/browser/browser_bug567127.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug567127.js
@@ -79,27 +79,26 @@ var gInstallNotificationObserver = {
   }
 };
 
 
 function test_confirmation(aWindow, aExpectedURLs) {
   var list = aWindow.document.getElementById("itemList");
   is(list.childNodes.length, aExpectedURLs.length, "Should be the right number of installs");
 
-  aExpectedURLs.forEach(function(aURL) {
-    var node = list.firstChild;
-    while (node) {
-      if (node.url == aURL) {
-        ok(true, "Should have seen " + aURL + " in the list");
-        return;
+  for (let url of aExpectedURLs) {
+    let found = false;
+    for (let node of list.children) {
+      if (node.url == url) {
+        found = true;
+        break;
       }
-      node = node.nextSibling;
     }
-    ok(false, "Should have seen " + aURL + " in the list");
-  });
+    ok(found, "Should have seen " + url + " in the list");
+  }
 
   aWindow.document.documentElement.cancelDialog();
 }
 
 
 function test() {
   waitForExplicitFinish();
   
--- a/toolkit/mozapps/extensions/test/browser/browser_bug581076.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug581076.js
@@ -24,19 +24,18 @@ function test() {
     gManagerWindow = aWindow;
     run_next_test();
   });
 }
 
 function end_test() {
   // Test generates a lot of available installs so just cancel them all
   AddonManager.getAllInstalls(function(aInstalls) {
-    aInstalls.forEach(function(aInstall) {
-      aInstall.cancel();
-    });
+    for (let install of aInstalls)
+      install.cancel();
 
     close_manager(gManagerWindow, finish);
   });
 }
 
 function search(aRemoteSearch, aCallback) {
   waitForFocus(function() {
     var searchBox = gManagerWindow.document.getElementById("header-search");
--- a/toolkit/mozapps/extensions/test/browser/browser_checkAddonCompatibility.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_checkAddonCompatibility.js
@@ -12,23 +12,23 @@ function test() {
 
   AddonManager.getAllAddons(function gAACallback(aAddons) {
     // Sort add-ons (by type and name) to improve output.
     aAddons.sort(function compareTypeName(a, b) {
       return a.type.localeCompare(b.type) || a.name.localeCompare(b.name);
     });
 
     let allCompatible = true;
-    aAddons.forEach(function checkCompatibility(a) {
+    for (let a of aAddons) {
       // Ignore plugins.
       if (a.type == "plugin")
-        return;
+        continue;
 
       ok(a.isCompatible, a.type + " " + a.name + " " + a.version + " should be compatible");
       allCompatible = allCompatible && a.isCompatible;
-    });
+    }
     // Add a reminder.
     if (!allCompatible)
       ok(false, "As this test failed, test browser_bug557956.js should have failed, too.");
 
     finish();
   });
 }
--- a/toolkit/mozapps/extensions/test/browser/browser_discovery.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_discovery.js
@@ -125,34 +125,33 @@ function testHash(aBrowser, aTestAddonVi
   if (aTestAddonVisible[2])
     ok("addon3@tests.mozilla.org" in data, "Test add-on 3 should be listed");
   else
     ok(!("addon3@tests.mozilla.org" in data), "Test add-on 3 should not be listed");
 
   // Test against all the add-ons the manager knows about since plugins and
   // app extensions may exist
   AddonManager.getAllAddons(function(aAddons) {
-    aAddons.forEach(function(aAddon) {
-      if (!(aAddon.id in data)) {
+    for (let addon of aAddons) {
+      if (!(addon.id in data)) {
         // Test add-ons will have shown an error if necessary above
-        if (aAddon.id.substring(6) != "@tests.mozilla.org")
-          ok(false, "Add-on " + aAddon.id + " was not included in the data");
-        return;
+        if (addon.id.substring(6) != "@tests.mozilla.org")
+          ok(false, "Add-on " + addon.id + " was not included in the data");
+        continue;
       }
 
-      info("Testing data for add-on " + aAddon.id);
-      var addonData = data[aAddon.id];
-      is(addonData.name, aAddon.name, "Name should be correct");
-      is(addonData.version, aAddon.version, "Version should be correct");
-      is(addonData.type, aAddon.type, "Type should be correct");
-      is(addonData.userDisabled, aAddon.userDisabled, "userDisabled should be correct");
-      is(addonData.isBlocklisted, aAddon.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED, "blocklisted should be correct");
-      is(addonData.isCompatible, aAddon.isCompatible, "isCompatible should be correct");
-    });
-
+      info("Testing data for add-on " + addon.id);
+      var addonData = data[addon.id];
+      is(addonData.name, addon.name, "Name should be correct");
+      is(addonData.version, addon.version, "Version should be correct");
+      is(addonData.type, addon.type, "Type should be correct");
+      is(addonData.userDisabled, addon.userDisabled, "userDisabled should be correct");
+      is(addonData.isBlocklisted, addon.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED, "blocklisted should be correct");
+      is(addonData.isCompatible, addon.isCompatible, "isCompatible should be correct");
+    }
     aCallback();
   });
 }
 
 function isLoading() {
   var loading = gManagerWindow.document.getElementById("discover-view").selectedPanel ==
                 gManagerWindow.document.getElementById("discover-loading");
   if (loading) {
--- a/toolkit/mozapps/extensions/test/browser/browser_dragdrop.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_dragdrop.js
@@ -100,27 +100,26 @@ function end_test() {
     finish();
   });
 }
 
 function test_confirmation(aWindow, aExpectedURLs) {
   var list = aWindow.document.getElementById("itemList");
   is(list.childNodes.length, aExpectedURLs.length, "Should be the right number of installs");
 
-  aExpectedURLs.forEach(function(aURL) {
-    var node = list.firstChild;
-    while (node) {
-      if (node.url == aURL) {
-        ok(true, "Should have seen " + aURL + " in the list");
-        return;
+  for (let url of aExpectedURLs) {
+    let found = false;
+    for (let node of list.children) {
+      if (node.url == url) {
+        found = true;
+        break;
       }
-      node = node.nextSibling;
     }
-    ok(false, "Should have seen " + aURL + " in the list");
-  });
+    ok(found, "Should have seen " + url + " in the list");
+  }
 
   aWindow.document.documentElement.cancelDialog();
 }
 
 // Simulates dropping a URL onto the manager
 add_test(function() {
   var url = TESTROOT + "addons/browser_dragdrop1.xpi";
 
--- a/toolkit/mozapps/extensions/test/browser/browser_searching.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_searching.js
@@ -56,17 +56,18 @@ function test() {
     name: "PASS - g - reSEARCHing SEARCH",
     sourceURI: "http://example.com/install2.xpi"
   }, {
     // Does not match query
     name: "FAIL",
     sourceURI: "http://example.com/fail-install1.xpi"
   }]);
 
-  installs.forEach(function(aInstall) { aInstall.install(); });
+  for (let install of installs )
+    install.install();
 
   open_manager("addons://list/extension", function(aWindow) {
     gManagerWindow = aWindow;
     gCategoryUtilities = new CategoryUtilities(gManagerWindow);
     run_next_test();
   });
 }
 
--- a/toolkit/mozapps/extensions/test/browser/browser_select_selection.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_select_selection.js
@@ -98,48 +98,49 @@ function test() {
 
   gProvider = new MockProvider();
 
   // Set prefs for Distributed Extension Source tests.
   Services.prefs.setBoolPref("extensions.installedDistroAddon.test3@tests.mozilla.org", true);
   Services.prefs.setBoolPref("extensions.installedDistroAddon.test12@tests.mozilla.org", true);
   Services.prefs.setBoolPref("extensions.installedDistroAddon.test15@tests.mozilla.org", true);
 
-  ADDONS.forEach(function(aAddon, aPos) {
-    var addon = new MockAddon("test" + aPos + "@tests.mozilla.org",
-                              "Test Add-on " + aPos, "extension");
+  for (let pos in ADDONS) {
+    let addonItem = ADDONS[pos];
+    let addon = new MockAddon("test" + pos + "@tests.mozilla.org",
+                              "Test Add-on " + pos, "extension");
     addon.version = "1.0";
-    addon.userDisabled = aAddon[0];
-    addon.appDisabled = aAddon[1];
-    addon.isActive = aAddon[3];
-    addon.applyBackgroundUpdates = aAddon[5] ? AddonManager.AUTOUPDATE_ENABLE
+    addon.userDisabled = addonItem[0];
+    addon.appDisabled = addonItem[1];
+    addon.isActive = addonItem[3];
+    addon.applyBackgroundUpdates = addonItem[5] ? AddonManager.AUTOUPDATE_ENABLE
                                              : AddonManager.AUTOUPDATE_DISABLE;
-    addon.scope = aAddon[6];
+    addon.scope = addonItem[6];
 
     // Remove the upgrade permission from non-profile add-ons
     if (addon.scope != AddonManager.SCOPE_PROFILE)
       addon._permissions -= AddonManager.PERM_CAN_UPGRADE;
 
     addon.findUpdates = function(aListener, aReason, aAppVersion, aPlatformVersion) {
-      addon.appDisabled = aAddon[2];
+      addon.appDisabled = addonItem[2];
       addon.isActive = addon.shouldBeActive;
 
-      if (aAddon[4]) {
+      if (addonItem[4]) {
         var newAddon = new MockAddon(this.id, this.name, "extension");
         newAddon.version = "2.0";
         var install = new MockInstall(this.name, this.type, newAddon);
         install.existingAddon = this;
         aListener.onUpdateAvailable(this, install);
       }
 
       aListener.onUpdateFinished(this, AddonManager.UPDATE_STATUS_NO_ERROR);
     };
 
     gProvider.addAddon(addon);
-  });
+  }
 
   gWin = Services.ww.openWindow(null,
                                 "chrome://mozapps/content/extensions/selectAddons.xul",
                                 "",
                                 "chrome,centerscreen,dialog,titlebar",
                                 null);
   waitForFocus(function() {
     waitForView("select", run_next_test);
--- a/toolkit/mozapps/extensions/test/browser/browser_sorting.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_sorting.js
@@ -207,19 +207,18 @@ function set_order(aSortBy, aAscending) 
   var list = gManagerWindow.document.getElementById("addon-list");
   var elements = [];
   var node = list.firstChild;
   while (node) {
     elements.push(node);
     node = node.nextSibling;
   }
   gManagerWindow.sortElements(elements, ["uiState", aSortBy], aAscending);
-  elements.forEach(function(aElement) {
-    list.appendChild(aElement);
-  });
+  for (let element of elements)
+    list.appendChild(element);
 }
 
 function check_order(aExpectedOrder) {
   var order = [];
   var list = gManagerWindow.document.getElementById("addon-list");
   var node = list.firstChild;
   while (node) {
     var id = node.getAttribute("value");
--- a/toolkit/mozapps/extensions/test/browser/head.js
+++ b/toolkit/mozapps/extensions/test/browser/head.js
@@ -64,45 +64,45 @@ var gRestorePrefs = [{name: PREF_LOGGING
                      {name: "extensions.getAddons.getWithPerformance.url"},
                      {name: "extensions.getAddons.search.browseURL"},
                      {name: "extensions.getAddons.search.url"},
                      {name: "extensions.getAddons.cache.enabled"},
                      {name: PREF_SEARCH_MAXRESULTS},
                      {name: PREF_STRICT_COMPAT},
                      {name: PREF_CHECK_COMPATIBILITY}];
 
-gRestorePrefs.forEach(function(aPref) {
-  if (!Services.prefs.prefHasUserValue(aPref.name)) {
-    aPref.type = "clear";
-    return;
+for (let pref of gRestorePrefs) {
+  if (!Services.prefs.prefHasUserValue(pref.name)) {
+    pref.type = "clear";
+    continue;
   }
-  aPref.type = Services.prefs.getPrefType(aPref.name);
-  if (aPref.type == Services.prefs.PREF_BOOL)
-    aPref.value = Services.prefs.getBoolPref(aPref.name);
-  else if (aPref.type == Services.prefs.PREF_INT)
-    aPref.value = Services.prefs.getIntPref(aPref.name);
-  else if (aPref.type == Services.prefs.PREF_STRING)
-    aPref.value = Services.prefs.getCharPref(aPref.name);
-});
+  pref.type = Services.prefs.getPrefType(pref.name);
+  if (pref.type == Services.prefs.PREF_BOOL)
+    pref.value = Services.prefs.getBoolPref(pref.name);
+  else if (pref.type == Services.prefs.PREF_INT)
+    pref.value = Services.prefs.getIntPref(pref.name);
+  else if (pref.type == Services.prefs.PREF_STRING)
+    pref.value = Services.prefs.getCharPref(pref.name);
+}
 
 // Turn logging on for all tests
 Services.prefs.setBoolPref(PREF_LOGGING_ENABLED, true);
 
 registerCleanupFunction(function() {
   // Restore prefs
-  gRestorePrefs.forEach(function(aPref) {
-    if (aPref.type == "clear")
-      Services.prefs.clearUserPref(aPref.name);
-    else if (aPref.type == Services.prefs.PREF_BOOL)
-      Services.prefs.setBoolPref(aPref.name, aPref.value);
-    else if (aPref.type == Services.prefs.PREF_INT)
-      Services.prefs.setIntPref(aPref.name, aPref.value);
-    else if (aPref.type == Services.prefs.PREF_STRING)
-      Services.prefs.setCharPref(aPref.name, aPref.value);
-  });
+  for (let pref of gRestorePrefs) {
+    if (pref.type == "clear")
+      Services.prefs.clearUserPref(pref.name);
+    else if (pref.type == Services.prefs.PREF_BOOL)
+      Services.prefs.setBoolPref(pref.name, pref.value);
+    else if (pref.type == Services.prefs.PREF_INT)
+      Services.prefs.setIntPref(pref.name, pref.value);
+    else if (pref.type == Services.prefs.PREF_STRING)
+      Services.prefs.setCharPref(pref.name, pref.value);
+  }
 
   // Throw an error if the add-ons manager window is open anywhere
   var windows = Services.wm.getEnumerator("Addons:Manager");
   if (windows.hasMoreElements())
     ok(false, "Found unexpected add-ons manager window still open");
   while (windows.hasMoreElements())
     windows.getNext().QueryInterface(Ci.nsIDOMWindow).close();
 
@@ -117,23 +117,23 @@ registerCleanupFunction(function() {
     ok(false, "Found unexpected add-ons installation window still open");
   while (windows.hasMoreElements())
     windows.getNext().QueryInterface(Ci.nsIDOMWindow).close();
 
 
   // We can for now know that getAllInstalls actually calls its callback before
   // it returns so this will complete before the next test start.
   AddonManager.getAllInstalls(function(aInstalls) {
-    aInstalls.forEach(function(aInstall) {
-      if (aInstall instanceof MockInstall)
-        return;
+    for (let install of aInstalls) {
+      if (install instanceof MockInstall)
+        continue;
 
-      ok(false, "Should not have seen an install of " + aInstall.sourceURI.spec + " in state " + aInstall.state);
-      aInstall.cancel();
-    });
+      ok(false, "Should not have seen an install of " + install.sourceURI.spec + " in state " + install.state);
+      install.cancel();
+    }
   });
 });
 
 function log_exceptions(aCallback, ...aArgs) {
   try {
     return aCallback.apply(null, aArgs);
   }
   catch (e) {
@@ -658,73 +658,73 @@ MockProvider.prototype = {
    * managed by this provider.
    *
    * @param  aAddonProperties
    *         An array of objects containing properties describing the add-ons
    * @return Array of the new MockAddons
    */
   createAddons: function MP_createAddons(aAddonProperties) {
     var newAddons = [];
-    aAddonProperties.forEach(function(aAddonProp) {
-      var addon = new MockAddon(aAddonProp.id);
-      for (var prop in aAddonProp) {
+    for (let addonProp of aAddonProperties) {
+      let addon = new MockAddon(addonProp.id);
+      for (let prop in addonProp) {
         if (prop == "id")
           continue;
         if (prop == "applyBackgroundUpdates") {
-          addon._applyBackgroundUpdates = aAddonProp[prop];
+          addon._applyBackgroundUpdates = addonProp[prop];
           continue;
         }
         if (prop == "appDisabled") {
-          addon._appDisabled = aAddonProp[prop];
+          addon._appDisabled = addonProp[prop];
           continue;
         }
-        addon[prop] = aAddonProp[prop];
+        addon[prop] = addonProp[prop];
       }
       if (!addon.optionsType && !!addon.optionsURL)
         addon.optionsType = AddonManager.OPTIONS_TYPE_DIALOG;
 
       // Make sure the active state matches the passed in properties
       addon.isActive = addon.shouldBeActive;
 
       this.addAddon(addon);
       newAddons.push(addon);
-    }, this);
+    }
 
     return newAddons;
   },
 
   /**
    * Creates a set of mock add-on install objects and adds them to the list
    * of installs managed by this provider.
    *
    * @param  aInstallProperties
    *         An array of objects containing properties describing the installs
    * @return Array of the new MockInstalls
    */
   createInstalls: function MP_createInstalls(aInstallProperties) {
     var newInstalls = [];
-    aInstallProperties.forEach(function(aInstallProp) {
-      var install = new MockInstall(aInstallProp.name || null,
-                                    aInstallProp.type || null,
+    for (let installProp of aInstallProperties) {
+      let install = new MockInstall(installProp.name || null,
+                                    installProp.type || null,
                                     null);
-      for (var prop in aInstallProp) {
+      for (let prop in installProp) {
         switch (prop) {
           case "name":
           case "type":
             break;
           case "sourceURI":
-            install[prop] = NetUtil.newURI(aInstallProp[prop]);
+            install[prop] = NetUtil.newURI(installProp[prop]);
             break;
           default:
-            install[prop] = aInstallProp[prop];
+            install[prop] = installProp[prop];
         }
       }
       this.addInstall(install);
       newInstalls.push(install);
-    }, this);
+    }
 
     return newInstalls;
   },
 
   /***** AddonProvider implementation *****/
 
   /**
    * Called to initialize the provider.
@@ -732,19 +732,18 @@ MockProvider.prototype = {
   startup: function MP_startup() {
     this.started = true;
   },
 
   /**
    * Called when the provider should shutdown.
    */
   shutdown: function MP_shutdown() {
-    this.callbackTimers.forEach(function(aTimer) {
-      aTimer.cancel();
-    });
+    for (let timer of this.callbackTimers)
+      timer.cancel();
     this.callbackTimers = [];
 
     this.started = false;
   },
 
   /**
    * Called to get an Addon with a particular ID.
    *
@@ -1213,23 +1212,23 @@ MockInstall.prototype = {
   },
 
   callListeners: function(aMethod) {
     var result = AddonManagerPrivate.callInstallListeners(aMethod, this.listeners,
                                                           this, this.addon);
 
     // Call test listeners after standard listeners to remove race condition
     // between standard and test listeners
-    this.testListeners.forEach(function(aListener) {
+    for (let listener of this.testListeners) {
       try {
-        if (aMethod in aListener)
-          if (aListener[aMethod].call(aListener, this, this.addon) === false)
+        if (aMethod in listener)
+          if (listener[aMethod].call(listener, this, this.addon) === false)
             result = false;
       }
       catch (e) {
         ok(false, "Test listener threw exception: " + e);
       }
-    }, this);
+    }
 
     return result;
   }
 };