Bug 1399696 - aboutNewTabService should initialize with the correct _activityStreamPrerender value r=Mardak
authork88hudson <khudson@mozilla.com>
Fri, 15 Sep 2017 10:33:15 -0400
changeset 665691 2ad95439eef6adad6aff5f0c72af709d304921ce
parent 665690 20d129c15a9990da780859ca97fff236a1052e05
child 665692 3cb1ce131f7cab332f036cecd59e5d104c981fa8
push id80148
push userbmo:emilio@crisal.io
push dateFri, 15 Sep 2017 20:59:22 +0000
reviewersMardak
bugs1399696
milestone57.0a1
Bug 1399696 - aboutNewTabService should initialize with the correct _activityStreamPrerender value r=Mardak 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