Bug 718518. Remove in-tree uses of the nonstandard third argument to String.prototype.replace. r=dcamp,jgriffin,dao,ted,dtownsend
authorTill Schneidereit <tschneidereit+bmo@gmail.com>
Wed, 18 Jan 2012 16:10:39 -0500
changeset 86045 0f8b66a9333317df9159b8bc255754ddb0a92dd5
parent 86044 f8f3d849c74acc24db4e82141e3902c166ce56f0
child 86046 92395111938e3a363af505e160d26305234d4357
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdcamp, jgriffin, dao, ted, dtownsend
bugs718518
milestone12.0a1
Bug 718518. Remove in-tree uses of the nonstandard third argument to String.prototype.replace. r=dcamp,jgriffin,dao,ted,dtownsend
browser/devtools/styleinspector/CssRuleView.jsm
services/sync/tps/extensions/tps/modules/tps.jsm
toolkit/content/LightweightThemeConsumer.jsm
toolkit/content/tests/chrome/test_bug253481.xul
toolkit/crashreporter/CrashSubmit.jsm
toolkit/mozapps/extensions/AddonRepository.jsm
toolkit/mozapps/extensions/XPIProvider.jsm
--- 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