Bug 868793 - Fix about:support's "ASSERTION: FormatStringFromName() without format parameters". r=felipe
authorDrew Willcoxon <adw@mozilla.com>
Mon, 20 May 2013 20:05:50 -0700
changeset 139600 1cd3b5a8c5a8155f1ccf04fe3949353e60f7f332
parent 139599 3a23e4fcc21494b8ffe942db11d1b5061d38172d
child 139601 7b4e9af7376413cd5a17503c2f811c986eb98525
push id3911
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 20:17:26 +0000
treeherdermozilla-aurora@7e26ca8db92b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe
bugs868793
milestone24.0a1
Bug 868793 - Fix about:support's "ASSERTION: FormatStringFromName() without format parameters". r=felipe
toolkit/content/aboutSupport.js
--- a/toolkit/content/aboutSupport.js
+++ b/toolkit/content/aboutSupport.js
@@ -76,21 +76,37 @@ let snapshotFormatters = {
       }));
       delete data.failures;
     }
 
     // graphics-tbody tbody
 
     function localizedMsg(msgArray) {
       let nameOrMsg = msgArray.shift();
+      if (msgArray.length) {
+        // formatStringFromName logs an NS_ASSERTION failure otherwise that says
+        // "use GetStringFromName".  Lame.
+        try {
+          return strings.formatStringFromName(nameOrMsg, msgArray,
+                                              msgArray.length);
+        }
+        catch (err) {
+          // Throws if nameOrMsg is not a name in the bundle.  This shouldn't
+          // actually happen though, since msgArray.length > 1 => nameOrMsg is a
+          // name in the bundle, not a message, and the remaining msgArray
+          // elements are parameters.
+          return nameOrMsg;
+        }
+      }
       try {
-        return strings.formatStringFromName(nameOrMsg, msgArray,
-                                            msgArray.length);
+        return strings.GetStringFromName(nameOrMsg);
       }
-      catch (err) {}
+      catch (err) {
+        // Throws if nameOrMsg is not a name in the bundle.
+      }
       return nameOrMsg;
     }
 
     let out = Object.create(data);
     let strings = stringBundle();
 
     out.acceleratedWindows =
       data.numAcceleratedWindows + "/" + data.numTotalWindows;