Bug 1544834 - Replace non-test uses of deprecated Array generics r=evilpie,dao
authorRob Wu <rob@robwu.nl>
Wed, 17 Apr 2019 19:03:17 +0000
changeset 470065 0d59dd598e5eb0b7b4618d68d6884c947eb658d6
parent 470064 53793d2ea3ece905e5847018f9c7595585f8f388
child 470066 edb8832eafa11ea93d652b277ac192f7ae0a2c19
push id112843
push useraiakab@mozilla.com
push dateFri, 19 Apr 2019 09:50:22 +0000
treeherdermozilla-inbound@c06f27cbfe40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersevilpie, dao
bugs1544834
milestone68.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 1544834 - Replace non-test uses of deprecated Array generics r=evilpie,dao - `Array.forEach` becomes for-of loop or `array.forEach`. - `Array.slice(a)` or `Array.slice(a, 0)` becomes `Array.from(a)`. - `Array.map` becomes `Array.from` - `Array` copy + concatenation becomes Array literal + spread syntax. - All other `Array.X(a, ...)` become `Array.prototype.X.call` or `Array.from(a).X(...)` Differential Revision: https://phabricator.services.mozilla.com/D27802
browser/base/content/browser-ctrlTab.js
browser/base/content/pageinfo/pageInfo.js
browser/base/content/tabbrowser.xml
browser/components/customizableui/CustomizeMode.jsm
browser/components/downloads/DownloadsCommon.jsm
browser/components/downloads/content/allDownloadsView.js
browser/components/sessionstore/SessionStore.jsm
browser/modules/AsyncTabSwitcher.jsm
devtools/client/performance/views/toolbar.js
devtools/client/shared/widgets/AbstractTreeItem.jsm
devtools/server/actors/webconsole/utils.js
dom/browser-element/BrowserElementParent.jsm
mobile/android/chrome/content/ConsoleAPI.js
mobile/android/modules/geckoview/GeckoViewConsole.jsm
netwerk/streamconv/converters/nsIndexedToHTML.cpp
services/common/async.js
toolkit/components/downloads/DownloadList.jsm
toolkit/components/downloads/DownloadUIHelper.jsm
toolkit/components/passwordmgr/LoginManagerContent.jsm
toolkit/content/widgets/notificationbox.js
toolkit/content/widgets/richlistbox.js
toolkit/content/widgets/richlistbox.xml
toolkit/content/widgets/scrollbox.xml
toolkit/content/widgets/tabbox.js
toolkit/content/widgets/tree.js
toolkit/modules/PopupNotifications.jsm
toolkit/mozapps/extensions/content/extensions.js
--- a/browser/base/content/browser-ctrlTab.js
+++ b/browser/base/content/browser-ctrlTab.js
@@ -284,17 +284,18 @@ var ctrlTab = {
       aPreview.hidden = true;
       aPreview._label.removeAttribute("value");
       aPreview.removeAttribute("tooltiptext");
       aPreview._favicon.removeAttribute("src");
     }
   },
 
   advanceFocus: function ctrlTab_advanceFocus(aForward) {
-    let selectedIndex = Array.indexOf(this.previews, this.selected);
+    let selectedIndex = Array.prototype.indexOf.call(this.previews,
+      this.selected);
     do {
       selectedIndex += aForward ? 1 : -1;
       if (selectedIndex < 0)
         selectedIndex = this.previews.length - 1;
       else if (selectedIndex >= this.previews.length)
         selectedIndex = 0;
     } while (this.previews[selectedIndex].hidden);
 
@@ -560,17 +561,17 @@ var ctrlTab = {
     for (let i = 0; i < thumbnailCount; i++)
       urls.push(this.tabList[i].linkedBrowser.currentURI.spec);
 
     aCallback(urls);
   },
 
   _initRecentlyUsedTabs() {
     this._recentlyUsedTabs =
-      Array.filter(gBrowser.tabs, tab => !tab.closing)
+      Array.prototype.filter.call(gBrowser.tabs, tab => !tab.closing)
            .sort((tab1, tab2) => tab2.lastAccessed - tab1.lastAccessed);
   },
 
   _init: function ctrlTab__init(enable) {
     var toggleEventListener = enable ? "addEventListener" : "removeEventListener";
 
     window[toggleEventListener]("SSWindowRestored", this);
 
--- a/browser/base/content/pageinfo/pageInfo.js
+++ b/browser/base/content/pageinfo/pageInfo.js
@@ -96,20 +96,20 @@ pageInfoTreeView.prototype = {
         this,
         this.data,
         treecol.index,
         function textComparator(a, b) { return (a || "").toLowerCase().localeCompare((b || "").toLowerCase()); },
         this.sortcol,
         this.sortdir
       );
 
-    Array.forEach(tree.columns, function(col) {
+    for (let col of tree.columns) {
       col.element.removeAttribute("sortActive");
       col.element.removeAttribute("sortDirection");
-    });
+    }
     treecol.element.setAttribute("sortActive", "true");
     treecol.element.setAttribute("sortDirection", this.sortdir ?
                                                   "ascending" : "descending");
 
     this.sortcol = treecol.index;
   },
 
   getRowProperties(row) { return ""; },
@@ -190,20 +190,20 @@ gImageView.onPageMediaSort = function(co
       this,
       this.data,
       index,
       comparator,
       this.sortcol,
       this.sortdir
     );
 
-  Array.forEach(tree.columns, function(col) {
+  for (let col of tree.columns) {
     col.element.removeAttribute("sortActive");
     col.element.removeAttribute("sortDirection");
-  });
+  }
   treecol.element.setAttribute("sortActive", "true");
   treecol.element.setAttribute("sortDirection", this.sortdir ?
                                                 "ascending" : "descending");
 
   this.sortcol = index;
 };
 
 var gImageHash = { };
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -175,17 +175,17 @@
             this.setAttribute("overflow", "true");
             this._positionPinnedTabs();
             this._handleTabSelect(true);
           });
 
           // Override scrollbox.xml method, since our scrollbox's children are
           // inherited from the scrollbox binding parent (this).
           arrowScrollbox._getScrollableElements = () => {
-            return Array.filter(this.children, arrowScrollbox._canScrollToElement);
+            return Array.prototype.filter.call(this.children, arrowScrollbox._canScrollToElement);
           };
           arrowScrollbox._canScrollToElement = tab => {
             return !tab._pinnedUnscrollable && !tab.hidden;
           };
         ]]></body>
       </method>
 
       <method name="observe">
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -1696,17 +1696,17 @@ CustomizeMode.prototype = {
       // they're attempting to append a child to that target.
       dragOverItem = (targetAreaType == "toolbar"
                         ? this._findVisiblePreviousSiblingNode(targetNode.lastElementChild)
                         : targetNode.lastElementChild) ||
                      targetNode;
       dragValue = "after";
     } else {
       let targetParent = targetNode.parentNode;
-      let position = Array.indexOf(targetParent.children, targetNode);
+      let position = Array.prototype.indexOf.call(targetParent.children, targetNode);
       if (position == -1) {
         dragOverItem = (targetAreaType == "toolbar"
                           ? this._findVisiblePreviousSiblingNode(targetNode.lastElementChild)
                           : targetNode.lastElementChild);
         dragValue = "after";
       } else {
         dragOverItem = targetParent.children[position];
         if (targetAreaType == "toolbar") {
--- a/browser/components/downloads/DownloadsCommon.jsm
+++ b/browser/components/downloads/DownloadsCommon.jsm
@@ -148,24 +148,24 @@ var DownloadsCommon = {
     let strings = {};
     let sb = Services.strings.createBundle(kDownloadsStringBundleUrl);
     for (let string of sb.getSimpleEnumeration()) {
       let stringName = string.key;
       if (stringName in kDownloadsStringsRequiringFormatting) {
         strings[stringName] = function() {
           // Convert "arguments" to a real array before calling into XPCOM.
           return sb.formatStringFromName(stringName,
-                                         Array.slice(arguments, 0),
+                                         Array.from(arguments),
                                          arguments.length);
         };
       } else if (stringName in kDownloadsStringsRequiringPluralForm) {
         strings[stringName] = function(aCount) {
           // Convert "arguments" to a real array before calling into XPCOM.
           let formattedString = sb.formatStringFromName(stringName,
-                                         Array.slice(arguments, 0),
+                                         Array.from(arguments),
                                          arguments.length);
           return PluralForm.get(aCount, formattedString);
         };
       } else {
         strings[stringName] = string.value;
       }
     }
     delete this.strings;
--- a/browser/components/downloads/content/allDownloadsView.js
+++ b/browser/components/downloads/content/allDownloadsView.js
@@ -290,18 +290,19 @@ DownloadsPlacesView.prototype = {
       // XXXmano: places.js relies on this behavior (see Bug 822203).
       this.searchTerm = "";
     } else {
       this._place = val;
     }
   },
 
   get selectedNodes() {
-      return Array.filter(this._richlistbox.selectedItems,
-                          element => element._shell.download.placesNode);
+    return Array.prototype.filter.call(
+      this._richlistbox.selectedItems,
+      element => element._shell.download.placesNode);
   },
 
   get selectedNode() {
     let selectedNodes = this.selectedNodes;
     return selectedNodes.length == 1 ? selectedNodes[0] : null;
   },
 
   get hasSelection() {
@@ -496,24 +497,25 @@ DownloadsPlacesView.prototype = {
         return this._richlistbox.selectedItems.length == 1;
       case "cmd_selectAll":
         return true;
       case "cmd_paste":
         return this._canDownloadClipboardURL();
       case "downloadsCmd_clearDownloads":
         return this.canClearDownloads(this._richlistbox);
       default:
-        return Array.every(this._richlistbox.selectedItems,
-                           element => element._shell.isCommandEnabled(aCommand));
+        return Array.prototype.every.call(
+          this._richlistbox.selectedItems,
+          element => element._shell.isCommandEnabled(aCommand));
     }
   },
 
   _copySelectedDownloadsToClipboard() {
-    let urls = Array.map(this._richlistbox.selectedItems,
-                         element => element._shell.download.source.url);
+    let urls = Array.from(this._richlistbox.selectedItems,
+                          element => element._shell.download.source.url);
 
     Cc["@mozilla.org/widget/clipboardhelper;1"]
       .getService(Ci.nsIClipboardHelper)
       .copyString(urls.join("\n"));
   },
 
   _getURLFromClipboardData() {
     let trans = Cc["@mozilla.org/widget/transferable;1"].
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -3662,17 +3662,17 @@ var SessionStoreInternal = {
     let arrowScrollbox = tabbrowser.tabContainer.arrowScrollbox;
     let smoothScroll = arrowScrollbox.smoothScroll;
     arrowScrollbox.smoothScroll = false;
 
     // We need to keep track of the initially open tabs so that they
     // can be moved to the end of the restored tabs.
     let initialTabs;
     if (!overwriteTabs && firstWindow) {
-      initialTabs = Array.slice(tabbrowser.tabs);
+      initialTabs = Array.from(tabbrowser.tabs);
     }
 
     // Get rid of tabs that aren't needed anymore.
     if (overwriteTabs) {
       for (let i = tabbrowser.browsers.length - 1; i >= 0; i--) {
         if (!tabbrowser.tabs[i].selected) {
           tabbrowser.removeTab(tabbrowser.tabs[i]);
         }
@@ -4047,17 +4047,17 @@ var SessionStoreInternal = {
 
     // It's important to set the window state to dirty so that
     // we collect their data for the first time when saving state.
     DirtyWindows.add(window);
 
     // In case we didn't collect/receive data for any tabs yet we'll have to
     // fill the array with at least empty tabData objects until |_tPos| or
     // we'll end up with |null| entries.
-    for (let otherTab of Array.slice(tabbrowser.tabs, 0, tab._tPos)) {
+    for (let otherTab of Array.prototype.slice.call(tabbrowser.tabs, 0, tab._tPos)) {
       let emptyState = {entries: [], lastAccessed: otherTab.lastAccessed};
       this._windows[window.__SSi].tabs.push(emptyState);
     }
 
     // Update the tab state in case we shut down without being notified.
     this._windows[window.__SSi].tabs[tab._tPos] = tabData;
 
     // Prepare the tab so that it can be properly restored. We'll pin/unpin
--- a/browser/modules/AsyncTabSwitcher.jsm
+++ b/browser/modules/AsyncTabSwitcher.jsm
@@ -414,17 +414,17 @@ class AsyncTabSwitcher {
     if (this.visibleTab !== showTab) {
       this.tabbrowser._adjustFocusBeforeTabSwitch(this.visibleTab, showTab);
       this.visibleTab = showTab;
 
       this.maybeVisibleTabs.add(showTab);
 
       let tabpanels = this.tabbrowser.tabpanels;
       let showPanel = this.tabbrowser.tabContainer.getRelatedElement(showTab);
-      let index = Array.indexOf(tabpanels.children, showPanel);
+      let index = Array.prototype.indexOf.call(tabpanels.children, showPanel);
       if (index != -1) {
         this.log(`Switch to tab ${index} - ${this.tinfo(showTab)}`);
         tabpanels.setAttribute("selectedIndex", index);
         if (showTab === this.requestedTab) {
           if (requestedTabState == this.STATE_LOADED) {
             // The new tab will be made visible in the next paint, record the expected
             // transaction id for that, and we'll mark when we get notified of its
             // completion.
--- a/devtools/client/performance/views/toolbar.js
+++ b/devtools/client/performance/views/toolbar.js
@@ -138,17 +138,18 @@ const ToolbarView = {
   },
 
   /**
    * Fired when a menu item in the markers filter popup is checked or unchecked.
    */
   _onHiddenMarkersChanged: function() {
     const checkedMenuItems =
       $$("#performance-filter-menupopup menuitem[marker-type]:not([checked])");
-    const hiddenMarkers = Array.map(checkedMenuItems, e => e.getAttribute("marker-type"));
+    const hiddenMarkers =
+      Array.from(checkedMenuItems, e => e.getAttribute("marker-type"));
     PerformanceController.setPref("hidden-markers", hiddenMarkers);
   },
 
   /**
    * Fired when a preference changes in the underlying OptionsView.
    * Propogated by the PerformanceController.
    */
   _onPrefChanged: function(prefName) {
--- a/devtools/client/shared/widgets/AbstractTreeItem.jsm
+++ b/devtools/client/shared/widgets/AbstractTreeItem.jsm
@@ -465,17 +465,18 @@ AbstractTreeItem.prototype = {
    *
    * @param number delta
    *        The offset from this item to the target item.
    * @return Node
    *         The element displaying the target item at the specified offset.
    */
   _getSiblingAtDelta: function(delta) {
     const childNodes = this._containerNode.childNodes;
-    const indexOfSelf = Array.indexOf(childNodes, this._targetNode);
+    const indexOfSelf =
+      Array.prototype.indexOf.call(childNodes, this._targetNode);
     if (indexOfSelf + delta >= 0) {
       return childNodes[indexOfSelf + delta];
     }
     return undefined;
   },
 
   _getNodesPerPageSize: function() {
     const childNodes = this._containerNode.childNodes;
--- a/devtools/server/actors/webconsole/utils.js
+++ b/devtools/server/actors/webconsole/utils.js
@@ -52,17 +52,17 @@ var WebConsoleUtils = {
     if (typeof object != "object") {
       return object;
     }
 
     let temp;
 
     if (Array.isArray(object)) {
       temp = [];
-      Array.forEach(object, function(value, index) {
+      object.forEach(function(value, index) {
         if (!filter || filter(index, value, object)) {
           temp.push(recursive ? WebConsoleUtils.cloneObject(value) : value);
         }
       });
     } else {
       temp = {};
       for (const key in object) {
         const value = object[key];
--- a/dom/browser-element/BrowserElementParent.jsm
+++ b/dom/browser-element/BrowserElementParent.jsm
@@ -22,18 +22,17 @@ function handleWindowEvent(e) {
     beps.forEach(bep => bep._handleOwnerEvent(e));
   }
 }
 
 function defineNoReturnMethod(fn) {
   return function method() {
     if (!this._domRequestReady) {
       // Remote browser haven't been created, we just queue the API call.
-      let args = Array.slice(arguments);
-      args.unshift(this);
+      let args = [this, ...arguments];
       this._pendingAPICalls.push(method.bind.apply(fn, args));
       return;
     }
     if (this._isAlive()) {
       fn.apply(this, arguments);
     }
   };
 }
--- a/mobile/android/chrome/content/ConsoleAPI.js
+++ b/mobile/android/chrome/content/ConsoleAPI.js
@@ -2,18 +2,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 var ConsoleAPI = {
   observe: function observe(aMessage, aTopic, aData) {
     aMessage = aMessage.wrappedJSObject;
 
-    let mappedArguments = Array.map(aMessage.arguments, this.formatResult, this);
-    let joinedArguments = Array.join(mappedArguments, " ");
+    let mappedArguments = Array.from(aMessage.arguments, this.formatResult, this);
+    let joinedArguments = mappedArguments.join(" ");
 
     if (aMessage.level == "error" || aMessage.level == "warn") {
       let flag = (aMessage.level == "error" ? Ci.nsIScriptError.errorFlag : Ci.nsIScriptError.warningFlag);
       let consoleMsg = Cc["@mozilla.org/scripterror;1"].createInstance(Ci.nsIScriptError);
       consoleMsg.init(joinedArguments, null, null, 0, 0, flag, "content javascript");
       Services.console.logMessage(consoleMsg);
     } else if (aMessage.level == "trace") {
       let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
--- a/mobile/android/modules/geckoview/GeckoViewConsole.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewConsole.jsm
@@ -46,18 +46,18 @@ var GeckoViewConsole = {
         this._handleConsoleMessage(aSubject);
         break;
     }
   },
 
   _handleConsoleMessage(aMessage) {
     aMessage = aMessage.wrappedJSObject;
 
-    const mappedArguments = Array.map(aMessage.arguments, this.formatResult, this);
-    const joinedArguments = Array.join(mappedArguments, " ");
+    const mappedArguments = Array.from(aMessage.arguments, this.formatResult, this);
+    const joinedArguments = mappedArguments.join(" ");
 
     if (aMessage.level == "error" || aMessage.level == "warn") {
       const flag = (aMessage.level == "error" ? Ci.nsIScriptError.errorFlag : Ci.nsIScriptError.warningFlag);
       const consoleMsg = Cc["@mozilla.org/scripterror;1"].createInstance(Ci.nsIScriptError);
       consoleMsg.init(joinedArguments, null, null, 0, 0, flag, "content javascript");
       Services.console.logMessage(consoleMsg);
     } else if (aMessage.level == "trace") {
       const bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
--- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp
+++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp
@@ -384,17 +384,17 @@ nsresult nsIndexedToHTML::DoOnStartReque
       "  for (var i = headCells.length - 1; i >= 0; i--) {\n"
       "    var anchor = document.createElement(\"a\");\n"
       "    anchor.href = \"\";\n"
       "    anchor.appendChild(headCells[i].firstChild);\n"
       "    headCells[i].appendChild(anchor);\n"
       "    headCells[i].addEventListener(\"click\", rowAction(i), true);\n"
       "  }\n"
       "  if (gUI_showHidden) {\n"
-      "    gRows = Array.slice(gTBody.rows);\n"
+      "    gRows = Array.from(gTBody.rows);\n"
       "    hiddenObjects = gRows.some(row => row.className == "
       "\"hidden-object\");\n"
       "  }\n"
       "  gTable.setAttribute(\"order\", \"\");\n"
       "  if (hiddenObjects) {\n"
       "    gUI_showHidden.style.display = \"block\";\n"
       "    updateHidden();\n"
       "  }\n"
@@ -416,17 +416,17 @@ nsresult nsIndexedToHTML::DoOnStartReque
       "  if (a < b)\n"
       "    return -1;\n"
       "  if (a > b)\n"
       "    return 1;\n"
       "  return 0;\n"
       "}\n"
       "function orderBy(column) {\n"
       "  if (!gRows)\n"
-      "    gRows = Array.slice(gTBody.rows);\n"
+      "    gRows = Array.from(gTBody.rows);\n"
       "  var order;\n"
       "  if (gOrderBy == column) {\n"
       "    order = gTable.getAttribute(\"order\") == \"asc\" ? \"desc\" : "
       "\"asc\";\n"
       "  } else {\n"
       "    order = \"asc\";\n"
       "    gOrderBy = column;\n"
       "    gTable.setAttribute(\"order-by\", column);\n"
--- a/services/common/async.js
+++ b/services/common/async.js
@@ -24,22 +24,21 @@ var Async = {
    *
    *   let self = this;
    *   self.foo(args, for, foo, function (bars, args) {
    *     self.bar(bars, args, function (baz, params) {
    *       self.baz(baz, params);
    *     });
    *   });
    */
-  chain: function chain() {
-    let funcs = Array.slice(arguments);
+  chain: function chain(...funcs) {
     let thisObj = this;
     return function callback() {
       if (funcs.length) {
-        let args = Array.slice(arguments).concat(callback);
+        let args = [...arguments, callback];
         let f = funcs.shift();
         f.apply(thisObj, args);
       }
     };
   },
 
   /**
    * Check if the app is still ready (not quitting). Returns true, or throws an
--- a/toolkit/components/downloads/DownloadList.jsm
+++ b/toolkit/components/downloads/DownloadList.jsm
@@ -34,17 +34,17 @@ this.DownloadList.prototype = {
    * returned array does not change when downloads are added or removed, though
    * the Download objects it contains are still updated in real time.
    *
    * @return {Promise}
    * @resolves An array of Download objects.
    * @rejects JavaScript exception.
    */
   getAll: function DL_getAll() {
-    return Promise.resolve(Array.slice(this._downloads, 0));
+    return Promise.resolve(Array.from(this._downloads));
   },
 
   /**
    * Adds a new download to the end of the items list.
    *
    * @note When a download is added to the list, its "onchange" event is
    *       registered by the list, thus it cannot be used to monitor the
    *       download.  To receive change notifications for downloads that are
--- a/toolkit/components/downloads/DownloadUIHelper.jsm
+++ b/toolkit/components/downloads/DownloadUIHelper.jsm
@@ -64,17 +64,17 @@ XPCOMUtils.defineLazyGetter(DownloadUIHe
   let strings = {};
   let sb = Services.strings.createBundle(kStringBundleUrl);
   for (let string of sb.getSimpleEnumeration()) {
     let stringName = string.key;
     if (stringName in kStringsRequiringFormatting) {
       strings[stringName] = function() {
         // Convert "arguments" to a real array before calling into XPCOM.
         return sb.formatStringFromName(stringName,
-                                       Array.slice(arguments, 0),
+                                       Array.from(arguments),
                                        arguments.length);
       };
     } else {
       strings[stringName] = string.value;
     }
   }
   return strings;
 });
--- a/toolkit/components/passwordmgr/LoginManagerContent.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerContent.jsm
@@ -605,18 +605,18 @@ var LoginManagerContent = {
 
     // Returns true if this window or any subframes have insecure login forms.
     let hasInsecureLoginForms = (thisWindow) => {
       let doc = thisWindow.document;
       let rootElsWeakSet = LoginFormFactory.getRootElementsWeakSetForDocument(doc);
       let hasLoginForm = ChromeUtils.nondeterministicGetWeakSetKeys(rootElsWeakSet)
                                     .filter(el => el.isConnected).length > 0;
       return (hasLoginForm && !thisWindow.isSecureContext) ||
-             Array.some(thisWindow.frames,
-                        frame => hasInsecureLoginForms(frame));
+             Array.prototype.some.call(thisWindow.frames,
+                                       frame => hasInsecureLoginForms(frame));
     };
 
     let messageManager = topWindow.docShell.messageManager;
     messageManager.sendAsyncMessage("PasswordManager:insecureLoginFormPresent", {
       hasInsecureLoginForms: hasInsecureLoginForms(topWindow),
     });
   },
 
--- a/toolkit/content/widgets/notificationbox.js
+++ b/toolkit/content/widgets/notificationbox.js
@@ -49,17 +49,18 @@ MozElements.NotificationBox = class Noti
   get allNotifications() {
     // Don't create any DOM if no new notification has been added yet.
     if (!this._stack) {
       return [];
     }
 
     var closedNotification = this._closedNotification;
     var notifications = this.stack.getElementsByTagName("notification");
-    return Array.filter(notifications, n => n != closedNotification);
+    return Array.prototype.filter.call(
+      notifications, n => n != closedNotification);
   }
 
   getNotificationWithValue(aValue) {
     var notifications = this.allNotifications;
     for (var n = notifications.length - 1; n >= 0; n--) {
       if (aValue == notifications[n].getAttribute("value"))
         return notifications[n];
     }
--- a/toolkit/content/widgets/richlistbox.js
+++ b/toolkit/content/widgets/richlistbox.js
@@ -907,17 +907,17 @@ MozElements.MozRichlistitem = class MozR
   }
 
   /**
    * nsIDOMXULSelectControlItemElement
    */
   get label() {
     const XULNS =
       "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-    return Array.map(this.getElementsByTagNameNS(XULNS, "label"),
+    return Array.from(this.getElementsByTagNameNS(XULNS, "label"),
         label => label.value)
       .join(" ");
   }
 
   set searchLabel(val) {
     if (val !== null)
       this.setAttribute("searchlabel", val);
     else
--- a/toolkit/content/widgets/richlistbox.xml
+++ b/toolkit/content/widgets/richlistbox.xml
@@ -39,17 +39,17 @@
       <!-- nsIDOMXULSelectControlItemElement -->
       <property name="label" readonly="true">
         <!-- Setter purposely not implemented; the getter returns a
              concatentation of label text to expose via accessibility APIs -->
         <getter>
           <![CDATA[
             const XULNS =
               "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-            return Array.map(this.getElementsByTagNameNS(XULNS, "label"),
+            return Array.from(this.getElementsByTagNameNS(XULNS, "label"),
                              label => label.value)
                         .join(" ");
           ]]>
         </getter>
       </property>
 
       <property name="searchLabel">
         <getter>
--- a/toolkit/content/widgets/scrollbox.xml
+++ b/toolkit/content/widgets/scrollbox.xml
@@ -331,17 +331,17 @@
         <body><![CDATA[
           var nodes = this.children;
           if (nodes.length == 1 &&
               nodes[0].localName == "children" &&
               nodes[0].namespaceURI == "http://www.mozilla.org/xbl") {
             nodes = document.getBindingParent(this).children;
           }
 
-          return Array.filter(nodes, this._canScrollToElement, this);
+          return Array.prototype.filter.call(nodes, this._canScrollToElement, this);
         ]]></body>
       </method>
 
       <method name="_elementFromPoint">
         <parameter name="aX"/>
         <parameter name="aPhysicalScrollDir"/>
         <body><![CDATA[
           var elements = this._getScrollableElements();
--- a/toolkit/content/widgets/tabbox.js
+++ b/toolkit/content/widgets/tabbox.js
@@ -223,17 +223,17 @@ class MozTabpanels extends MozXULElement
       return null;
 
     let tabsElm = tabboxElm.tabs;
     if (!tabsElm)
       return null;
 
     // Return tab element having 'linkedpanel' attribute equal to the id
     // of the tab panel or the same index as the tab panel element.
-    let tabpanelIdx = Array.indexOf(this.children, aTabPanelElm);
+    let tabpanelIdx = Array.prototype.indexOf.call(this.children, aTabPanelElm);
     if (tabpanelIdx == -1)
       return null;
 
     let tabElms = tabsElm.children;
     let tabElmFromIndex = tabElms[tabpanelIdx];
 
     let tabpanelId = aTabPanelElm.id;
     if (tabpanelId) {
--- a/toolkit/content/widgets/tree.js
+++ b/toolkit/content/widgets/tree.js
@@ -485,20 +485,20 @@
         this.appendChild(MozXULElement.parseXULToFragment(`
           <treecolpicker class="treecol-image" fixed="true"></treecolpicker>
         `));
         this.initializeAttributeInheritance();
       }
 
       // Set resizeafter="farthest" on the splitters if nothing else has been
       // specified.
-      Array.forEach(this.getElementsByTagName("splitter"), function(splitter) {
+      for (let splitter of this.getElementsByTagName("splitter")) {
         if (!splitter.hasAttribute("resizeafter"))
           splitter.setAttribute("resizeafter", "farthest");
-      });
+      }
     }
   }
 
   customElements.define("treecols", MozTreecols);
 
   class MozTree extends MozElements.BaseControlMixin(MozElements.MozElementMixin(XULTreeElement)) {
     constructor() {
       super();
--- a/toolkit/modules/PopupNotifications.jsm
+++ b/toolkit/modules/PopupNotifications.jsm
@@ -1431,17 +1431,17 @@ PopupNotifications.prototype = {
   _dismissOrRemoveCurrentNotifications() {
     let browser = this.panel.firstElementChild &&
                   this.panel.firstElementChild.notification.browser;
     if (!browser)
       return;
 
     let notifications = this._getNotificationsForBrowser(browser);
     // Mark notifications as dismissed and call dismissal callbacks
-    Array.forEach(this.panel.children, function(nEl) {
+    for (let nEl of this.panel.children) {
       let notificationObj = nEl.notification;
       // Never call a dismissal handler on a notification that's been removed.
       if (!notifications.includes(notificationObj))
         return;
 
       // Record the time of the first notification dismissal if the main action
       // was not triggered in the meantime.
       let timeSinceShown = this.window.performance.now() - notificationObj.timeShown;
@@ -1455,17 +1455,17 @@ PopupNotifications.prototype = {
       // Do not mark the notification as dismissed or fire NOTIFICATION_EVENT_DISMISSED
       // if the notification is removed.
       if (notificationObj.options.removeOnDismissal) {
         this._remove(notificationObj);
       } else {
         notificationObj.dismissed = true;
         this._fireCallback(notificationObj, NOTIFICATION_EVENT_DISMISSED);
       }
-    }, this);
+    }
   },
 
   _onCheckboxCommand(event) {
     let notificationEl = getNotificationFromElement(event.originalTarget);
     let checked = notificationEl.checkbox.checked;
     let notification = notificationEl.notification;
 
     // Save checkbox state to be able to persist it when re-opening the doorhanger.
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -1811,17 +1811,17 @@ function sortElements(aElements, aSortBy
 
     // If we got here, then all values of a and b
     // must have been equal.
     return 0;
   });
 }
 
 function sortList(aList, aSortBy, aAscending) {
-  var elements = Array.slice(aList.childNodes, 0);
+  var elements = Array.from(aList.childNodes);
   sortElements(elements, [aSortBy], aAscending);
 
   while (aList.lastChild)
     aList.lastChild.remove();
 
   for (let element of elements)
     aList.appendChild(element);
 }