Bug 718518. Remove in-tree uses of the nonstandard third argument to String.prototype.replace. r=dcamp,jgriffin,dao,ted,dtownsend
--- a/browser/devtools/styleinspector/CssRuleView.jsm
+++ b/browser/devtools/styleinspector/CssRuleView.jsm
@@ -1266,17 +1266,17 @@ InplaceEditor.prototype = {
/**
* Size the editor to fit its current contents.
*/
_updateSize: function InplaceEditor_updateSize()
{
// Replace spaces with non-breaking spaces. Otherwise setting
// the span's textContent will collapse spaces and the measurement
// will be wrong.
- this._measurement.textContent = this.input.value.replace(' ', '\u00a0', 'g');
+ this._measurement.textContent = this.input.value.replace(/ /g, '\u00a0');
// We add a bit of padding to the end. Should be enough to fit
// any letter that could be typed, otherwise we'll scroll before
// we get a chance to resize. Yuck.
let width = this._measurement.offsetWidth + 10;
this.input.style.width = width + "px";
},
--- a/services/sync/tps/extensions/tps/modules/tps.jsm
+++ b/services/sync/tps/extensions/tps/modules/tps.jsm
@@ -643,17 +643,17 @@ let TPS =
this._enabledEngines = names;
},
RunMozmillTest: function TPS__RunMozmillTest(testfile) {
var mozmillfile = CC["@mozilla.org/file/local;1"]
.createInstance(CI.nsILocalFile);
if (hh.oscpu.toLowerCase().indexOf('windows') > -1) {
let re = /\/(\w)\/(.*)/;
- this.config.testdir = this.config.testdir.replace(re, "$1://$2").replace("/", "\\", "g");
+ this.config.testdir = this.config.testdir.replace(re, "$1://$2").replace(/\//g, "\\");
}
mozmillfile.initWithPath(this.config.testdir);
mozmillfile.appendRelativePath(testfile);
Logger.logInfo("Running mozmill test " + mozmillfile.path);
var frame = {};
CU.import('resource://mozmill/modules/frame.js', frame);
frame.events.addListener('setTest', this.MozmillSetTestListener.bind(this));
--- a/toolkit/content/LightweightThemeConsumer.jsm
+++ b/toolkit/content/LightweightThemeConsumer.jsm
@@ -103,16 +103,16 @@ LightweightThemeConsumer.prototype = {
else
root.removeAttribute("drawintitlebar");
#endif
}
}
function _setImage(aElement, aActive, aURL) {
aElement.style.backgroundImage =
- (aActive && aURL) ? 'url("' + aURL.replace('"', '\\"', "g") + '")' : "";
+ (aActive && aURL) ? 'url("' + aURL.replace(/"/g, '\\"') + '")' : "";
}
function _parseRGB(aColorString) {
var rgb = aColorString.match(/^rgba?\((\d+), (\d+), (\d+)/);
rgb.shift();
return rgb.map(function (x) parseInt(x));
}
--- a/toolkit/content/tests/chrome/test_bug253481.xul
+++ b/toolkit/content/tests/chrome/test_bug253481.xul
@@ -51,21 +51,21 @@ SimpleTest.waitForFocus(function() {
setTimeout(function() {
var testString = "\n hello hello \n world\nworld \n";
var expectedResults = {
// even "pasteintact" strips leading/trailing newlines
"pasteintact": testString.replace(/^\n/, '').replace(/\n$/, ''),
// "pastetofirst" strips leading newlines
"pastetofirst": testString.replace(/^\n/, '').split(/\n/)[0],
// "replacewithspaces" strips trailing newlines first - bug 432415
-"replacewithspaces": testString.replace(/\n$/, '').replace('\n',' ','g'),
+"replacewithspaces": testString.replace(/\n$/, '').replace(/\n/g,' '),
// "strip" is pretty straightforward
-"strip": testString.replace('\n','','g'),
+"strip": testString.replace(/\n/g,''),
// "replacewithcommas" strips leading and trailing newlines first
-"replacewithcommas": testString.replace(/^\n/, '').replace(/\n$/, '').replace('\n',',','g'),
+"replacewithcommas": testString.replace(/^\n/, '').replace(/\n$/, '').replace(/\n/g,','),
// "stripsurroundingwhitespace" strips all newlines and whitespace around them
"stripsurroundingwhitespace": testString.replace(/\s*\n\s*/g,'')
};
// Put a multi-line string in the clipboard
SimpleTest.waitForClipboard(testString, function() {
var clip = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper);
--- a/toolkit/crashreporter/CrashSubmit.jsm
+++ b/toolkit/crashreporter/CrashSubmit.jsm
@@ -62,17 +62,17 @@ function parseKeyValuePairs(text) {
continue;
// can't just .split() because the value might contain = characters
let eq = lines[i].indexOf('=');
if (eq != -1) {
let [key, value] = [lines[i].substring(0, eq),
lines[i].substring(eq + 1)];
if (key && value)
- data[key] = value.replace("\\n", "\n", "g").replace("\\\\", "\\", "g");
+ data[key] = value.replace(/\\n/g, "\n").replace(/\\\\/g, "\\");
}
}
return data;
}
function parseKeyValuePairsFromFile(file) {
var fstream = Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(Ci.nsIFileInputStream);
--- a/toolkit/mozapps/extensions/AddonRepository.jsm
+++ b/toolkit/mozapps/extensions/AddonRepository.jsm
@@ -143,24 +143,24 @@ const INTEGER_KEY_MAP = {
function convertHTMLToPlainText(html) {
if (!html)
return html;
var converter = Cc["@mozilla.org/widget/htmlformatconverter;1"].
createInstance(Ci.nsIFormatConverter);
var input = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
- input.data = html.replace("\n", "<br>", "g");
+ input.data = html.replace(/\n/g, "<br>");
var output = {};
converter.convert("text/html", input, input.data.length, "text/unicode",
output, {});
if (output.value instanceof Ci.nsISupportsString)
- return output.value.data.replace("\r\n", "\n", "g");
+ return output.value.data.replace(/\r\n/g, "\n");
return html;
}
function getAddonsToCache(aIds, aCallback) {
try {
var types = Services.prefs.getCharPref(PREF_GETADDONS_CACHE_TYPES);
}
catch (e) { }
--- a/toolkit/mozapps/extensions/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/XPIProvider.jsm
@@ -823,18 +823,18 @@ function loadManifestFromRDF(aUri, aStre
// Generate random GUID used for Sync.
// This was lifted from util.js:makeGUID() from services-sync.
let rng = Cc["@mozilla.org/security/random-generator;1"].
createInstance(Ci.nsIRandomGenerator);
let bytes = rng.generateRandomBytes(9);
let byte_string = [String.fromCharCode(byte) for each (byte in bytes)]
.join("");
// Base64 encode
- addon.syncGUID = btoa(byte_string).replace('+', '-', 'g')
- .replace('/', '_', 'g');
+ addon.syncGUID = btoa(byte_string).replace(/\+/g, '-')
+ .replace(/\//g, '_');
return addon;
}
/**
* Loads an AddonInternal object from an add-on extracted in a directory.
*
* @param aDir