Bug 1103588 - Part 1: Replace deprecated String#contains with String#includes in browser tests and extensions. r=dolske
authorChris Peterson <cpeterson@mozilla.com>
Sat, 09 Apr 2016 16:05:17 -0700
changeset 330819 e0f16e09b67330faa40f8dd491e87963e0d2655e
parent 330818 f43c0ea2c7c847ca361375164b3a4c58eb714426
child 330820 28e0d6720135c0bd7153db04418e9ca82d814bf7
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs1103588
milestone48.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 1103588 - Part 1: Replace deprecated String#contains with String#includes in browser tests and extensions. r=dolske
browser/base/content/test/general/browser_aboutCertError.js
browser/components/sessionstore/test/browser_581937.js
browser/components/sessionstore/test/browser_aboutPrivateBrowsing.js
browser/extensions/loop/chrome/test/xpcshell/test_looprooms.js
browser/extensions/pocket/content/pktApi.jsm
--- a/browser/base/content/test/general/browser_aboutCertError.js
+++ b/browser/base/content/test/general/browser_aboutCertError.js
@@ -1,11 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 // This is testing the aboutCertError page (Bug 1207107).
 
 const GOOD_PAGE = "https://example.com/";
 const BAD_CERT = "https://expired.example.com/";
 const BAD_STS_CERT = "https://badchain.include-subdomains.pinning.example.com:443";
 const {TabStateFlusher} = Cu.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {});
 const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
 
@@ -144,25 +146,25 @@ add_task(function* checkAdvancedDetails(
     let serializedSecurityInfo = serhelper.serializeToString(serializable);
     return {
       divDisplay: div.style.display,
       text: text.textContent,
       securityInfoAsString: serializedSecurityInfo
     };
   });
   is(message.divDisplay, "block", "Debug information is visible");
-  ok(message.text.contains(BAD_CERT), "Correct URL found");
-  ok(message.text.contains("Certificate has expired"),
+  ok(message.text.includes(BAD_CERT), "Correct URL found");
+  ok(message.text.includes("Certificate has expired"),
      "Correct error message found");
-  ok(message.text.contains("HTTP Strict Transport Security: false"),
+  ok(message.text.includes("HTTP Strict Transport Security: false"),
      "Correct HSTS value found");
-  ok(message.text.contains("HTTP Public Key Pinning: false"),
+  ok(message.text.includes("HTTP Public Key Pinning: false"),
      "Correct HPKP value found");
   let certChain = getCertChain(message.securityInfoAsString);
-  ok(message.text.contains(certChain), "Found certificate chain");
+  ok(message.text.includes(certChain), "Found certificate chain");
 
   gBrowser.removeCurrentTab();
 });
 
 add_task(function* checkAdvancedDetailsForHSTS() {
   info("Loading a bad STS cert page and verifying the advanced details section");
   let browser;
   let certErrorLoaded;
@@ -216,25 +218,25 @@ add_task(function* checkAdvancedDetailsF
     let serializedSecurityInfo = serhelper.serializeToString(serializable);
     return {
       divDisplay: div.style.display,
       text: text.textContent,
       securityInfoAsString: serializedSecurityInfo
     };
   });
   is(message.divDisplay, "block", "Debug information is visible");
-  ok(message.text.contains(badStsUri.spec), "Correct URL found");
-  ok(message.text.contains("requested domain name does not match the server's certificate"),
+  ok(message.text.includes(badStsUri.spec), "Correct URL found");
+  ok(message.text.includes("requested domain name does not match the server's certificate"),
      "Correct error message found");
-  ok(message.text.contains("HTTP Strict Transport Security: false"),
+  ok(message.text.includes("HTTP Strict Transport Security: false"),
      "Correct HSTS value found");
-  ok(message.text.contains("HTTP Public Key Pinning: true"),
+  ok(message.text.includes("HTTP Public Key Pinning: true"),
      "Correct HPKP value found");
   let certChain = getCertChain(message.securityInfoAsString);
-  ok(message.text.contains(certChain), "Found certificate chain");
+  ok(message.text.includes(certChain), "Found certificate chain");
 
   gBrowser.removeCurrentTab();
 });
 
 function waitForCertErrorLoad(browser) {
   return new Promise(resolve => {
     info("Waiting for DOMContentLoaded event");
     browser.addEventListener("DOMContentLoaded", function load() {
--- a/browser/components/sessionstore/test/browser_581937.js
+++ b/browser/components/sessionstore/test/browser_581937.js
@@ -10,10 +10,10 @@ add_task(function* () {
   is(tab.linkedBrowser.currentURI.spec, "about:blank",
      "we will be removing an about:blank tab");
 
   let r = `rand-${Math.random()}`;
   ss.setTabValue(tab, "foobar", r);
 
   yield promiseRemoveTab(tab);
   let closedTabData = ss.getClosedTabData(window);
-  ok(!closedTabData.contains(r), "tab not stored in _closedTabs");
+  ok(!closedTabData.includes(r), "tab not stored in _closedTabs");
 });
--- a/browser/components/sessionstore/test/browser_aboutPrivateBrowsing.js
+++ b/browser/components/sessionstore/test/browser_aboutPrivateBrowsing.js
@@ -12,10 +12,10 @@ add_task(function* () {
   is(gBrowser.browsers[1].currentURI.spec, "about:privatebrowsing",
      "we will be removing an about:privatebrowsing tab");
 
   let r = `rand-${Math.random()}`;
   ss.setTabValue(tab, "foobar", r);
 
   yield promiseRemoveTab(tab);
   let closedTabData = ss.getClosedTabData(window);
-  ok(!closedTabData.contains(r), "tab not stored in _closedTabs");
+  ok(!closedTabData.includes(r), "tab not stored in _closedTabs");
 });
--- a/browser/extensions/loop/chrome/test/xpcshell/test_looprooms.js
+++ b/browser/extensions/loop/chrome/test/xpcshell/test_looprooms.js
@@ -398,17 +398,17 @@ add_task(function* test_createRoom() {
   var expectedRoom = extend({}, kCreateRoomProps);
   expectedRoom.roomToken = kCreateRoomData.roomToken;
 
   gExpectedAdds.push(expectedRoom);
   let room = yield LoopRooms.promise("create", kCreateRoomProps);
 
   // We can't check the value of the key, but check we've got a # which indicates
   // there should be one.
-  Assert.ok(room.roomUrl.contains("#"), "Created room url should have a key");
+  Assert.ok(room.roomUrl.includes("#"), "Created room url should have a key");
   var key = room.roomUrl.split("#")[1];
   Assert.ok(key.length, "Created room url should have non-zero length key");
 
   compareRooms(room, expectedRoom);
 });
 
 // Test if opening a new room window works correctly.
 add_task(function* test_openRoom() {
--- a/browser/extensions/pocket/content/pktApi.jsm
+++ b/browser/extensions/pocket/content/pktApi.jsm
@@ -607,17 +607,17 @@ var pktApi = (function() {
         });
     }
 
     /**
      * Helper function to get current signup AB group the user is in
      */
     function getSignupAB() {
         var setting = getSetting('signupAB');
-        if (!setting || setting.contains('hero'))
+        if (!setting || setting.includes('hero'))
         {
             var rand = (Math.floor(Math.random()*100+1));
             if (rand > 90)
             {
                 setting = 'storyboard_nlm';
             }
             else
             {