Bug 1093101 - Use user-set browser.newtab.url pref for new tabs in private windows. r=dao
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Tue, 13 Jan 2015 06:41:15 +0200
changeset 223482 c2b8d06dcffc1e7bd906f48ed10883b640358585
parent 223481 11aebde6e809d32c6b37e23de66fe9e674f5490c
child 223483 7e143e1f08526ce35fd44c0149fb95c597a5384f
push id28095
push usercbook@mozilla.com
push dateTue, 13 Jan 2015 13:24:48 +0000
treeherdermozilla-central@a5700bec72e1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1093101
milestone38.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 1093101 - Use user-set browser.newtab.url pref for new tabs in private windows. r=dao
browser/base/content/browser.js
browser/base/content/test/general/browser_bug767836_perwindowpb.js
browser/base/content/utilityOverlay.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1090,19 +1090,16 @@ var gBrowserInit = {
     // will be fired.
     gBrowser.addEventListener("MozApplicationManifest",
                               OfflineApps, false);
     // listen for offline apps on social
     let socialBrowser = document.getElementById("social-sidebar-browser");
     socialBrowser.addEventListener("MozApplicationManifest",
                               OfflineApps, false);
 
-    let uriToLoad = this._getUriToLoad();
-    var isLoadingBlank = isBlankPageURL(uriToLoad);
-
     // This pageshow listener needs to be registered before we may call
     // swapBrowsersAndCloseOther() to receive pageshow events fired by that.
     let mm = window.messageManager;
     mm.addMessageListener("PageVisibility:Show", function(message) {
       if (message.target == gBrowser.selectedBrowser) {
         setTimeout(pageShowEventHandlers, 0, message.data.persisted);
       }
     });
@@ -1130,16 +1127,17 @@ var gBrowserInit = {
       if (event.detail.sendCrashReport) {
         TabCrashReporter.submitCrashReport(browser);
       }
 #endif
       let tab = gBrowser.getTabForBrowser(browser);
       SessionStore.reviveCrashedTab(tab);
     }, false, true);
 
+    let uriToLoad = this._getUriToLoad();
     if (uriToLoad && uriToLoad != "about:blank") {
       if (uriToLoad instanceof Ci.nsISupportsArray) {
         let count = uriToLoad.Count();
         let specs = [];
         for (let i = 0; i < count; i++) {
           let urisstring = uriToLoad.GetElementAt(i).QueryInterface(Ci.nsISupportsString);
           specs.push(urisstring.data);
         }
@@ -1214,18 +1212,20 @@ var gBrowserInit = {
     if (mustLoadSidebar) {
       let sidebar = document.getElementById("sidebar");
       let sidebarBox = document.getElementById("sidebar-box");
       sidebar.setAttribute("src", sidebarBox.getAttribute("src"));
     }
 
     UpdateUrlbarSearchSplitterState();
 
-    if (!isLoadingBlank || !focusAndSelectUrlBar())
+    if (!(isBlankPageURL(uriToLoad) || uriToLoad == "about:privatebrowsing") ||
+        !focusAndSelectUrlBar()) {
       gBrowser.selectedBrowser.focus();
+    }
 
     // Set up Sanitize Item
     this._initializeSanitizer();
 
     // Enable/Disable auto-hide tabbar
     gBrowser.tabContainer.updateVisibility();
 
     BookmarkingUI.init();
--- a/browser/base/content/test/general/browser_bug767836_perwindowpb.js
+++ b/browser/base/content/test/general/browser_bug767836_perwindowpb.js
@@ -24,23 +24,18 @@ function test() {
       is(aWindow.gBrowser.selectedBrowser.currentURI.spec, newTabURL,
         "URL of NewTab should be " + newTabURL + " in " + mode +  " mode");
       // Set the custom newtab url
       Services.prefs.setCharPref(newTabPrefName, testURL);
       ok(Services.prefs.prefHasUserValue(newTabPrefName), "Custom newtab url is set");
 
       // Open a newtab after setting the custom newtab url
       openNewTab(aWindow, function () {
-        if (aIsPrivateMode) {
-          is(aWindow.gBrowser.selectedBrowser.currentURI.spec, newTabURL,
-             "URL of NewTab should always be " + newTabURL + " in " + mode +  " mode");
-        } else {
-          is(aWindow.gBrowser.selectedBrowser.currentURI.spec, testURL,
-             "URL of NewTab should be the custom url");
-        }
+        is(aWindow.gBrowser.selectedBrowser.currentURI.spec, testURL,
+           "URL of NewTab should be the custom url");
 
         // clear the custom url preference
         Services.prefs.clearUserPref(newTabPrefName);
         ok(!Services.prefs.prefHasUserValue(newTabPrefName), "No custom newtab url is set");
 
         aWindow.gBrowser.removeTab(aWindow.gBrowser.selectedTab);
         aWindow.gBrowser.removeTab(aWindow.gBrowser.selectedTab);
         aWindow.close();
--- a/browser/base/content/utilityOverlay.js
+++ b/browser/base/content/utilityOverlay.js
@@ -9,17 +9,18 @@ Components.utils.import("resource://gre/
 Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
 Components.utils.import("resource:///modules/RecentWindow.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "BROWSER_NEW_TAB_URL", function () {
   const PREF = "browser.newtab.url";
 
   function getNewTabPageURL() {
     if (PrivateBrowsingUtils.isWindowPrivate(window) &&
-        !PrivateBrowsingUtils.permanentPrivateBrowsing) {
+        !PrivateBrowsingUtils.permanentPrivateBrowsing &&
+        !Services.prefs.prefHasUserValue(PREF)) {
       return "about:privatebrowsing";
     }
 
     let url = Services.prefs.getComplexValue(PREF, Ci.nsISupportsString).data;
     return url || "about:blank";
   }
 
   function update() {