Bug 783025 - Replace String.indexOf(...) != -1 with String.contains(...). r=dao

This commit is contained in:
Amod 2012-09-08 22:58:23 +02:00
parent a0adbfd4d0
commit 38ada58ece
10 changed files with 15 additions and 15 deletions

View File

@ -658,7 +658,7 @@ var allTabs = {
} catch (e) {}
tabstring = tab.label + " " + tab.label.toLocaleLowerCase() + " " + tabstring;
for (let i = 0; i < filter.length; i++)
matches += tabstring.indexOf(filter[i]) > -1;
matches += tabstring.contains(filter[i]);
}
if (matches < filter.length || tab.hidden) {
preview.hidden = true;

View File

@ -1049,7 +1049,7 @@ var gBrowserInit = {
// set default character set if provided
if ("arguments" in window && window.arguments.length > 1 && window.arguments[1]) {
if (window.arguments[1].indexOf("charset=") != -1) {
if (window.arguments[1].startsWith("charset=")) {
var arrayArgComponents = window.arguments[1].split("=");
if (arrayArgComponents) {
//we should "inherit" the charset menu setting in a new window
@ -2758,7 +2758,7 @@ function getMeOutOfHere() {
url = prefs.getComplexValue("browser.startup.homepage",
Ci.nsIPrefLocalizedString).data;
// If url is a pipe-delimited set of pages, just take the first one.
if (url.indexOf("|") != -1)
if (url.contains("|"))
url = url.split("|")[0];
} catch(e) {
Components.utils.reportError("Couldn't get homepage pref: " + e);
@ -3467,7 +3467,7 @@ function FillHistoryMenu(aParent) {
function addToUrlbarHistory(aUrlToAdd) {
if (aUrlToAdd &&
aUrlToAdd.indexOf(" ") == -1 &&
!aUrlToAdd.contains(" ") &&
!/[\x00-\x1F]/.test(aUrlToAdd))
PlacesUIUtils.markPageAsTyped(aUrlToAdd);
}

View File

@ -57,8 +57,8 @@ let RemoteTabViewer = {
let item = this._tabsList.getItemAtIndex(i);
let hide = false;
if (item.getAttribute("type") == "tab") {
if (item.getAttribute("url").toLowerCase().indexOf(val) == -1 &&
item.getAttribute("title").toLowerCase().indexOf(val) == -1)
if (!item.getAttribute("url").toLowerCase().contains(val) &&
!item.getAttribute("title").toLowerCase().contains(val))
hide = true;
else
clientTabs++;

View File

@ -795,7 +795,7 @@
// add the scheme and host to the title to prevent spoofing.
// XXX https://bugzilla.mozilla.org/show_bug.cgi?id=22183#c239
try {
if (docElement.getAttribute("chromehidden").indexOf("location") != -1) {
if (docElement.getAttribute("chromehidden").contains("location")) {
var uri = this.mURIFixup.createExposableURI(
aBrowser.currentURI);
if (uri.scheme == "about")
@ -3750,7 +3750,7 @@
} catch (ex) {}
// valid urls don't contain spaces ' '; if we have a space it isn't a valid url.
if (!url || url.indexOf(" ") != -1)
if (!url || url.contains(" "))
return;
let bgLoad = Services.prefs.getBoolPref("browser.tabs.loadInBackground");

View File

@ -19,7 +19,7 @@ function afterZoomAndLoad(aCallback, aTab) {
value = undefined;
oldAPTS.call(FullZoom, value, browser);
// Don't reset _applyPrefToSetting until we've seen the about:blank load(s)
if (browser && (browser.currentURI.spec.indexOf("http:") != -1)) {
if (browser && browser.currentURI.spec.startsWith("http:")) {
FullZoom._applyPrefToSetting = oldAPTS;
didZoom = true;
}

View File

@ -28,7 +28,7 @@ function test() {
executeSoon(function () {
let consoleListener = {
observe: function (m) {
if (m.message.indexOf("NS_ERROR_DOM_BAD_URI") > -1) {
if (m.message.contains("NS_ERROR_DOM_BAD_URI")) {
ok(true, "drop was blocked");
executeSoon(finish);
}

View File

@ -756,7 +756,7 @@ function triggerSecondaryCommand(popup, index) {
}, false);
// One down event to open the popup
EventUtils.synthesizeKey("VK_DOWN", { altKey: (navigator.platform.indexOf("Mac") == -1) });
EventUtils.synthesizeKey("VK_DOWN", { altKey: !navigator.platform.contains("Mac") });
}
function loadURI(uri, callback) {

View File

@ -143,7 +143,7 @@ function checkOKButton() {
// This rest of particular test doesn't really apply on Mac, since buttons
// aren't focusable by default.
if (navigator.platform.indexOf("Mac") != -1) {
if (navigator.platform.contains("Mac")) {
executeSoon(testCloseBySpace);
return;
}
@ -151,7 +151,7 @@ function checkOKButton() {
let displayName = document.getElementById("socialUserDisplayName");
// Linux has the buttons in the [unshare] [ok] order, so displayName will come first.
if (navigator.platform.indexOf("Linux") != -1) {
if (navigator.platform.contains("Linux")) {
checkNextInTabOrder(displayName, function () {
checkNextInTabOrder(undoButton, function () {
checkNextInTabOrder(okButton, testCloseBySpace);

View File

@ -76,7 +76,7 @@ function handleMessageEvents(event) {
catch (e) {
var bodyInnerHTML = "";
}
if (cacheCount == 2 || (bodyInnerHTML.indexOf("error") != -1)) {
if (cacheCount == 2 || bodyInnerHTML.contains("error")) {
clearInterval(intervalID);
is(cacheCount, 2, "frame not reloaded successfully");
if (cacheCount != 2) {

View File

@ -466,7 +466,7 @@
return selectedVal;
// The selection doesn't span the full domain if it doesn't contain a slash and is
// followed by some character other than a slash.
if (selectedVal.indexOf("/") == -1) {
if (!selectedVal.contains("/")) {
let remainder = inputVal.replace(selectedVal, "");
if (remainder != "" && remainder[0] != "/")
return selectedVal;