Bug 1075059 - Part 1: Backout of Array.prototpype.contains usages. r=me
authorTill Schneidereit <till@tillschneidereit.net>
Thu, 02 Oct 2014 17:37:48 +0200
changeset 208479 3c341e9e6639a181a1f7d9ae992813f414e61db6
parent 208478 5bed1b3e2da643aaf6d6184f7ffb465989f87e66
child 208480 7009237d5e47c9e15d1fde75d19c2744afe3322b
push id27585
push useremorley@mozilla.com
push dateFri, 03 Oct 2014 13:26:33 +0000
treeherdermozilla-central@e4f5e843a370 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1075059
milestone35.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 1075059 - Part 1: Backout of Array.prototpype.contains usages. r=me
browser/base/content/browser-addons.js
browser/base/content/browser-places.js
browser/base/content/browser.js
browser/base/content/newtab/updater.js
browser/base/content/pageinfo/permissions.js
browser/base/content/sync/setup.js
browser/base/content/tabbrowser.xml
browser/base/content/test/general/browser_bug521216.js
browser/base/content/test/general/browser_contentAreaClick.js
browser/base/content/test/general/browser_devices_get_user_media.js
browser/base/content/test/general/browser_devices_get_user_media_about_urls.js
browser/base/content/test/general/head.js
browser/base/content/test/general/test_contextmenu.html
browser/base/content/urlbarBindings.xml
--- a/browser/base/content/browser-addons.js
+++ b/browser/base/content/browser-addons.js
@@ -41,17 +41,17 @@ const gXPInstallObserver = {
                               .getInterface(Components.interfaces.nsIWebNavigation)
                               .QueryInterface(Components.interfaces.nsIDocShell);
       browser = this._getBrowser(shell);
     } catch (e) {
       browser = winOrBrowser;
     }
     // Note that the above try/catch will pass through dead object proxies and
     // other degenerate objects. Make sure the browser is bonafide.
-    if (!browser || !gBrowser.browsers.contains(browser))
+    if (!browser || gBrowser.browsers.indexOf(browser) == -1)
       return;
 
     const anchorID = "addons-notification-icon";
     var messageString, action;
     var brandShortName = brandBundle.getString("brandShortName");
 
     var notificationID = aTopic;
     // Make notifications persist a minimum of 30 seconds
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -1366,17 +1366,17 @@ let 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(
-        function (id) !aItemIds.contains(id)
+        function (id) aItemIds.indexOf(id) == -1
       ).concat(aItemIds);
 
       this._updateStar();
 
       // Start observing bookmarks if needed.
       if (!this._hasBookmarksObserver) {
         try {
           PlacesUtils.addLazyBookmarkObserver(this);
@@ -1587,17 +1587,17 @@ let 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.contains(aItemId)) {
+      if (this._itemIds.indexOf(aItemId) == -1) {
         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/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2228,17 +2228,17 @@ function URLBarSetURI(aURI) {
     // Strip off "wyciwyg://" and passwords for the location bar
     try {
       uri = Services.uriFixup.createExposableURI(uri);
     } catch (e) {}
 
     // Replace initial page URIs with an empty string
     // only if there's no opener (bug 370555).
     // Bug 863515 - Make content.opener checks work in electrolysis.
-    if (gInitialPages.contains(uri.spec))
+    if (gInitialPages.indexOf(uri.spec) != -1)
       value = !gMultiProcessBrowser && content.opener ? uri.spec : "";
     else
       value = losslessDecodeURI(uri);
 
     valid = !isBlankPageURL(uri.spec);
   }
 
   gURLBar.value = value;
--- a/browser/base/content/newtab/updater.js
+++ b/browser/base/content/newtab/updater.js
@@ -124,17 +124,17 @@ let gUpdater = {
    * @param aCallback The callback to call when finished.
    */
   _removeLegacySites: function Updater_removeLegacySites(aSites, aCallback) {
     let batch = [];
 
     // Delete sites that were removed from the grid.
     gGrid.sites.forEach(function (aSite) {
       // The site must be valid and not in the current grid.
-      if (!aSite || aSites.contains(aSite))
+      if (!aSite || aSites.indexOf(aSite) != -1)
         return;
 
       batch.push(new Promise(resolve => {
         // Fade out the to-be-removed site.
         gTransformation.hideSite(aSite, function () {
           let node = aSite.node;
 
           // Remove the site from the DOM.
--- a/browser/base/content/pageinfo/permissions.js
+++ b/browser/base/content/pageinfo/permissions.js
@@ -13,17 +13,17 @@ var gPermissions = SitePermissions.listP
 gPermissions.push("plugins");
 
 var permissionObserver = {
   observe: function (aSubject, aTopic, aData)
   {
     if (aTopic == "perm-changed") {
       var permission = aSubject.QueryInterface(Components.interfaces.nsIPermission);
       if (permission.host == gPermURI.host) {
-        if (gPermissions.contains(permission.type))
+        if (gPermissions.indexOf(permission.type) > -1)
           initRow(permission.type);
         else if (permission.type.startsWith("plugin"))
           setPluginsRadioState();
       }
     }
   }
 };
 
--- a/browser/base/content/sync/setup.js
+++ b/browser/base/content/sync/setup.js
@@ -147,19 +147,19 @@ var gSyncSetup = {
 
     // Generate a new passphrase so that Weave.Service.login() will
     // actually do something.
     let passphrase = Weave.Utils.generatePassphrase();
     Weave.Service.identity.syncKey = passphrase;
 
     // Only open the dialog if username + password are actually correct.
     Weave.Service.login();
-    if (![Weave.LOGIN_FAILED_INVALID_PASSPHRASE,
-          Weave.LOGIN_FAILED_NO_PASSPHRASE,
-          Weave.LOGIN_SUCCEEDED].contains(Weave.Status.login)) {
+    if ([Weave.LOGIN_FAILED_INVALID_PASSPHRASE,
+         Weave.LOGIN_FAILED_NO_PASSPHRASE,
+         Weave.LOGIN_SUCCEEDED].indexOf(Weave.Status.login) == -1) {
       return;
     }
 
     // Hide any errors about the passphrase, we know it's not right.
     let feedback = document.getElementById("existingPassphraseFeedbackRow");
     feedback.hidden = true;
     let el = document.getElementById("existingPassphrase");
     el.value = Weave.Utils.hyphenatePassphrase(passphrase);
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -1663,17 +1663,17 @@
             evt.initEvent("TabOpen", true, false);
             t.dispatchEvent(evt);
 
             // If we didn't swap docShells with a preloaded browser
             // then let's just continue loading the page normally.
             if (!docShellsSwapped && !uriIsAboutBlank) {
               // pretend the user typed this so it'll be available till
               // the document successfully loads
-              if (aURI && !gInitialPages.contains(aURI))
+              if (aURI && gInitialPages.indexOf(aURI) == -1)
                 b.userTypedValue = aURI;
 
               let flags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
               if (aAllowThirdPartyFixup) {
                 flags |= Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
                 flags |= Ci.nsIWebNavigation.LOAD_FLAGS_FIXUP_SCHEME_TYPOS;
               }
               if (aFromExternal)
@@ -2162,24 +2162,24 @@
                 return !tab.closing;
               }, this);
             }
 
             // Try to find a remaining tab that comes after the given tab
             var tab = aTab;
             do {
               tab = tab.nextSibling;
-            } while (tab && !remainingTabs.contains(tab));
+            } while (tab && remainingTabs.indexOf(tab) == -1);
 
             if (!tab) {
               tab = aTab;
 
               do {
                 tab = tab.previousSibling;
-              } while (tab && !remainingTabs.contains(tab));
+              } while (tab && remainingTabs.indexOf(tab) == -1);
             }
 
             this.selectedTab = tab;
           ]]>
         </body>
       </method>
 
       <method name="swapNewTabWithBrowser">
@@ -2417,20 +2417,20 @@
         </body>
       </method>
 
       <method name="showOnlyTheseTabs">
         <parameter name="aTabs"/>
         <body>
         <![CDATA[
           Array.forEach(this.tabs, function(tab) {
-            if (aTabs.contains(tab))
+            if (aTabs.indexOf(tab) == -1)
+              this.hideTab(tab);
+            else
               this.showTab(tab);
-            else
-              this.hideTab(tab);
           }, this);
 
           this.tabContainer._handleTabSelect(false);
         ]]>
         </body>
       </method>
 
       <method name="showTab">
--- a/browser/base/content/test/general/browser_bug521216.js
+++ b/browser/base/content/test/general/browser_bug521216.js
@@ -8,17 +8,17 @@ function test() {
   tabIndex = gBrowser.tabs.length;
   gBrowser.addTabsProgressListener(progressListener);
   gBrowser.tabContainer.addEventListener("TabOpen", TabOpen, false);
   gBrowser.addTab("data:text/html,<html><head><link href='about:logo' rel='shortcut icon'>");
 }
 
 function record(aName) {
   info("got " + aName);
-  if (!actual.contains(aName))
+  if (actual.indexOf(aName) == -1)
     actual.push(aName);
   if (actual.length == expected.length) {
     is(actual.toString(), expected.toString(),
        "got events and progress notifications in expected order");
     gBrowser.removeTab(tab);
     gBrowser.removeTabsProgressListener(progressListener);
     gBrowser.tabContainer.removeEventListener("TabOpen", TabOpen, false);
     finish();
--- a/browser/base/content/test/general/browser_contentAreaClick.js
+++ b/browser/base/content/test/general/browser_contentAreaClick.js
@@ -207,18 +207,18 @@ let gClickHandler = {
     let isPanelClick = linkId == "panellink";
     gTestWin.contentAreaClick(event, isPanelClick);
     let prevent = event.defaultPrevented;
     is(prevent, gCurrentTest.preventDefault,
        gCurrentTest.desc + ": event.defaultPrevented is correct (" + prevent + ")")
 
     // Check that all required methods have been called.
     gCurrentTest.expectedInvokedMethods.forEach(function(aExpectedMethodName) {
-      ok(gInvokedMethods.contains(aExpectedMethodName),
-         gCurrentTest.desc + ":" + aExpectedMethodName + " was invoked");
+      isnot(gInvokedMethods.indexOf(aExpectedMethodName), -1,
+            gCurrentTest.desc + ":" + aExpectedMethodName + " was invoked");
     });
     
     if (gInvokedMethods.length != gCurrentTest.expectedInvokedMethods.length) {
       ok(false, "Wrong number of invoked methods");
       gInvokedMethods.forEach(function (method) info(method + " was invoked"));
     }
 
     event.preventDefault();
--- a/browser/base/content/test/general/browser_devices_get_user_media.js
+++ b/browser/base/content/test/general/browser_devices_get_user_media.js
@@ -28,17 +28,17 @@ function observer(aSubject, aTopic, aDat
 
 function promiseObserverCalled(aTopic, aAction) {
   let deferred = Promise.defer();
 
   Services.obs.addObserver(function observer() {
     ok(true, "got " + aTopic + " notification");
     Services.obs.removeObserver(observer, aTopic);
 
-    if (kObservedTopics.contains(aTopic)) {
+    if (kObservedTopics.indexOf(aTopic) != -1) {
       if (!(aTopic in gObservedTopics))
         gObservedTopics[aTopic] = -1;
       else
         --gObservedTopics[aTopic];
     }
 
     deferred.resolve();
   }, aTopic, false);
@@ -822,17 +822,17 @@ let gTests = [
     let alwaysLabel = gNavigatorBundle.getString("getUserMedia.always.label");
     ok(!!alwaysLabel, "found the 'Always Allow' localized label");
     let labels = [];
     let notification = PopupNotifications.panel.firstChild;
     for (let node of notification.childNodes) {
       if (node.localName == "menuitem")
         labels.push(node.getAttribute("label"));
     }
-    ok(!labels.contains(alwaysLabel), "The 'Always Allow' item isn't shown");
+    is(labels.indexOf(alwaysLabel), -1, "The 'Always Allow' item isn't shown");
 
     // Cleanup.
     yield closeStream(true);
     Perms.remove(uri.host, "camera");
     Perms.remove(uri.host, "microphone");
   }
 }
 
--- a/browser/base/content/test/general/browser_devices_get_user_media_about_urls.js
+++ b/browser/base/content/test/general/browser_devices_get_user_media_about_urls.js
@@ -33,17 +33,17 @@ function promiseObserverCalled(aTopic, a
   let deferred = Promise.defer();
   info("Waiting for " + aTopic);
 
   Services.obs.addObserver(function observer(aSubject, topic, aData) {
     ok(true, "got " + aTopic + " notification");
     info("Message: " + aData);
     Services.obs.removeObserver(observer, aTopic);
 
-    if (kObservedTopics.contains(aTopic)) {
+    if (kObservedTopics.indexOf(aTopic) != -1) {
       if (!(aTopic in gObservedTopics))
         gObservedTopics[aTopic] = -1;
       else
         --gObservedTopics[aTopic];
     }
 
     deferred.resolve();
   }, aTopic, false);
--- a/browser/base/content/test/general/head.js
+++ b/browser/base/content/test/general/head.js
@@ -686,17 +686,17 @@ function makeActionURI(action, params) {
 
 function is_hidden(element) {
   var style = element.ownerDocument.defaultView.getComputedStyle(element, "");
   if (style.display == "none")
     return true;
   if (style.visibility != "visible")
     return true;
   if (style.display == "-moz-popup")
-    return ["hiding","closed"].contains(element.state);
+    return ["hiding","closed"].indexOf(element.state) != -1;
 
   // Hiding a parent element will hide all its children
   if (element.parentNode != element.ownerDocument)
     return is_hidden(element.parentNode);
 
   return false;
 }
 
--- a/browser/base/content/test/general/test_contextmenu.html
+++ b/browser/base/content/test/general/test_contextmenu.html
@@ -886,17 +886,17 @@ function waitForEvents(event)
     loaded = true;
   if (painted && loaded) {
     subwindow.removeEventListener("MozAfterPaint", waitForEvents, false);
     subwindow.onload = null;
     startTest();
   }
 }
 
-const isOSXMtnLion = navigator.userAgent.contains("Mac OS X 10.8");
+const isOSXMtnLion = navigator.userAgent.indexOf("Mac OS X 10.8") != -1;
 
 if (isOSXMtnLion) {
   todo(false, "Mountain Lion doesn't like this test (bug 792304)");
 } else {
   SpecialPowers.setBoolPref("plugins.click_to_play", true);
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
 
   var subwindow = window.open("./subtst_contextmenu.html", "contextmenu-subtext", "width=600,height=800");
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -194,17 +194,17 @@
           let selection = controller.getSelection(controller.SELECTION_URLSECONDARY);
           selection.removeAllRanges();
 
           let textNode = this.editor.rootElement.firstChild;
           let value = textNode.textContent;
 
           let protocol = value.match(/^[a-z\d.+\-]+:(?=[^\d])/);
           if (protocol &&
-              !["http:", "https:", "ftp:"].contains(protocol[0]))
+              ["http:", "https:", "ftp:"].indexOf(protocol[0]) == -1)
             return;
           let matchedURL = value.match(/^((?:[a-z]+:\/\/)?(?:[^\/]+@)?)(.+?)(?::\d+)?(?:\/|$)/);
           if (!matchedURL)
             return;
 
           let [, preDomain, domain] = matchedURL;
           let baseDomain = domain;
           let subDomain = "";