Bug 1369875 - Turn off activity-stream.enabled for new tab related tests r=Mardak
authork88hudson <khudson@mozilla.com>
Fri, 02 Jun 2017 16:33:18 -0400
changeset 362760 76d4bd75e8e2
parent 362759 447882512ee8
child 362761 bc64157bced9
push id31988
push usercbook@mozilla.com
push dateThu, 08 Jun 2017 12:43:02 +0000
treeherdermozilla-central@f223e1fd2044 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMardak
bugs1369875
milestone55.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 1369875 - Turn off activity-stream.enabled for new tab related tests r=Mardak MozReview-Commit-ID: Gx3itUrHICL
browser/base/content/test/newtab/head.js
browser/components/newtab/tests/browser/browser_newtab_overrides.js
--- a/browser/base/content/test/newtab/head.js
+++ b/browser/base/content/test/newtab/head.js
@@ -1,15 +1,24 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const PREF_NEWTAB_ENABLED = "browser.newtabpage.enabled";
 const PREF_NEWTAB_DIRECTORYSOURCE = "browser.newtabpage.directory.source";
+const PREF_NEWTAB_ACTIVITY_STREAM = "browser.newtabpage.activity-stream.enabled";
 
 Services.prefs.setBoolPref(PREF_NEWTAB_ENABLED, true);
+Services.prefs.setBoolPref(PREF_NEWTAB_ACTIVITY_STREAM, false);
+
+// Opens and closes a new tab to clear any existing preloaded ones. This is
+// necessary to prevent any left-over activity-stream preloaded new tabs from
+// affecting these tests.
+BrowserOpenTab();
+const initialTab = gBrowser.selectedTab;
+gBrowser.removeTab(initialTab);
 
 var tmp = {};
 Cu.import("resource://gre/modules/NewTabUtils.jsm", tmp);
 Cu.import("resource:///modules/DirectoryLinksProvider.jsm", tmp);
 Cu.import("resource://testing-common/PlacesTestUtils.jsm", tmp);
 Cc["@mozilla.org/moz/jssubscript-loader;1"]
   .getService(Ci.mozIJSSubScriptLoader)
   .loadSubScript("chrome://browser/content/sanitize.js", tmp);
@@ -73,16 +82,17 @@ registerCleanupFunction(function() {
 
   Object.keys(oldSize).forEach(prop => {
     if (oldSize[prop]) {
       gBrowser.contentWindow[prop] = oldSize[prop];
     }
   });
 
   Services.prefs.clearUserPref(PREF_NEWTAB_ENABLED);
+  Services.prefs.clearUserPref(PREF_NEWTAB_ACTIVITY_STREAM);
   Services.prefs.setCharPref(PREF_NEWTAB_DIRECTORYSOURCE, gOrigDirectorySource);
 
   return watchLinksChangeOnce();
 });
 
 function pushPrefs(...aPrefs) {
   return SpecialPowers.pushPrefEnv({"set": aPrefs});
 }
--- a/browser/components/newtab/tests/browser/browser_newtab_overrides.js
+++ b/browser/components/newtab/tests/browser/browser_newtab_overrides.js
@@ -1,21 +1,24 @@
 "use strict";
 
 let Cu = Components.utils;
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/Preferences.jsm");
+const PREF_NEWTAB_ACTIVITY_STREAM = "browser.newtabpage.activity-stream.enabled";
+
+Services.prefs.setBoolPref(PREF_NEWTAB_ACTIVITY_STREAM, false);
 
 XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService",
                                    "@mozilla.org/browser/aboutnewtab-service;1",
                                    "nsIAboutNewTabService");
 
 registerCleanupFunction(function() {
-  Services.prefs.setBoolPref("browser.newtabpage.activity-stream.enabled", false);
+  Services.prefs.clearUserPref(PREF_NEWTAB_ACTIVITY_STREAM);
   aboutNewTabService.resetNewTabURL();
 });
 
 /*
  * Tests that the default newtab page is always returned when one types "about:newtab" in the URL bar,
  * even when overridden.
  */
 add_task(async function redirector_ignores_override() {