Bug 1322719 - treat about:newtab like about:home in our UI when it's the default, r=dao a=lizzard
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 16 Dec 2016 17:44:52 +0000
changeset 353360 d2f676e88f05d5bb96d31a1fc5776be8e41c1c12
parent 353359 c8846e8964616760719182b10c35ad6192bf5649
child 353361 16e1a0ce86e4e4b8066793ae9a89ba2ab19ecd69
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao, lizzard
bugs1322719
milestone52.0a2
Bug 1322719 - treat about:newtab like about:home in our UI when it's the default, r=dao a=lizzard 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
@@ -5263,17 +5263,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.