Bug 1322719 - treat about:newtab like about:home in our UI when it's the default, r=dao
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 16 Dec 2016 17:44:52 +0000
changeset 450773 bd570e5a9b4546a15546d09e507d0769434a4163
parent 450772 03090e5ca9b989f6b3823412425b9e0f50ef6ef6
child 450774 19b8210a8cce07f6af71de8bd53731169a99f561
push id38944
push userbmo:leftysolara@gmail.com
push dateSun, 18 Dec 2016 16:01:15 +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.