Bug 1074804 - Replace arrays .indexOf with .includes in Places. r=mak
authorHassen ben tanfous <hassenbtn@gmail.com>
Sun, 11 Oct 2015 20:24:32 +0200
changeset 300520 2a6d58e63d30a36f43abf37d76add32b6f3c7265
parent 300519 3eea09a56dc95d0590cd6aa866c9a9a385a9d874
child 300521 4a7e85280dd47d6c25d94918f16865e206dfddcf
push id5392
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:08:23 +0000
treeherdermozilla-beta@16ce8562a975 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1074804
milestone44.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 1074804 - Replace arrays .indexOf with .includes in Places. r=mak
browser/base/content/browser-places.js
browser/components/places/PlacesUIUtils.jsm
browser/components/places/content/browserPlacesViews.js
browser/components/places/content/controller.js
browser/components/places/content/editBookmarkOverlay.js
browser/components/places/content/places.js
browser/components/places/content/tree.xml
browser/components/places/content/treeView.js
browser/components/places/tests/browser/browser_history_sidebar_search.js
browser/components/places/tests/browser/browser_library_middleclick.js
browser/components/places/tests/chrome/test_0_bug510634.xul
browser/components/places/tests/chrome/test_editBookmarkOverlay_tags_liveUpdate.xul
toolkit/components/places/BookmarkJSONUtils.jsm
toolkit/components/places/Bookmarks.jsm
toolkit/components/places/PlacesTransactions.jsm
toolkit/components/places/PlacesUtils.jsm
toolkit/components/places/UnifiedComplete.js
toolkit/components/places/nsTaggingService.js
toolkit/components/places/tests/chrome/test_342484.xul
toolkit/components/places/tests/head_common.js
toolkit/components/places/tests/queries/test_redirects.js
toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
toolkit/components/places/tests/unit/test_384370.js
toolkit/components/places/tests/unit/test_async_transactions.js
toolkit/components/places/tests/unit/test_promiseBookmarksTree.js
toolkit/components/places/tests/unit/test_tagging.js
toolkit/components/places/tests/unit/test_utils_backups_create.js
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -1487,17 +1487,17 @@ var BookmarkingUI = {
         Components.utils.reportError("BookmarkingUI did not receive current URI");
         return;
       }
 
       // It's possible that onItemAdded gets called before the async statement
       // calls back.  For such an edge case, retain all unique entries from both
       // arrays.
       this._itemIds = this._itemIds.filter(
-        id => aItemIds.indexOf(id) == -1
+        id => !aItemIds.includes(id)
       ).concat(aItemIds);
 
       this._updateStar();
 
       // Start observing bookmarks if needed.
       if (!this._hasBookmarksObserver) {
         try {
           PlacesUtils.addLazyBookmarkObserver(this);
@@ -1721,17 +1721,17 @@ var BookmarkingUI = {
     PanelUI.hide();
   },
 
   // nsINavBookmarkObserver
   onItemAdded: function BUI_onItemAdded(aItemId, aParentId, aIndex, aItemType,
                                         aURI) {
     if (aURI && aURI.equals(this._uri)) {
       // If a new bookmark has been added to the tracked uri, register it.
-      if (this._itemIds.indexOf(aItemId) == -1) {
+      if (!this._itemIds.includes(aItemId)) {
         this._itemIds.push(aItemId);
         // Only need to update the UI if it wasn't marked as starred before:
         if (this._itemIds.length == 1) {
           this._updateStar();
         }
       }
     }
   },
--- a/browser/components/places/PlacesUIUtils.jsm
+++ b/browser/components/places/PlacesUIUtils.jsm
@@ -165,17 +165,17 @@ this.PlacesUIUtils = {
       transactions.push(
         new PlacesEditItemLastModifiedTransaction(null, aData.lastModified)
       );
     }
 
     let annos = [];
     if (aData.annos) {
       annos = aData.annos.filter(function (aAnno) {
-        return this._copyableAnnotations.indexOf(aAnno.name) != -1;
+        return this._copyableAnnotations.includes(aAnno.name);
       }, this);
     }
 
     // There's no need to copy the keyword since it's bound to the bookmark url.
     return new PlacesCreateBookmarkTransaction(PlacesUtils._uri(aData.uri),
                                                aContainer, aIndex, aData.title,
                                                null, annos, transactions);
   },
@@ -277,17 +277,17 @@ this.PlacesUIUtils = {
       transactions.push(
         new PlacesEditItemLastModifiedTransaction(null, aData.lastModified)
       );
     }
 
     let annos = [];
     if (aData.annos) {
       annos = aData.annos.filter(function (aAnno) {
-        return this._copyableAnnotations.indexOf(aAnno.name) != -1;
+        return this._copyableAnnotations.includes(aAnno.name);
       }, this);
     }
 
     return new PlacesCreateFolderTransaction(aData.title, aContainer, aIndex,
                                              annos, transactions);
   },
 
   /**
@@ -318,17 +318,17 @@ this.PlacesUIUtils = {
     if (aData.annos) {
       annos = aData.annos.filter(function (aAnno) {
         if (aAnno.name == PlacesUtils.LMANNO_FEEDURI) {
           feedURI = PlacesUtils._uri(aAnno.value);
         }
         else if (aAnno.name == PlacesUtils.LMANNO_SITEURI) {
           siteURI = PlacesUtils._uri(aAnno.value);
         }
-        return this._copyableAnnotations.indexOf(aAnno.name) != -1
+        return this._copyableAnnotations.includes(aAnno.name)
       }, this);
     }
 
     return new PlacesCreateLivemarkTransaction(feedURI, siteURI, aData.title,
                                                aContainer, aIndex, annos);
   },
 
   /**
@@ -406,21 +406,21 @@ this.PlacesUIUtils = {
    *          The index within the container the item was dropped or pasted at.
    * @param   aCopy
    *          The drag action was copy, so don't move folders or links.
    *
    * @return  a Places Transaction that can be transacted for performing the
    *          move/insert command.
    */
   getTransactionForData: function(aData, aType, aNewParentGuid, aIndex, aCopy) {
-    if (this.SUPPORTED_FLAVORS.indexOf(aData.type) == -1)
+    if (!this.SUPPORTED_FLAVORS.includes(aData.type))
       throw new Error(`Unsupported '${aData.type}' data type`);
 
     if ("itemGuid" in aData) {
-      if (this.PLACES_FLAVORS.indexOf(aData.type) == -1)
+      if (!this.PLACES_FLAVORS.includes(aData.type))
         throw new Error (`itemGuid unexpectedly set on ${aData.type} data`);
 
       let info = { guid: aData.itemGuid
                  , newParentGuid: aNewParentGuid
                  , newIndex: aIndex };
       if (aCopy) {
         info.excludingAnnotation = "Places/SmartBookmark";
         return PlacesTransactions.Copy(info);
@@ -461,17 +461,17 @@ this.PlacesUIUtils = {
    * @return true if any transaction has been performed, false otherwise.
    */
   showBookmarkDialog:
   function PUIU_showBookmarkDialog(aInfo, aParentWindow) {
     // Preserve size attributes differently based on the fact the dialog has
     // a folder picker or not, since it needs more horizontal space than the
     // other controls.
     let hasFolderPicker = !("hiddenRows" in aInfo) ||
-                          aInfo.hiddenRows.indexOf("folderPicker") == -1;
+                          !aInfo.hiddenRows.includes("folderPicker");
     // Use a different chrome url to persist different sizes.
     let dialogURL = hasFolderPicker ?
                     "chrome://browser/content/places/bookmarkProperties2.xul" :
                     "chrome://browser/content/places/bookmarkProperties.xul";
 
     let features = "centerscreen,chrome,modal,resizable=yes";
     aParentWindow.openDialog(dialogURL, "", features, aInfo);
     return ("performed" in aInfo && aInfo.performed);
@@ -1040,17 +1040,17 @@ this.PlacesUIUtils = {
         if (!itemExists(query.itemId)) {
           // Orphan annotation, bail out and create a new left pane root.
           corrupt = true;
           break;
         }
 
         // Check that all queries have valid parents.
         let parentId = bs.getFolderIdForItem(query.itemId);
-        if (items.indexOf(parentId) == -1 && parentId != leftPaneRoot) {
+        if (!items.includes(parentId) && parentId != leftPaneRoot) {
           // The parent is not part of the left pane, bail out and create a new
           // left pane root.
           corrupt = true;
           break;
         }
 
         // Titles could have been corrupted or the user could have changed his
         // locale.  Check title and eventually fix it.
--- a/browser/components/places/content/browserPlacesViews.js
+++ b/browser/components/places/content/browserPlacesViews.js
@@ -334,17 +334,17 @@ PlacesViewBase.prototype = {
     else {
       let itemId = aPlacesNode.itemId;
       if (type == Ci.nsINavHistoryResultNode.RESULT_TYPE_URI) {
         element = document.createElement("menuitem");
         element.className = "menuitem-iconic bookmark-item menuitem-with-favicon";
         element.setAttribute("scheme",
                              PlacesUIUtils.guessUrlSchemeForUI(aPlacesNode.uri));
       }
-      else if (PlacesUtils.containerTypes.indexOf(type) != -1) {
+      else if (PlacesUtils.containerTypes.includes(type)) {
         element = document.createElement("menu");
         element.setAttribute("container", "true");
 
         if (aPlacesNode.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY) {
           element.setAttribute("query", "true");
           if (PlacesUtils.nodeIsTagQuery(aPlacesNode))
             element.setAttribute("tagContainer", "true");
           else if (PlacesUtils.nodeIsDay(aPlacesNode))
@@ -1053,17 +1053,17 @@ PlacesToolbar.prototype = {
     else {
       button = document.createElement("toolbarbutton");
       button.className = "bookmark-item";
       button.setAttribute("label", aChild.title || "");
       let icon = aChild.icon;
       if (icon)
         button.setAttribute("image", icon);
 
-      if (PlacesUtils.containerTypes.indexOf(type) != -1) {
+      if (PlacesUtils.containerTypes.includes(type)) {
         button.setAttribute("type", "menu");
         button.setAttribute("container", "true");
 
         if (PlacesUtils.nodeIsQuery(aChild)) {
           button.setAttribute("query", "true");
           if (PlacesUtils.nodeIsTagQuery(aChild))
             button.setAttribute("tagContainer", "true");
         }
@@ -1880,17 +1880,17 @@ PlacesPanelMenuView.prototype = {
       button.className = "bookmark-item";
       if (typeof this.options.extraClasses.entry == "string")
         button.classList.add(this.options.extraClasses.entry);
       button.setAttribute("label", aChild.title || "");
       let icon = aChild.icon;
       if (icon)
         button.setAttribute("image", icon);
 
-      if (PlacesUtils.containerTypes.indexOf(type) != -1) {
+      if (PlacesUtils.containerTypes.includes(type)) {
         button.setAttribute("container", "true");
 
         if (PlacesUtils.nodeIsQuery(aChild)) {
           button.setAttribute("query", "true");
           if (PlacesUtils.nodeIsTagQuery(aChild))
             button.setAttribute("tagContainer", "true");
         }
         else if (PlacesUtils.nodeIsFolder(aChild)) {
--- a/browser/components/places/content/controller.js
+++ b/browser/components/places/content/controller.js
@@ -496,29 +496,29 @@ PlacesController.prototype = {
    *         and the item can be displayed, false otherwise.
    */
   _shouldShowMenuItem: function PC__shouldShowMenuItem(aMenuItem, aMetaData) {
     var selectiontype = aMenuItem.getAttribute("selectiontype");
     if (!selectiontype) {
       selectiontype = "single|multiple";
     }
     var selectionTypes = selectiontype.split("|");
-    if (selectionTypes.indexOf("any") != -1) {
+    if (selectionTypes.includes("any")) {
       return true;
     }
     var count = aMetaData.length;
-    if (count > 1 && selectionTypes.indexOf("multiple") == -1)
+    if (count > 1 && !selectionTypes.includes("multiple"))
       return false;
-    if (count == 1 && selectionTypes.indexOf("single") == -1)
+    if (count == 1 && !selectionTypes.includes("single"))
       return false;
     // NB: if there is no selection, we show the item if and only if
     // the selectiontype includes 'none' - the metadata list will be
     // empty so none of the other criteria will apply anyway.
     if (count == 0)
-      return selectionTypes.indexOf("none") != -1;
+      return selectionTypes.includes("none");
 
     var forceHideAttr = aMenuItem.getAttribute("forcehideselection");
     if (forceHideAttr) {
       var forceHideRules = forceHideAttr.split("|");
       for (let i = 0; i < aMetaData.length; ++i) {
         for (let j = 0; j < forceHideRules.length; ++j) {
           if (forceHideRules[j] in aMetaData[i])
             return false;
@@ -1450,17 +1450,17 @@ var PlacesControllerDragHelper = {
 
   /**
    * Extract the first accepted flavor from a list of flavors.
    * @param aFlavors
    *        The flavors list of type DOMStringList.
    */
   getFirstValidFlavor: function PCDH_getFirstValidFlavor(aFlavors) {
     for (let i = 0; i < aFlavors.length; i++) {
-      if (PlacesUIUtils.SUPPORTED_FLAVORS.indexOf(aFlavors[i]) != -1)
+      if (PlacesUIUtils.SUPPORTED_FLAVORS.includes(aFlavors[i]))
         return aFlavors[i];
     }
 
     // If no supported flavor is found, check if data includes text/plain
     // contents.  If so, request them as text/unicode, a conversion will happen
     // automatically.
     if (aFlavors.contains("text/plain")) {
         return PlacesUtils.TYPE_UNICODE;
@@ -1566,17 +1566,17 @@ var PlacesControllerDragHelper = {
   },
 
   /**
    * Handles the drop of one or more items onto a view.
    * @param   insertionPoint
    *          The insertion point where the items should be dropped
    */
   onDrop: Task.async(function* (insertionPoint, dt) {
-    let doCopy = ["copy", "link"].indexOf(dt.dropEffect) != -1;
+    let doCopy = ["copy", "link"].includes(dt.dropEffect);
 
     let transactions = [];
     let dropCount = dt.mozItemCount;
     let movedCount = 0;
     let parentGuid = PlacesUIUtils.useAsyncTransactions ?
                        (yield insertionPoint.promiseGuid()) : null;
     let tagName = insertionPoint.tagName;
     for (let i = 0; i < dropCount; ++i) {
--- a/browser/components/places/content/editBookmarkOverlay.js
+++ b/browser/components/places/content/editBookmarkOverlay.js
@@ -284,17 +284,17 @@ var gEditItemOverlay = {
     let firstURI = uris.shift();
     let commonTags = new Set(PlacesUtils.tagging.getTagsForURI(firstURI));
     if (commonTags.size == 0)
       return this._cachedCommonTags = [];
 
     for (let uri of uris) {
       let curentURITags = PlacesUtils.tagging.getTagsForURI(uri);
       for (let tag of commonTags) {
-        if (curentURITags.indexOf(tag) == -1) {
+        if (!curentURITags.includes(tag)) {
           commonTags.delete(tag)
           if (commonTags.size == 0)
             return this._paneInfo.cachedCommonTags = [];
         }
       }
     }
     return this._paneInfo._cachedCommonTags = [...commonTags];
   },
@@ -448,18 +448,18 @@ var gEditItemOverlay = {
     // Optimize the trivial cases (which are actually the most common).
     if (inputTags.length == 0 && aCurrentTags.length == 0)
       return { newTags: [], removedTags: [] };
     if (inputTags.length == 0)
       return { newTags: [], removedTags: aCurrentTags };
     if (aCurrentTags.length == 0)
       return { newTags: inputTags, removedTags: [] };
 
-    let removedTags = aCurrentTags.filter(t => inputTags.indexOf(t) == -1);
-    let newTags = inputTags.filter(t => aCurrentTags.indexOf(t) == -1);
+    let removedTags = aCurrentTags.filter(t => !inputTags.includes(t));
+    let newTags = inputTags.filter(t => !aCurrentTags.includes(t));
     return { removedTags, newTags };
   },
 
   // Adds and removes tags for one or more uris.
   _setTagsFromTagsInputField: Task.async(function* (aCurrentTags, aURIs) {
     let { removedTags, newTags } = this._getTagsChanges(aCurrentTags);
     if (removedTags.length + newTags.length == 0)
       return false;
@@ -868,17 +868,17 @@ var gEditItemOverlay = {
     }
 
     let tagsInField = this._getTagsArrayFromTagsInputField();
     let allTags = PlacesUtils.tagging.allTags;
     for (tag of allTags) {
       let elt = document.createElement("listitem");
       elt.setAttribute("type", "checkbox");
       elt.setAttribute("label", tag);
-      if (tagsInField.indexOf(tag) != -1)
+      if (tagsInField.includes(tag))
         elt.setAttribute("checked", "true");
       tagsSelector.appendChild(elt);
       if (selectedTag === tag)
         selectedIndex = tagsSelector.getIndexOfItem(elt);
     }
 
     // Restore position.
     // The listbox allows to scroll only if the required offset doesn't
--- a/browser/components/places/content/places.js
+++ b/browser/components/places/content/places.js
@@ -1350,21 +1350,21 @@ var ContentArea = {
     let detailsDeck = document.getElementById("detailsDeck");
     detailsDeck.hidden = !options.showDetailsPane;
 
     // toolbarSet.
     for (let elt of this._toolbar.childNodes) {
       // On Windows and Linux the menu buttons are menus wrapped in a menubar.
       if (elt.id == "placesMenu") {
         for (let menuElt of elt.childNodes) {
-          menuElt.hidden = options.toolbarSet.indexOf(menuElt.id) == -1;
+          menuElt.hidden = !options.toolbarSet.includes(menuElt.id);
         }
       }
       else {
-        elt.hidden = options.toolbarSet.indexOf(elt.id) == -1;
+        elt.hidden = !options.toolbarSet.includes(elt.id);
       }
     }
   },
 
   /**
    * Options for the current view.
    *
    * @see ContentTree.viewOptions for supported options and default values.
--- a/browser/components/places/content/tree.xml
+++ b/browser/components/places/content/tree.xml
@@ -167,17 +167,17 @@
           // Do nothing if a node matching the given uri is already selected
           if (this.hasSelection && this.selectedNode.uri == placeURI)
             return;
 
           function findNode(container, placeURI, nodesURIChecked) {
             var containerURI = container.uri;
             if (containerURI == placeURI)
               return container;
-            if (nodesURIChecked.indexOf(containerURI) != -1)
+            if (nodesURIChecked.includes(containerURI))
               return null;
 
             // never check the contents of the same query
             nodesURIChecked.push(containerURI);
 
             var wasOpen = container.containerOpen;
             if (!wasOpen)
               container.containerOpen = true;
--- a/browser/components/places/content/treeView.js
+++ b/browser/components/places/content/treeView.js
@@ -1151,17 +1151,17 @@ PlacesTreeView.prototype = {
       props += " cutting";
     }
 
     let properties = this._cellProperties.get(node);
     if (properties === undefined) {
       properties = "";
       let itemId = node.itemId;
       let nodeType = node.type;
-      if (PlacesUtils.containerTypes.indexOf(nodeType) != -1) {
+      if (PlacesUtils.containerTypes.includes(nodeType)) {
         if (nodeType == Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY) {
           properties += " query";
           if (PlacesUtils.nodeIsTagQuery(node))
             properties += " tagContainer";
           else if (PlacesUtils.nodeIsDay(node))
             properties += " dayContainer";
           else if (PlacesUtils.nodeIsHost(node))
             properties += " hostContainer";
--- a/browser/components/places/tests/browser/browser_history_sidebar_search.js
+++ b/browser/components/places/tests/browser/browser_history_sidebar_search.js
@@ -75,15 +75,15 @@ function check_sidebar_tree_order(aExpec
   var rc = treeView.rowCount;
   var columns = tree.columns;
   is(columns.count, 1, "There should be only 1 column in the sidebar");
   var found = 0;
   for (var r = 0; r < rc; r++) {
     var node = treeView.nodeForTreeIndex(r);
     // We could inherit visits from previous tests, skip them since they are
     // not interesting for us.
-    if (pages.indexOf(node.uri) == -1)
+    if (!pages.includes(node.uri))
       continue;
     is(node.uri, pages[r], "Node is in correct position based on its visit date");
     found++;
   }
   ok(found, aExpectedRows, "Found all expected results");
 }
--- a/browser/components/places/tests/browser/browser_library_middleclick.js
+++ b/browser/components/places/tests/browser/browser_library_middleclick.js
@@ -34,23 +34,23 @@ var gTabsListener = {
 
   onLocationChange: function(aBrowser, aWebProgress, aRequest, aLocationURI,
                              aFlags) {
     var spec = aLocationURI.spec;
     ok(true, spec);
     // When a new tab is opened, location is first set to "about:blank", so
     // we can ignore those calls.
     // Ignore multiple notifications for the same URI too.
-    if (spec == "about:blank" || this._loadedURIs.indexOf(spec) != -1)
+    if (spec == "about:blank" || this._loadedURIs.includes(spec))
       return;
 
-    ok(gCurrentTest.URIs.indexOf(spec) != -1,
+    ok(gCurrentTest.URIs.includes(spec),
        "Opened URI found in list: " + spec);
 
-    if (gCurrentTest.URIs.indexOf(spec) != -1 )
+    if (gCurrentTest.URIs.includes(spec))
       this._loadedURIs.push(spec);
 
     if (this._loadedURIs.length == gCurrentTest.URIs.length) {
       // We have correctly opened all URIs.
 
       // Reset arrays.
       this._loadedURIs.length = 0;
 
--- a/browser/components/places/tests/chrome/test_0_bug510634.xul
+++ b/browser/components/places/tests/chrome/test_0_bug510634.xul
@@ -73,17 +73,17 @@
          "Opened All Bookmarks");
 
       ["History", "Downloads", "Tags", "AllBookmarks", "BookmarksToolbar",
        "BookmarksMenu", "UnfiledBookmarks"].forEach(
         function(aQueryName, aRow) {
           let found = false;
           for (let i = 0; i < tree.view.rowCount && !found; i++) {
             rowProperties = tree.view.getCellProperties(i, titleColumn).split(" ");
-            found = rowProperties.indexOf("OrganizerQuery_" + aQueryName) != -1;
+            found = rowProperties.includes("OrganizerQuery_" + aQueryName);
           }
           ok(found, "OrganizerQuery_" + aQueryName + " is set");
         }
       );
 
       // Close the root node
       tree.result.root.containerOpen = false;
 
--- a/browser/components/places/tests/chrome/test_editBookmarkOverlay_tags_liveUpdate.xul
+++ b/browser/components/places/tests/chrome/test_editBookmarkOverlay_tags_liveUpdate.xul
@@ -40,19 +40,19 @@
       let tagsSelector = document.getElementById("editBMPanel_tagsSelector");
       let children = tagsSelector.childNodes;
       is(children.length, aAvailableTags.length,
           "Found expected number of tags in the tags selector");
 
       Array.forEach(children, function (aChild) {
         let tag = aChild.getAttribute("label");
         ok(true, "Found tag '" + tag + "' in the selector");
-        ok(aAvailableTags.indexOf(tag) != -1, "Found expected tag");
+        ok(aAvailableTags.includes(tag), "Found expected tag");
         let checked = aChild.getAttribute("checked") == "true";
-        is(checked, aCheckedTags.indexOf(tag) != -1,
+        is(checked, aCheckedTags.includes(tag),
            "Tag is correctly marked");
       });
     }
 
     function runTest() {
       SimpleTest.waitForExplicitFinish();
 
       Task.spawn(function* () {
--- a/toolkit/components/places/BookmarkJSONUtils.jsm
+++ b/toolkit/components/places/BookmarkJSONUtils.jsm
@@ -271,17 +271,17 @@ BookmarkImporter.prototype = {
             // Delete existing children of the root node, excepting:
             // 1. special folders: delete the child nodes
             // 2. tags folder: untag via the tagging api
             let root = PlacesUtils.getFolderContents(PlacesUtils.placesRootId,
                                                    false, false).root;
             let childIds = [];
             for (let i = 0; i < root.childCount; i++) {
               let childId = root.getChild(i).itemId;
-              if (excludeItems.indexOf(childId) == -1 &&
+              if (!excludeItems.includes(childId) &&
                   childId != PlacesUtils.tagsFolderId) {
                 childIds.push(childId);
               }
             }
             root.containerOpen = false;
 
             for (let i = 0; i < childIds.length; i++) {
               let rootItemId = childIds[i];
--- a/toolkit/components/places/Bookmarks.jsm
+++ b/toolkit/components/places/Bookmarks.jsm
@@ -141,17 +141,17 @@ var Bookmarks = Object.freeze({
     let time = (info && info.dateAdded) || new Date();
     let insertInfo = validateBookmarkObject(info,
       { type: { defaultValue: this.TYPE_BOOKMARK }
       , index: { defaultValue: this.DEFAULT_INDEX }
       , url: { requiredIf: b => b.type == this.TYPE_BOOKMARK
              , validIf: b => b.type == this.TYPE_BOOKMARK }
       , parentGuid: { required: true }
       , title: { validIf: b => [ this.TYPE_BOOKMARK
-                               , this.TYPE_FOLDER ].indexOf(b.type) != -1 }
+                               , this.TYPE_FOLDER ].includes(b.type) }
       , dateAdded: { defaultValue: time
                    , validIf: b => !b.lastModified ||
                                     b.dateAdded <= b.lastModified }
       , lastModified: { defaultValue: time,
                         validIf: b => (!b.dateAdded && b.lastModified >= time) ||
                                       (b.dateAdded && b.lastModified >= b.dateAdded) }
       });
 
@@ -249,17 +249,17 @@ var Bookmarks = Object.freeze({
         // Remove non-enumerable properties.
         return Object.assign({}, item);
       }
 
       let time = (updateInfo && updateInfo.dateAdded) || new Date();
       updateInfo = validateBookmarkObject(updateInfo,
         { url: { validIf: () => item.type == this.TYPE_BOOKMARK }
         , title: { validIf: () => [ this.TYPE_BOOKMARK
-                                  , this.TYPE_FOLDER ].indexOf(item.type) != -1 }
+                                  , this.TYPE_FOLDER ].includes(item.type) }
         , lastModified: { defaultValue: new Date()
                         , validIf: b => b.lastModified >= item.dateAdded }
         });
 
       return PlacesUtils.withConnectionWrapper("Bookmarks.jsm: update",
         Task.async(function*(db) {
         let parent;
         if (updateInfo.hasOwnProperty("parentGuid")) {
@@ -273,17 +273,17 @@ var Bookmarks = Object.freeze({
                  UNION ALL
                  SELECT id FROM moz_bookmarks
                  JOIN descendants ON parent = did
                  WHERE type = :type
                )
                SELECT guid FROM moz_bookmarks
                WHERE id IN descendants
               `, { id: item._id, type: this.TYPE_FOLDER });
-            if ([r.getResultByName("guid") for (r of rows)].indexOf(updateInfo.parentGuid) != -1)
+            if ([r.getResultByName("guid") for (r of rows)].includes(updateInfo.parentGuid))
               throw new Error("Cannot insert a folder into itself or one of its descendants");
           }
 
           parent = yield fetchBookmark({ guid: updateInfo.parentGuid });
           if (!parent)
             throw new Error("No bookmarks found for the provided parentGuid");
         }
 
@@ -379,17 +379,17 @@ var Bookmarks = Object.freeze({
     let info = guidOrInfo;
     if (!info)
       throw new Error("Input should be a valid object");
     if (typeof(guidOrInfo) != "object")
       info = { guid: guidOrInfo };
 
     // Disallow removing the root folders.
     if ([this.rootGuid, this.menuGuid, this.toolbarGuid, this.unfiledGuid,
-         this.tagsGuid].indexOf(info.guid) != -1) {
+         this.tagsGuid].includes(info.guid)) {
       throw new Error("It's not possible to remove Places root folders.");
     }
 
     // Even if we ignore any other unneeded property, we still validate any
     // known property to reduce likelihood of hidden bugs.
     let removeInfo = validateBookmarkObject(info);
 
     return Task.spawn(function* () {
@@ -1178,17 +1178,17 @@ const VALIDATORS = Object.freeze({
                                       /^[a-zA-Z0-9\-_]{12}$/.test(v)),
   index: simpleValidateFunc(v => Number.isInteger(v) &&
                                  v >= Bookmarks.DEFAULT_INDEX),
   dateAdded: simpleValidateFunc(v => v.constructor.name == "Date"),
   lastModified: simpleValidateFunc(v => v.constructor.name == "Date"),
   type: simpleValidateFunc(v => Number.isInteger(v) &&
                                 [ Bookmarks.TYPE_BOOKMARK
                                 , Bookmarks.TYPE_FOLDER
-                                , Bookmarks.TYPE_SEPARATOR ].indexOf(v) != -1),
+                                , Bookmarks.TYPE_SEPARATOR ].includes(v)),
   title: v => {
     simpleValidateFunc(val => val === null || typeof(val) == "string").call(this, v);
     if (!v)
       return null;
     return v.slice(0, DB_TITLE_LENGTH_MAX);
   },
   url: v => {
     simpleValidateFunc(val => (typeof(val) == "string" && val.length <= DB_URL_LENGTH_MAX) ||
--- a/toolkit/components/places/PlacesTransactions.jsm
+++ b/toolkit/components/places/PlacesTransactions.jsm
@@ -720,17 +720,17 @@ DefineTransaction.annotationObjectValida
 
   if (obj &&
       checkProperty("name", true, v => typeof(v) == "string" && v.length > 0) &&
       checkProperty("expires", false, Number.isInteger) &&
       checkProperty("flags", false, Number.isInteger) &&
       checkProperty("value", false, isPrimitive) ) {
     // Nothing else should be set
     let validKeys = ["name", "value", "flags", "expires"];
-    if (Object.keys(obj).every( (k) => validKeys.indexOf(k) != -1 ))
+    if (Object.keys(obj).every( (k) => validKeys.includes(k)))
       return obj;
   }
   throw new Error("Invalid annotation object");
 };
 
 DefineTransaction.urlValidate = function(url) {
   // When this module is updated to use Bookmarks.jsm, we should actually
   // convert nsIURIs/spec to URL objects.
@@ -1036,17 +1036,17 @@ function* createItemsFromBookmarksTree(a
       case PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR: {
         itemId = PlacesUtils.bookmarks.insertSeparator(parentId, aIndex, guid);
         break;
       }
     }
     if (annos.length > 0) {
       if (!aRestoring && aExcludingAnnotations.length > 0) {
         annos = [for(a of annos)
-                 if (aExcludingAnnotations.indexOf(a.name) == -1) a];
+                 if (!aExcludingAnnotations.includes(a.name)) a];
       }
 
       PlacesUtils.setAnnotationsForItem(itemId, annos);
     }
 
     if (aRestoring) {
       if ("dateAdded" in aItem)
         PlacesUtils.bookmarks.setItemDateAdded(itemId, aItem.dateAdded);
@@ -1090,17 +1090,17 @@ PT.NewBookmark.prototype = Object.seal({
         if (aKeyword)
           PlacesUtils.bookmarks.setKeywordForBookmark(itemId, aKeyword);
         if (aPostData)
           PlacesUtils.setPostDataForBookmark(itemId, aPostData);
         if (aAnnos.length)
           PlacesUtils.setAnnotationsForItem(itemId, aAnnos);
         if (aTags.length > 0) {
           let currentTags = PlacesUtils.tagging.getTagsForURI(aURI);
-          aTags = [t for (t of aTags) if (currentTags.indexOf(t) == -1)];
+          aTags = [t for (t of aTags) if (!currentTags.includes(t))];
           PlacesUtils.tagging.tagURI(aURI, aTags);
         }
 
         return itemId;
       },
       function _additionalOnUndo() {
         if (aTags.length > 0)
           PlacesUtils.tagging.untagURI(aURI, aTags);
@@ -1263,17 +1263,17 @@ PT.EditUrl.prototype = Object.seal({
     // Move tags from old URI to new URI.
     if (oldURITags.length > 0) {
       // Only untag the old URI if this is the only bookmark.
       if (PlacesUtils.getBookmarksForURI(oldURI, {}).length == 0)
         PlacesUtils.tagging.untagURI(oldURI, oldURITags);
 
       let currentNewURITags = PlacesUtils.tagging.getTagsForURI(aURI);
       newURIAdditionalTags = [t for (t of oldURITags)
-                              if (currentNewURITags.indexOf(t) == -1)];
+                              if (!currentNewURITags.includes(t))];
       if (newURIAdditionalTags)
         PlacesUtils.tagging.tagURI(aURI, newURIAdditionalTags);
     }
 
     this.undo = () => {
       PlacesUtils.bookmarks.changeBookmarkURI(itemId, oldURI);
       // Move tags from new URI to old URI.
       if (oldURITags.length > 0) {
@@ -1500,17 +1500,17 @@ PT.Tag.prototype = {
                          , tags: aTags
                          , parentGuid: PlacesUtils.bookmarks.unfiledGuid }));
         yield createTxn.execute();
         onUndo.unshift(createTxn.undo.bind(createTxn));
         onRedo.push(createTxn.redo.bind(createTxn));
       }
       else {
         let currentTags = PlacesUtils.tagging.getTagsForURI(currentURI);
-        let newTags = [t for (t of aTags) if (currentTags.indexOf(t) == -1)];
+        let newTags = [t for (t of aTags) if (!currentTags.includes(t))];
         PlacesUtils.tagging.tagURI(currentURI, newTags);
         onUndo.unshift(() => {
           PlacesUtils.tagging.untagURI(currentURI, newTags);
         });
         onRedo.push(() => {
           PlacesUtils.tagging.tagURI(currentURI, newTags);
         });
       }
@@ -1541,17 +1541,17 @@ PT.Untag.prototype = {
   execute: function* (aURIs, aTags) {
     let onUndo = [], onRedo = [];
     for (let uri of aURIs) {
       // Workaround bug 449811.
       let currentURI = uri;
       let tagsToRemove;
       let tagsSet = PlacesUtils.tagging.getTagsForURI(currentURI);
       if (aTags.length > 0)
-        tagsToRemove = [t for (t of aTags) if (tagsSet.indexOf(t) != -1)];
+        tagsToRemove = [t for (t of aTags) if (tagsSet.includes(t))];
       else
         tagsToRemove = tagsSet;
       PlacesUtils.tagging.untagURI(currentURI, tagsToRemove);
       onUndo.unshift(() => {
         PlacesUtils.tagging.tagURI(currentURI, tagsToRemove);
       });
       onRedo.push(() => {
         PlacesUtils.tagging.untagURI(currentURI, tagsToRemove);
--- a/toolkit/components/places/PlacesUtils.jsm
+++ b/toolkit/components/places/PlacesUtils.jsm
@@ -485,17 +485,17 @@ this.PlacesUtils = {
    * @param   aNode
    *          A result node
    * @returns true if the node is a container item, false otherwise
    */
   containerTypes: [Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER,
                    Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT,
                    Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY],
   nodeIsContainer: function PU_nodeIsContainer(aNode) {
-    return this.containerTypes.indexOf(aNode.type) != -1;
+    return this.containerTypes.includes(aNode.type);
   },
 
   /**
    * Determines whether or not a ResultNode is an history related container.
    * @param   node
    *          A result node
    * @returns true if the node is an history related container, false otherwise
    */
@@ -2983,17 +2983,17 @@ function PlacesRemoveLivemarkTransaction
   this.item.title = PlacesUtils.bookmarks.getItemTitle(this.item.id);
   this.item.parentId = PlacesUtils.bookmarks.getFolderIdForItem(this.item.id);
 
   let annos = PlacesUtils.getAnnotationsForItem(this.item.id);
   // Exclude livemark service annotations, those will be recreated automatically
   let annosToExclude = [PlacesUtils.LMANNO_FEEDURI,
                         PlacesUtils.LMANNO_SITEURI];
   this.item.annotations = annos.filter(function(aValue, aIndex, aArray) {
-      return annosToExclude.indexOf(aValue.name) == -1;
+      return !annosToExclude.includes(aValue.name);
     });
   this.item.dateAdded = PlacesUtils.bookmarks.getItemDateAdded(this.item.id);
   this.item.lastModified =
     PlacesUtils.bookmarks.getItemLastModified(this.item.id);
 }
 
 PlacesRemoveLivemarkTransaction.prototype = {
   __proto__: BaseTransaction.prototype,
@@ -3756,17 +3756,17 @@ PlacesUntagURITransaction.prototype = {
   __proto__: BaseTransaction.prototype,
 
   doTransaction: function UTUTXN_doTransaction()
   {
     // Filter tags existing on the bookmark, otherwise on undo we may try to
     // set nonexistent tags.
     let tags = PlacesUtils.tagging.getTagsForURI(this.item.uri);
     this.item.tags = this.item.tags.filter(function (aTag) {
-      return tags.indexOf(aTag) != -1;
+      return tags.includes(aTag);
     });
     PlacesUtils.tagging.untagURI(this.item.uri, this.item.tags);
   },
 
   undoTransaction: function UTUTXN_undoTransaction()
   {
     PlacesUtils.tagging.tagURI(this.item.uri, this.item.tags);
   }
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -1285,17 +1285,17 @@ Search.prototype = {
     }
 
     // Do not apply the special style if the user is doing a search from the
     // location bar but the entered terms match an irrelevant portion of the
     // URL. For example, "https://www.google.com/search?q=terms&client=firefox"
     // when searching for "Firefox".
     let terms = parseResult.terms.toLowerCase();
     if (this._searchTokens.length > 0 &&
-        this._searchTokens.every(token => terms.indexOf(token) == -1)) {
+        this._searchTokens.every(token => !terms.includes(token))) {
       return;
     }
 
     // Use the special separator that the binding will use to style the item.
     match.style = "search " + match.style;
     match.comment = parseResult.terms + TITLE_SEARCH_ENGINE_SEPARATOR +
                     parseResult.engineName;
   },
--- a/toolkit/components/places/nsTaggingService.js
+++ b/toolkit/components/places/nsTaggingService.js
@@ -639,17 +639,17 @@ TagAutoCompleteSearch.prototype = {
     function doSearch() {
       var i = 0;
       while (i < searchResults.length) {
         if (self._stopped)
           yield false;
         // for each match, prepend what the user has typed so far
         if (searchResults[i].toLowerCase()
                             .indexOf(searchString.toLowerCase()) == 0 &&
-            comments.indexOf(searchResults[i]) == -1) {
+            !comments.includes(searchResults[i])) {
           results.push(before + searchResults[i]);
           comments.push(searchResults[i]);
         }
     
         ++i;
 
         /* TODO: bug 481451
          * For each yield we pass a new result to the autocomplete
--- a/toolkit/components/places/tests/chrome/test_342484.xul
+++ b/toolkit/components/places/tests/chrome/test_342484.xul
@@ -38,17 +38,17 @@ function runTest() {
     })
     .then(function (aLivemark) {
       waitForLivemarkLoad(aLivemark, function (aLivemark) {
         let nodes = aLivemark.getNodesForContainer({});
 
         is(nodes.length, 2, "Created the two good livemark items");
         for (let i = 0; i < nodes.length; ++i) {
           let node = nodes[i];
-          ok(GOOD_URLS.indexOf(node.uri) != -1, "livemark item created with bad uri " + node.uri);
+          ok(GOOD_URLS.includes(node.uri), "livemark item created with bad uri " + node.uri);
         }
 
         PlacesUtils.livemarks.removeLivemark(aLivemark).then(() => {
           SimpleTest.finish();
         });
       });
     }, function () {
       is(true, false, "Should not fail adding a livemark");
--- a/toolkit/components/places/tests/head_common.js
+++ b/toolkit/components/places/tests/head_common.js
@@ -730,18 +730,18 @@ function do_compare_arrays(a1, a2, sorte
 {
   if (a1.length != a2.length)
     return false;
 
   if (sorted) {
     return a1.every((e, i) => e == a2[i]);
   }
   else {
-    return a1.filter(e => a2.indexOf(e) == -1).length == 0 &&
-           a2.filter(e => a1.indexOf(e) == -1).length == 0;
+    return a1.filter(e => !a2.includes(e)).length == 0 &&
+           a2.filter(e => !a1.includes(e)).length == 0;
   }
 }
 
 /**
  * Generic nsINavBookmarkObserver that doesn't implement anything, but provides
  * dummy methods to prevent errors about an object not having a certain method.
  */
 function NavBookmarkObserver() {}
--- a/toolkit/components/places/tests/queries/test_redirects.js
+++ b/toolkit/components/places/tests/queries/test_redirects.js
@@ -45,17 +45,17 @@ function check_results_callback(aSequenc
     }
 
     return true;
   });
 
   // Remove duplicates, since queries are RESULTS_AS_URI (unique pages).
   let seen = [];
   expectedData = expectedData.filter(function (aData) {
-    if (seen.indexOf(aData.uri) != -1)
+    if (seen.includes(aData.uri))
       return false;
     else
       seen.push(aData.uri);
     return true;
   });
 
   // Sort expectedData.
   function getFirstIndexFor(aEntry) {
--- a/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
+++ b/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
@@ -126,17 +126,17 @@ function _check_autocomplete_matches(mat
   if (stripPrefix(uri.spec) != stripPrefix(result.value) || title != result.comment) {
     return false;
   }
 
   let actualStyle = result.style.split(/\s+/).sort();
   if (style)
     Assert.equal(actualStyle.toString(), style.toString(), "Match should have expected style");
   if (uri.spec.startsWith("moz-action:")) {
-    Assert.ok(actualStyle.indexOf("action") != -1, "moz-action results should always have 'action' in their style");
+    Assert.ok(actualStyle.includes("action"), "moz-action results should always have 'action' in their style");
   }
 
   if (match.icon)
     Assert.equal(result.image, match.icon, "Match should have expected image");
 
   return true;
 }
 
--- a/toolkit/components/places/tests/unit/test_384370.js
+++ b/toolkit/components/places/tests/unit/test_384370.js
@@ -163,11 +163,11 @@ function testUnfiledBookmarks() {
   root.containerOpen = false;
 }
 
 function testTags() {
   for (let { uri, tags } of tagData) {
     do_print("Test tags for " + uri.spec + ": " + tags + "\n");
     let foundTags = PlacesUtils.tagging.getTagsForURI(uri);
     Assert.equal(foundTags.length, tags.length);
-    Assert.ok(tags.every(tag => foundTags.indexOf(tag) != -1));
+    Assert.ok(tags.every(tag => foundTags.includes(tag)));
   }
 }
--- a/toolkit/components/places/tests/unit/test_async_transactions.js
+++ b/toolkit/components/places/tests/unit/test_async_transactions.js
@@ -238,17 +238,17 @@ function ensureTimestampsUpdated(aGuid, 
   if (aCheckDateAdded)
     do_check_true(changes.has("dateAdded"))
   do_check_true(changes.has("lastModified"));
 }
 
 function ensureTagsForURI(aURI, aTags) {
   let tagsSet = tagssvc.getTagsForURI(aURI);
   do_check_eq(tagsSet.length, aTags.length);
-  do_check_true(aTags.every( t => tagsSet.indexOf(t) != -1 ));
+  do_check_true(aTags.every( t => tagsSet.includes(t)));
 }
 
 function createTestFolderInfo(aTitle = "Test Folder") {
   return { parentGuid: rootGuid, title: "Test Folder" };
 }
 
 function isLivemarkTree(aTree) {
   return !!aTree.annos &&
@@ -1157,17 +1157,17 @@ add_task(function* test_untag_uri() {
       for (let url of urls) {
         ensureTagsForURI(url, preRemovalTags.get(url));
       }
     }
     function ensureTagsUnset() {
       for (let url of urls) {
         let expectedTags = tagsRemoved.length == 0 ?
            [] : [for (tag of preRemovalTags.get(url))
-                 if (tagsRemoved.indexOf(tag) == -1) tag];
+                 if (!tagsRemoved.includes(tag)) tag];
         ensureTagsForURI(url, expectedTags);
       }
     }
 
     yield PT.Untag(aInfo).transact();
     yield ensureTagsUnset();
     yield PT.undo();
     yield ensureTagsSet();
--- a/toolkit/components/places/tests/unit/test_promiseBookmarksTree.js
+++ b/toolkit/components/places/tests/unit/test_promiseBookmarksTree.js
@@ -80,17 +80,17 @@ function* compareToNode(aItem, aNode, aI
 
       PlacesUtils.asContainer(aNode);
       if (!aNode.containerOpen)
         aNode.containerOpen = true;
 
       for (let i = 0; i < aNode.childCount; i++) {
         let childNode = aNode.getChild(i);
         if (childNode.itemId == PlacesUtils.tagsFolderId ||
-            aExcludedGuids.indexOf(childNode.bookmarkGuid) != -1) {
+            aExcludedGuids.includes(childNode.bookmarkGuid)) {
           continue;
         }
         expectedChildrenNodes.push(childNode);
       }
 
       if (expectedChildrenNodes.length > 0) {
         do_check_true(Array.isArray(aItem.children));
         do_check_eq(aItem.children.length, expectedChildrenNodes.length);
--- a/toolkit/components/places/tests/unit/test_tagging.js
+++ b/toolkit/components/places/tests/unit/test_tagging.js
@@ -88,38 +88,38 @@ function run_test() {
   var tagId = child.itemId;
   var tagTitle = child.title;
 
   // test mixed id/name tagging
   // as well as non-id numeric tags
   var uri3 = uri("http://testuri/3");
   tagssvc.tagURI(uri3, [tagId, "tag 3", "456"]);
   var tags = tagssvc.getTagsForURI(uri3);
-  do_check_true(tags.indexOf(tagTitle) != -1);
-  do_check_true(tags.indexOf("tag 3") != -1);
-  do_check_true(tags.indexOf("456") != -1);
+  do_check_true(tags.includes(tagTitle));
+  do_check_true(tags.includes("tag 3"));
+  do_check_true(tags.includes("456"));
 
   // test mixed id/name tagging
   tagssvc.untagURI(uri3, [tagId, "tag 3", "456"]);
   tags = tagssvc.getTagsForURI(uri3);
   do_check_eq(tags.length, 0);
 
   // Terminate tagging service, fire up a new instance and check that existing
   // tags are there.  This will ensure that any internal caching system is
   // correctly filled at startup and we are not losing previously existing tags.
   var uri4 = uri("http://testuri/4");
   tagssvc.tagURI(uri4, [tagId, "tag 3", "456"]);
   tagssvc = null;
   tagssvc = Cc["@mozilla.org/browser/tagging-service;1"].
             getService(Ci.nsITaggingService);
   var uri4Tags = tagssvc.getTagsForURI(uri4);
   do_check_eq(uri4Tags.length, 3);
-  do_check_true(uri4Tags.indexOf(tagTitle) != -1);
-  do_check_true(uri4Tags.indexOf("tag 3") != -1);
-  do_check_true(uri4Tags.indexOf("456") != -1);
+  do_check_true(uri4Tags.includes(tagTitle));
+  do_check_true(uri4Tags.includes("tag 3"));
+  do_check_true(uri4Tags.includes("456"));
 
   // Test sparse arrays.
   let curChildCount = tagRoot.childCount;
 
   try {
     tagssvc.tagURI(uri1, [, "tagSparse"]);
     do_check_eq(tagRoot.childCount, curChildCount + 1);
   } catch (ex) {
--- a/toolkit/components/places/tests/unit/test_utils_backups_create.js
+++ b/toolkit/components/places/tests/unit/test_utils_backups_create.js
@@ -18,17 +18,17 @@ add_task(function () {
   // Generate random dates.
   let dateObj = new Date();
   let dates = [];
   while (dates.length < NUMBER_OF_BACKUPS) {
     // Use last year to ensure today's backup is the newest.
     let randomDate = new Date(dateObj.getFullYear() - 1,
                               Math.floor(12 * Math.random()),
                               Math.floor(28 * Math.random()));
-    if (dates.indexOf(randomDate.getTime()) == -1)
+    if (!dates.includes(randomDate.getTime()))
       dates.push(randomDate.getTime());
   }
   // Sort dates from oldest to newest.
   dates.sort();
 
   // Get and cleanup the backups folder.
   let backupFolderPath = yield PlacesBackups.getBackupFolder();
   let bookmarksBackupDir = new FileUtils.File(backupFolderPath);