Bug 1560550 - Port |Bug 1339461 - Convert foo.indexOf(...) == -1 to foo.includes()| to SM - test files. r=frg
authorIan Neal <iann_cvs@blueyonder.co.uk>
Tue, 25 Jun 2019 23:37:29 +0200
changeset 35949 d04da3816b8e83bb9816322b5eb980e671ca704f
parent 35948 708b5e8fcaa6367e896f98abaaf783cb24c063e5
child 35950 4aed62fba5e7c54c0f66cdcdedd5ab917bd1d7d4
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersfrg
bugs1560550, 1339461
Bug 1560550 - Port |Bug 1339461 - Convert foo.indexOf(...) == -1 to foo.includes()| to SM - test files. r=frg
suite/browser/test/browser/browser_popupNotification.js
suite/components/places/tests/unit/test_leftpane_corruption_handling.js
suite/components/tests/browser/browser_394759_basic.js
suite/components/tests/browser/browser_408470.js
suite/components/tests/browser/browser_448741.js
suite/components/tests/browser/browser_493467.js
suite/components/tests/browser/browser_522545.js
suite/components/tests/chrome/test_idcheck.xul
--- a/suite/browser/test/browser/browser_popupNotification.js
+++ b/suite/browser/test/browser/browser_popupNotification.js
@@ -751,17 +751,17 @@ function triggerSecondaryCommand(popup, 
     for (let i = 0; i <= index; i++)
       EventUtils.synthesizeKey("VK_DOWN", {});
 
     // Activate
     EventUtils.synthesizeKey("VK_RETURN", {});
   });
 
   // One down event to open the popup
-  EventUtils.synthesizeKey("VK_DOWN", { altKey: (navigator.platform.indexOf("Mac") == -1) });
+  EventUtils.synthesizeKey("VK_DOWN", { altKey: !navigator.platform.includes("Mac") });
 }
 
 function loadURI(uri, callback) {
   if (callback) {
     gBrowser.addEventListener("load", function loadURIgBLoad() {
       // Ignore the about:blank load
       if (gBrowser.currentURI.spec != uri)
         return;
--- a/suite/components/places/tests/unit/test_leftpane_corruption_handling.js
+++ b/suite/components/places/tests/unit/test_leftpane_corruption_handling.js
@@ -165,17 +165,17 @@ function compareJSON(aNodeJSON_1, aNodeJ
   // List of properties we should not compare (expected to be different).
   const SKIP_PROPS = ["dateAdded", "lastModified", "id"];
 
   function compareObjects(obj1, obj2) {
     function count(o) { var n = 0; for (let p in o) n++; return n; }
     Assert.equal(count(obj1), count(obj2));
     for (let prop in obj1) {
       // Skip everchanging values.
-      if (SKIP_PROPS.indexOf(prop) != -1)
+      if (SKIP_PROPS.includes(prop))
         continue;
       // Skip undefined objects, otherwise we hang on them.
       if (!obj1[prop])
         continue;
       if (typeof(obj1[prop]) == "object")
         return compareObjects(obj1[prop], obj2[prop]);
       if (obj1[prop] !== obj2[prop]) {
         print(prop + ": " + obj1[prop] + "!=" + obj2[prop]);
--- a/suite/components/tests/browser/browser_394759_basic.js
+++ b/suite/components/tests/browser/browser_394759_basic.js
@@ -28,17 +28,17 @@ function test() {
     let textbox = newWin.content.document.getElementById("textbox");
     textbox.value = uniqueText;
 
     newWin.close();
 
     is(ss.getClosedWindowCount(), closedWindowCount + 1,
        "The closed window was added to Recently Closed Windows");
     let data = JSON.parse(ss.getClosedWindowData())[0];
-    ok(data.title == testURL && JSON.stringify(data).indexOf(uniqueText) > -1,
+    ok(data.title == testURL && JSON.stringify(data).includes(uniqueText),
        "The closed window data was stored correctly");
 
     // reopen the closed window and ensure its integrity
     let newWin2 = ss.undoCloseWindow(0);
 
     ok(newWin2 instanceof ChromeWindow,
        "undoCloseWindow actually returned a window");
     is(ss.getClosedWindowCount(), closedWindowCount,
--- a/suite/components/tests/browser/browser_408470.js
+++ b/suite/components/tests/browser/browser_408470.js
@@ -21,17 +21,17 @@ function test() {
       let ssTitle = aSS.title;
       stylesheetSwitchAll(tab.linkedBrowser.contentWindow, ssTitle);
 
       let newTab = ss.duplicateTab(window,tab);
       newTab.linkedBrowser.addEventListener("load", function loadListener2(aEvent) {
         newTab.linkedBrowser.removeEventListener("load", loadListener2, true);
         let states = Array.from(newTab.linkedBrowser.contentDocument.styleSheets,
                                 aSS => !aSS.disabled);
-        let correct = states.indexOf(true) == aIx && states.indexOf(true, aIx + 1) == -1;
+        let correct = states.indexOf(true) == aIx && !states.includes(true, aIx + 1);
 
         if (/^fail_/.test(ssTitle))
           ok(!correct, "didn't restore stylesheet " + ssTitle);
         else
           ok(correct, "restored stylesheet " + ssTitle);
 
         getBrowser().removeTab(newTab);
         if (--pendingCount == 0)
--- a/suite/components/tests/browser/browser_448741.js
+++ b/suite/components/tests/browser/browser_448741.js
@@ -15,17 +15,17 @@ function test() {
   tab.linkedBrowser.stop();
   ss.setTabValue(tab, uniqueName, uniqueValue);
   let valueWasCleaned = false;
 
   // prevent our value from being written to disk
   function cleaningObserver(aSubject, aTopic, aData) {
     ok(aTopic == "sessionstore-state-write", "observed correct topic?");
     ok(aSubject instanceof Ci.nsISupportsString, "subject is a string?");
-    ok(aSubject.data.indexOf(uniqueValue) > -1, "data contains our value?");
+    ok(aSubject.data.includes(uniqueValue), "data contains our value?");
 
     // find the data for the newly added tab and delete it
     let state = JSON.parse(aSubject.data);
     state.windows.forEach(function (winData) {
       winData.tabs.forEach(function (tabData) {
         if (tabData.extData && uniqueName in tabData.extData &&
             tabData.extData[uniqueName] == uniqueValue) {
           delete tabData.extData[uniqueName];
@@ -38,17 +38,17 @@ function test() {
     aSubject.data = JSON.stringify(state);
     Services.obs.removeObserver(cleaningObserver, aTopic, false);
   }
 
   // make sure that all later observers don't see that value any longer
   function checkingObserver(aSubject, aTopic, aData) {
     ok(valueWasCleaned && aSubject instanceof Ci.nsISupportsString,
        "ready to check the cleaned state?");
-    ok(aSubject.data.indexOf(uniqueValue) == -1, "data no longer contains our value?");
+    ok(!aSubject.data.includes(uniqueValue), "data no longer contains our value?");
 
     // clean up
     getBrowser().removeTab(tab);
     Services.obs.removeObserver(checkingObserver, aTopic, false);
     if (Services.prefs.prefHasUserValue("browser.sessionstore.interval"))
       Services.prefs.clearUserPref("browser.sessionstore.interval");
     finish();
   }
--- a/suite/components/tests/browser/browser_493467.js
+++ b/suite/components/tests/browser/browser_493467.js
@@ -33,16 +33,16 @@ function test() {
       docShell[attribute] = false;
     }
   }
 
   // make sure that all available permissions have been remembered
   tabState = JSON.parse(ss.getTabState(tab));
   let disallow = tabState.disallow.split(",");
   permissions.forEach(function(aName) {
-    ok(disallow.indexOf(aName) > -1, "Saved state of allow" + aName);
+    ok(disallow.includes(aName), "Saved state of allow" + aName);
   });
   // IF A TEST FAILS, please add the missing permission's name (without the
   // leading "allow") to nsSessionStore.js's CAPABILITIES array. Thanks.
 
   getBrowser().removeTab(tab);
   is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
 }
--- a/suite/components/tests/browser/browser_522545.js
+++ b/suite/components/tests/browser/browser_522545.js
@@ -150,17 +150,17 @@ function test() {
       uris.push("http://example.com/" + i);
 
     // We're waiting for the first location change, which should indicate
     // one of the tabs has loaded and the others haven't. So one should
     // be in a non-userTypedValue case, while others should still have
     // userTypedValue and userTypedClear set.
     getBrowser().addTabsProgressListener({
       onLocationChange: function (aBrowser) {
-        if (uris.indexOf(aBrowser.currentURI.spec) > -1) {
+        if (uris.includes(aBrowser.currentURI.spec)) {
           getBrowser().removeTabsProgressListener(this);
           firstLocationChange();
         }
       }
     });
 
     function firstLocationChange() {
       let state = JSON.parse(ss.getBrowserState());
--- a/suite/components/tests/chrome/test_idcheck.xul
+++ b/suite/components/tests/chrome/test_idcheck.xul
@@ -74,17 +74,17 @@
         {
           // always dump DOM trees of the conflicting elements
           dump("Double id='" + id + "' detected in " + aDocument.location.href + ":\n");
           dump("  Tree 0:\n");
           DumpElementTree(checkedList[id]);
           dump("  Tree 1:\n");
           DumpElementTree(idList[i]);
         }
-        if (aIgnorableIDs.indexOf(id) < 0)
+        if (!aIgnorableIDs.includes(id))
         {
           // if the id is not in our ignore list, show its status
           ok(!duplicate, "check id: " + filename + "#" + id);
         }
         else if (!(id in ignoredList))
         {
           // mark ignored id tests as todo,
           // even though we may never (be able to) fix them