Bug 1141055 - fix in-content 'Content' pane preference initialization so rebuildFonts *actually* doesn't break, r=jaws
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 16 Mar 2015 17:01:45 -0700
changeset 233860 f981a0bd0e1ca38963f46f69565f6c81e5eba580
parent 233859 00579267379bea466515586df49fa170a59ecc72
child 233861 cdf8e5b44c56fca7188b664ded8f7c41646f7ee5
push id28425
push usercbook@mozilla.com
push dateTue, 17 Mar 2015 10:33:06 +0000
treeherdermozilla-central@a194e8023090 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1141055
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1141055 - fix in-content 'Content' pane preference initialization so rebuildFonts *actually* doesn't break, r=jaws
browser/components/preferences/in-content/content.js
browser/components/preferences/in-content/tests/browser.ini
browser/components/preferences/in-content/tests/browser_basic_rebuild_fonts_test.js
--- a/browser/components/preferences/in-content/content.js
+++ b/browser/components/preferences/in-content/content.js
@@ -94,49 +94,50 @@ var gContentPane = {
 
   // FONTS
 
   /**
    * Populates the default font list in UI.
    */
   _rebuildFonts: function ()
   {
+    var preferences = document.getElementById("contentPreferences");
+    // Ensure preferences are "visible" to ensure bindings work.
+    preferences.hidden = false;
+    // Force flush:
+    preferences.clientHeight;
     var langGroupPref = document.getElementById("font.language.group");
     this._selectDefaultLanguageGroup(langGroupPref.value,
                                      this._readDefaultFontTypeForLanguage(langGroupPref.value) == "serif");
   },
 
   /**
    * 
    */
   _selectDefaultLanguageGroup: function (aLanguageGroup, aIsSerif)
   {
     const kFontNameFmtSerif         = "font.name.serif.%LANG%";
     const kFontNameFmtSansSerif     = "font.name.sans-serif.%LANG%";
     const kFontNameListFmtSerif     = "font.name-list.serif.%LANG%";
     const kFontNameListFmtSansSerif = "font.name-list.sans-serif.%LANG%";
     const kFontSizeFmtVariable      = "font.size.variable.%LANG%";
 
+    var preferences = document.getElementById("contentPreferences");
     var prefs = [{ format   : aIsSerif ? kFontNameFmtSerif : kFontNameFmtSansSerif,
                    type     : "fontname",
                    element  : "defaultFont",
                    fonttype : aIsSerif ? "serif" : "sans-serif" },
                  { format   : aIsSerif ? kFontNameListFmtSerif : kFontNameListFmtSansSerif,
                    type     : "unichar",
                    element  : null,
                    fonttype : aIsSerif ? "serif" : "sans-serif" },
                  { format   : kFontSizeFmtVariable,
                    type     : "int",
                    element  : "defaultFontSize",
                    fonttype : null }];
-    var preferences = document.getElementById("contentPreferences");
-    // Ensure preferences are "visible" to ensure bindings work.
-    preferences.hidden = false;
-    // Force flush:
-    preferences.clientHeight;
     for (var i = 0; i < prefs.length; ++i) {
       var preference = document.getElementById(prefs[i].format.replace(/%LANG%/, aLanguageGroup));
       if (!preference) {
         preference = document.createElement("preference");
         var name = prefs[i].format.replace(/%LANG%/, aLanguageGroup);
         preference.id = name;
         preference.setAttribute("name", name);
         preference.setAttribute("type", prefs[i].type);
--- a/browser/components/preferences/in-content/tests/browser.ini
+++ b/browser/components/preferences/in-content/tests/browser.ini
@@ -1,15 +1,16 @@
 [DEFAULT]
 skip-if = buildapp == "mulet"
 support-files =
   head.js
   privacypane_tests_perwindow.js
 
 [browser_advanced_update.js]
+[browser_basic_rebuild_fonts_test.js]
 [browser_bug410900.js]
 [browser_bug731866.js]
 [browser_bug795764_cachedisabled.js]
 [browser_bug1018066_resetScrollPosition.js]
 [browser_bug1020245_openPreferences_to_paneContent.js]
 [browser_change_app_handler.js]
 skip-if = os != "win" # This test tests the windows-specific app selection dialog, so can't run on non-Windows
 [browser_connection.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/preferences/in-content/tests/browser_basic_rebuild_fonts_test.js
@@ -0,0 +1,26 @@
+Services.prefs.setBoolPref("browser.preferences.inContent", true);
+Services.prefs.setBoolPref("browser.preferences.instantApply", true);
+
+registerCleanupFunction(function() {
+  Services.prefs.clearUserPref("browser.preferences.inContent");
+  Services.prefs.clearUserPref("browser.preferences.instantApply");
+});
+
+add_task(function() {
+  yield openPreferencesViaOpenPreferencesAPI("paneContent", null, {leaveOpen: true});
+  let doc = gBrowser.contentDocument;
+  var langGroup = Services.prefs.getComplexValue("font.language.group", Ci.nsIPrefLocalizedString).data
+  is(doc.getElementById("font.language.group").value, langGroup,
+     "Language group should be set correctly.");
+
+  let defaultFontType = Services.prefs.getCharPref("font.default." + langGroup);
+  let fontFamily = Services.prefs.getCharPref("font.name." + defaultFontType + "." + langGroup);
+  let fontFamilyField = doc.getElementById("defaultFont");
+  is(fontFamilyField.value, fontFamily, "Font family should be set correctly.");
+
+  let defaultFontSize = Services.prefs.getIntPref("font.size.variable." + langGroup);
+  let fontSizeField = doc.getElementById("defaultFontSize");
+  is(fontSizeField.value, defaultFontSize, "Font size should be set correctly.");
+
+  gBrowser.removeCurrentTab();
+});