Bug 1378366 - If the default font is not found, use 'Default' as the name for an unchanged font preference. Previously this would show up as blank in this case. r=timdream
authorJared Wein <jwein@mozilla.com>
Thu, 26 Oct 2017 12:25:12 -0400
changeset 688105 1a6103d5708d6bfcf477b329b2a0aba79f27d1ef
parent 688104 9ded8c9fd0d253bc781f970c30daf6ae6119e32d
child 688106 170e3ed76a389209e79b9f2200ece037950af813
push id86669
push userhikezoe@mozilla.com
push dateSat, 28 Oct 2017 10:13:18 +0000
reviewerstimdream
bugs1378366
milestone58.0a1
Bug 1378366 - If the default font is not found, use 'Default' as the name for an unchanged font preference. Previously this would show up as blank in this case. r=timdream MozReview-Commit-ID: G1GEwWNtBMi
browser/locales/en-US/chrome/browser/preferences/preferences.properties
toolkit/mozapps/preferences/fontbuilder.js
--- a/browser/locales/en-US/chrome/browser/preferences/preferences.properties
+++ b/browser/locales/en-US/chrome/browser/preferences/preferences.properties
@@ -7,16 +7,17 @@
 # LOCALIZATION NOTE: phishBefore uses %S to represent the name of the provider
 #                    whose privacy policy must be accepted (for enabling
 #                    check-every-page-as-I-load-it phishing protection).
 phishBeforeText=Selecting this option will send the address of web pages you are viewing to %S. To continue, please review and accept the following terms of service.
 
 #### Fonts
 
 labelDefaultFont=Default (%S)
+labelDefaultFontUnnamed=Default
 
 veryLargeMinimumFontTitle=Large minimum font size
 veryLargeMinimumFontWarning=You have selected a very large minimum font size (more than 24 pixels). This may make it difficult or impossible to use some important configuration pages like this one.
 acceptVeryLargeMinimumFont=Keep my changes anyway
 
 #### Permissions Manager
 
 trackingprotectionpermissionstext2=You have disabled Tracking Protection on these websites.
--- a/toolkit/mozapps/preferences/fontbuilder.js
+++ b/toolkit/mozapps/preferences/fontbuilder.js
@@ -34,27 +34,27 @@ var FontBuilder = {
 
     if (!this._allFonts)
       this._allFonts = await this.enumerator.EnumerateAllFontsAsync({});
 
     // Build the UI for the Default Font and Fonts for this CSS type.
     var popup = document.createElement("menupopup");
     var separator;
     if (fonts.length > 0) {
-      if (defaultFont) {
-        var bundlePreferences = document.getElementById("bundlePreferences");
-        var label = bundlePreferences.getFormattedString("labelDefaultFont", [defaultFont]);
-        var menuitem = document.createElement("menuitem");
-        menuitem.setAttribute("label", label);
-        menuitem.setAttribute("value", ""); // Default Font has a blank value
-        popup.appendChild(menuitem);
+      var bundlePreferences = document.getElementById("bundlePreferences");
+      var defaultLabel = defaultFont ?
+        bundlePreferences.getFormattedString("labelDefaultFont", [defaultFont]) :
+        bundlePreferences.getString("labelDefaultFontUnnamed");
+      var menuitem = document.createElement("menuitem");
+      menuitem.setAttribute("label", defaultLabel);
+      menuitem.setAttribute("value", ""); // Default Font has a blank value
+      popup.appendChild(menuitem);
 
-        separator = document.createElement("menuseparator");
-        popup.appendChild(separator);
-      }
+      separator = document.createElement("menuseparator");
+      popup.appendChild(separator);
 
       for (var i = 0; i < fonts.length; ++i) {
         menuitem = document.createElement("menuitem");
         menuitem.setAttribute("value", fonts[i]);
         menuitem.setAttribute("label", fonts[i]);
         popup.appendChild(menuitem);
       }
     }