Bug 1369875 - Turn off activity-stream.enabled for new tab related tests
MozReview-Commit-ID: Gx3itUrHICL
--- 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() {