Bug 1322719 - treat about:newtab like about:home in our UI when it's the default, r?dao draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 16 Dec 2016 17:44:52 +0000
changeset 450469 86f97bdbfe2704a483254338f1a92f13ffd8279b
parent 449801 7652a58efa46f1c57c94bba26efc5d53b6184e83
child 539758 bc081e5893c54e8a9a7b97c01cc70b7b7f0cccc5
push id38863
push usergijskruitbosch@gmail.com
push dateFri, 16 Dec 2016 17:46:06 +0000
reviewersdao
bugs1322719
milestone53.0a1
Bug 1322719 - treat about:newtab like about:home in our UI when it's the default, r?dao MozReview-Commit-ID: DFn7ZZF2dXw
browser/base/content/browser.js
browser/components/preferences/in-content/main.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -5302,17 +5302,17 @@ var gHomeButton = {
 
   updateTooltip: function(homeButton)
   {
     if (!homeButton)
       homeButton = document.getElementById("home-button");
     if (homeButton) {
       var homePage = this.getHomePage();
       homePage = homePage.replace(/\|/g, ', ');
-      if (homePage.toLowerCase() == "about:home")
+      if (["about:home", "about:newtab"].includes(homePage.toLowerCase()))
         homeButton.setAttribute("tooltiptext", homeButton.getAttribute("aboutHomeOverrideTooltip"));
       else
         homeButton.setAttribute("tooltiptext", homePage);
     }
   },
 
   getHomePage: function()
   {
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -240,20 +240,27 @@ var gMainPane = {
    *   selected and doesn't change the UI for this preference, the deprecated
    *   option is preserved.
    */
 
   syncFromHomePref: function()
   {
     let homePref = document.getElementById("browser.startup.homepage");
 
-    // If the pref is set to about:home, set the value to "" to show the
-    // placeholder text (about:home title).
-    if (homePref.value.toLowerCase() == "about:home")
+    // If the pref is set to about:home or about:newtab, set the value to ""
+    // to show the placeholder text (about:home title) rather than
+    // exposing those URLs to users.
+    let defaultBranch = Services.prefs.getDefaultBranch("");
+    let defaultValue = defaultBranch.getComplexValue("browser.startup.homepage",
+                                                     Ci.nsIPrefLocalizedString).data;
+    let currentValue = homePref.value.toLowerCase();
+    if (currentValue == "about:home" ||
+        (currentValue == defaultValue && currentValue == "about:newtab")) {
       return "";
+    }
 
     // If the pref is actually "", show about:blank.  The actual home page
     // loading code treats them the same, and we don't want the placeholder text
     // to be shown.
     if (homePref.value == "")
       return "about:blank";
 
     // Otherwise, show the actual pref value.