Bug 1399696 - aboutNewTabService should initialize with the correct _activityStreamPrerender value draft bug1399696
authork88hudson <khudson@mozilla.com>
Fri, 15 Sep 2017 10:33:15 -0400
changeset 665476 fac6c24fc7748c28b76aae405621f169cc1a0b61
parent 665390 893fe1549e1e7342a66514b65960f08d40810a34
child 731796 ffbfa9a863189d47128deef628d675b6244a44dc
push id80076
push userkhudson@mozilla.com
push dateFri, 15 Sep 2017 14:45:46 +0000
bugs1399696
milestone57.0a1
Bug 1399696 - aboutNewTabService should initialize with the correct _activityStreamPrerender value MozReview-Commit-ID: BrLNwO74S5q
browser/components/newtab/aboutNewTabService.js
browser/components/newtab/tests/xpcshell/test_AboutNewTabService.js
--- a/browser/components/newtab/aboutNewTabService.js
+++ b/browser/components/newtab/aboutNewTabService.js
@@ -70,17 +70,17 @@ function AboutNewTabService() {
  * Loading a chrome resource, or an about: URL in the redirector with either the
  * LOAD_NORMAL or LOAD_REPLACE flags yield unexpected behaviors, so a roundtrip
  * to the redirector from browser chrome is avoided.
  */
 AboutNewTabService.prototype = {
 
   _newTabURL: ABOUT_URL,
   _activityStreamEnabled: false,
-  _activityStreamPrerender: true,
+  _activityStreamPrerender: false,
   _overridden: false,
 
   classID: Components.ID("{dfcd2adc-7867-4d3a-ba70-17501f208142}"),
   QueryInterface: XPCOMUtils.generateQI([
     Ci.nsIAboutNewTabService,
     Ci.nsIObserver
   ]),
   _xpcom_categories: [{
@@ -131,16 +131,17 @@ AboutNewTabService.prototype = {
       // exit there is no change of state
       return false;
     }
     if (stateEnabled) {
       this._activityStreamEnabled = true;
     } else {
       this._activityStreamEnabled = false;
     }
+    this._activityStreamPrerender = Services.prefs.getBoolPref(PREF_ACTIVITY_STREAM_PRERENDER_ENABLED);
     this._newtabURL = ABOUT_URL;
     return true;
   },
 
   /*
    * Returns the default URL.
    *
    * This URL only depends on the browser.newtabpage.activity-stream.enabled pref. Overriding
--- a/browser/components/newtab/tests/xpcshell/test_AboutNewTabService.js
+++ b/browser/components/newtab/tests/xpcshell/test_AboutNewTabService.js
@@ -22,16 +22,24 @@ const ACTIVITY_STREAM_PRERENDER_PREF = "
 function cleanup() {
   Services.prefs.clearUserPref(ACTIVITY_STREAM_PREF);
   Services.prefs.clearUserPref(ACTIVITY_STREAM_PRERENDER_PREF);
   aboutNewTabService.resetNewTabURL();
 }
 
 do_register_cleanup(cleanup);
 
+add_task(async function test_as_and_prerender_initialized() {
+  Assert.equal(aboutNewTabService.activityStreamEnabled, Services.prefs.getBoolPref(ACTIVITY_STREAM_PREF),
+    ".activityStreamEnabled should be set to the correct initial value");
+  Assert.equal(aboutNewTabService.activityStreamPrerender, Services.prefs.getBoolPref(ACTIVITY_STREAM_PRERENDER_PREF),
+    ".activityStreamPrerender should be set to the correct initial value");
+  Services.prefs.getBoolPref(ACTIVITY_STREAM_PREF);
+});
+
 /**
  * Test the overriding of the default URL
  */
 add_task(async function test_override_activity_stream_disabled() {
   let notificationPromise;
   Services.prefs.setBoolPref(ACTIVITY_STREAM_PREF, false);
 
   // tests default is the local newtab resource