Bug 1454344 - Setting New tabs to |Blank Page| does not become effective until the 2nd new tab. r=k88hudson
authorEd Lee <edilee@mozilla.com>
Tue, 24 Apr 2018 16:29:02 -0700
changeset 469231 733115bbb9b59a4d35232c3a792b7aa524bd7176
parent 469145 76f35d0ecaa690917347f2b0f97180b05e7272bb
child 469232 122be576bdc1c03e9c8fce0a709b74018873eb2c
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersk88hudson
bugs1454344
milestone61.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 1454344 - Setting New tabs to |Blank Page| does not become effective until the 2nd new tab. r=k88hudson MozReview-Commit-ID: GNbMgaLpB9n
browser/base/content/tabbrowser.js
browser/components/preferences/in-content/tests/browser.ini
browser/components/preferences/in-content/tests/browser_newtab_menu.js
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -1759,20 +1759,21 @@ window._gBrowser = {
       browser.setAttribute("preloadedState", "consumed");
       browser.setAttribute("autocompletepopup", "PopupAutoComplete");
     }
 
     return browser;
   },
 
   _isPreloadingEnabled() {
-    // Preloading for the newtab page is enabled when the pref is true
+    // Preloading for the newtab page is enabled when the prefs are true
     // and the URL is "about:newtab". We do not support preloading for
-    // custom newtab URLs.
+    // custom newtab URLs -- only for the default Firefox Home page.
     return Services.prefs.getBoolPref("browser.newtab.preload") &&
+      Services.prefs.getBoolPref("browser.newtabpage.enabled") &&
       !aboutNewTabService.overridden;
   },
 
   _createPreloadBrowser() {
     // Do nothing if we have a preloaded browser already
     // or preloading of newtab pages is disabled.
     if (this._preloadedBrowser || !this._isPreloadingEnabled()) {
       return;
--- a/browser/components/preferences/in-content/tests/browser.ini
+++ b/browser/components/preferences/in-content/tests/browser.ini
@@ -47,16 +47,17 @@ skip-if = os != "win" || (os == "win" &&
 [browser_defaultbrowser_alwayscheck.js]
 [browser_healthreport.js]
 skip-if = true || !healthreport # Bug 1185403 for the "true"
 [browser_homepages_filter_aboutpreferences.js]
 [browser_extension_controlled.js]
 [browser_languages_subdialog.js]
 [browser_layersacceleration.js]
 [browser_masterpassword.js]
+[browser_newtab_menu.js]
 [browser_notifications_do_not_disturb.js]
 [browser_password_management.js]
 [browser_performance.js]
 skip-if = !e10s
 [browser_performance_e10srollout.js]
 skip-if = !e10s
 [browser_performance_non_e10s.js]
 skip-if = e10s
new file mode 100644
--- /dev/null
+++ b/browser/components/preferences/in-content/tests/browser_newtab_menu.js
@@ -0,0 +1,25 @@
+add_task(async function newtabPreloaded() {
+  await openPreferencesViaOpenPreferencesAPI("paneHome", {leaveOpen: true});
+
+  const {contentDocument: doc, contentWindow} = gBrowser;
+  function dispatchMenuItemCommand(menuItem) {
+    const cmdEvent = doc.createEvent("xulcommandevent");
+    cmdEvent.initCommandEvent("command", true, true, contentWindow, 0, false, false, false, false, null, 0);
+    menuItem.dispatchEvent(cmdEvent);
+  }
+
+  const menuHome = doc.querySelector(`#newTabMode menuitem[value="0"]`);
+  const menuBlank = doc.querySelector(`#newTabMode menuitem[value="1"]`);
+  ok(menuHome.selected, "The first item, Home (default), is selected.");
+  ok(gBrowser._isPreloadingEnabled(), "Default Home allows preloading.");
+
+  dispatchMenuItemCommand(menuBlank);
+  ok(menuBlank.selected, "The second item, Blank, is selected.");
+  ok(!gBrowser._isPreloadingEnabled(), "Non-Home prevents preloading.");
+
+  dispatchMenuItemCommand(menuHome);
+  ok(menuHome.selected, "The first item, Home, is selected again.");
+  ok(gBrowser._isPreloadingEnabled(), "Default Home allows preloading again.");
+
+  BrowserTestUtils.removeTab(gBrowser.selectedTab);
+});