Skip to content

Commit e518714

Browse files
committed
Bug 1996347 - Newtab move feature gate for tests and automation into activitystream r=whimboo,home-newtab-reviewers,nbarrett
Differential Revision: https://phabricator.services.mozilla.com/D271335
1 parent 6f28d4a commit e518714

File tree

11 files changed

+42
-71
lines changed

11 files changed

+42
-71
lines changed

browser/extensions/newtab/content-src/components/Weather/Weather.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ export class _Weather extends React.PureComponent {
245245

246246
isEnabled() {
247247
const { values } = this.props.Prefs;
248-
const systemValue = values[PREF_SYSTEM_SHOW_WEATHER];
248+
const systemValue =
249+
values[PREF_SYSTEM_SHOW_WEATHER] && values["feeds.weatherfeed"];
249250
const experimentValue = values.trainhopConfig?.weather?.enabled;
250251
return systemValue || experimentValue;
251252
}

browser/extensions/newtab/data/content/activity-stream.bundle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11396,7 +11396,7 @@ class _Weather extends (external_React_default()).PureComponent {
1139611396
const {
1139711397
values
1139811398
} = this.props.Prefs;
11399-
const systemValue = values[PREF_SYSTEM_SHOW_WEATHER];
11399+
const systemValue = values[PREF_SYSTEM_SHOW_WEATHER] && values["feeds.weatherfeed"];
1140011400
const experimentValue = values.trainhopConfig?.weather?.enabled;
1140111401
return systemValue || experimentValue;
1140211402
}

browser/extensions/newtab/lib/ActivityStream.sys.mjs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ const LOCALE_SECTIONS_CONFIG =
9595
"browser.newtabpage.activity-stream.discoverystream.sections.locale-content-config";
9696

9797
const BROWSER_URLBAR_PLACEHOLDERNAME = "browser.urlbar.placeholderName";
98+
const PREF_SHOULD_AS_INITIALIZE_FEEDS =
99+
"browser.newtabpage.activity-stream.testing.shouldInitializeFeeds";
98100

99101
export const WEATHER_OPTIN_REGIONS = [
100102
"AT", // Austria
@@ -145,6 +147,17 @@ export function csvPrefHasValue(stringPrefName, value) {
145147
return prefValues.includes(value);
146148
}
147149

150+
export function shouldInitializeFeeds(defaultValue = true) {
151+
// For tests/automation: when false, newtab won't initialize
152+
// select feeds in this session.
153+
// Flipping after initialization has no effect on the current session.
154+
const shouldInitialize = Services.prefs.getBoolPref(
155+
PREF_SHOULD_AS_INITIALIZE_FEEDS,
156+
defaultValue
157+
);
158+
return shouldInitialize;
159+
}
160+
148161
function useInferredPersonalization({ geo, locale }) {
149162
return (
150163
csvPrefHasValue(REGION_INFERRED_PERSONALIZATION_CONFIG, geo) &&
@@ -1566,6 +1579,7 @@ const FEEDS_DATA = [
15661579
];
15671580

15681581
const FEEDS_CONFIG = new Map();
1582+
15691583
for (const config of FEEDS_DATA) {
15701584
const pref = `feeds.${config.name}`;
15711585
FEEDS_CONFIG.set(pref, config.factory);
@@ -1579,10 +1593,24 @@ export class ActivityStream {
15791593
constructor() {
15801594
this.initialized = false;
15811595
this.store = new lazy.Store();
1582-
this.feeds = FEEDS_CONFIG;
15831596
this._defaultPrefs = new lazy.DefaultPrefs(PREFS_CONFIG);
15841597
}
15851598

1599+
get feeds() {
1600+
if (shouldInitializeFeeds()) {
1601+
return FEEDS_CONFIG;
1602+
}
1603+
1604+
// We currently make excpetions for topsites, and prefs feeds
1605+
// because they currently impacts tests timing for places initialization.
1606+
// See bug 1999166.
1607+
const feeds = new Map([
1608+
["feeds.system.topsites", FEEDS_CONFIG.get("feeds.system.topsites")],
1609+
["feeds.prefs", FEEDS_CONFIG.get("feeds.prefs")],
1610+
]);
1611+
return feeds;
1612+
}
1613+
15861614
init() {
15871615
this._updateDynamicPrefs();
15881616
this._defaultPrefs.init();

browser/extensions/newtab/test/unit/content-src/components/Weather.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const mockState = {
4040
...INITIAL_STATE.Prefs.values,
4141
[PREF_SYS_SHOW_WEATHER]: true,
4242
[PREF_SYS_SHOW_WEATHER_OPT_IN]: false,
43+
"feeds.weatherfeed": true,
4344
},
4445
},
4546
Weather: { ...weatherInit },

browser/extensions/newtab/test/unit/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ export class FakensIPrefBranch {
118118
setBoolPref(prefName, value) {
119119
this.set(prefName, value);
120120
}
121-
getBoolPref(prefName) {
122-
return this.get(prefName);
121+
getBoolPref(prefName, defaultValue) {
122+
return this.get(prefName, defaultValue);
123123
}
124124
setIntPref(prefName, value) {
125125
this.set(prefName, value);

browser/modules/AboutNewTab.sys.mjs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const PREF_ACTIVITY_STREAM_DEBUG = "browser.newtabpage.activity-stream.debug";
2121
// AboutHomeStartupCache needs us in "quit-application", so stay alive longer.
2222
// TODO: We could better have a shared async shutdown blocker?
2323
const TOPIC_APP_QUIT = "profile-before-change";
24-
const PREF_SHOULD_INITIALIZE = "browser.newtabpage.shouldInitialize";
2524

2625
export const AboutNewTab = {
2726
QueryInterface: ChromeUtils.generateQI([
@@ -51,16 +50,6 @@ export const AboutNewTab = {
5150
return;
5251
}
5352

54-
// For tests/automation: when false, newtab won't initialize in this session.
55-
// Flipping after initialization has no effect on the current session.
56-
const shouldInitialize = Services.prefs.getBoolPref(
57-
PREF_SHOULD_INITIALIZE,
58-
true
59-
);
60-
if (!shouldInitialize) {
61-
return;
62-
}
63-
6453
Services.obs.addObserver(this, TOPIC_APP_QUIT);
6554
if (!AppConstants.RELEASE_OR_BETA) {
6655
XPCOMUtils.defineLazyPreferenceGetter(

browser/modules/test/browser/browser.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ https_first_disabled = true
7777
["browser_UsageTelemetry_uniqueOriginsVisitedInPast24Hours.js"]
7878
https_first_disabled = true
7979

80-
["browser_aboutnewtab_init_gate.js"]
81-
8280
["browser_preloading_tab_moving.js"]
8381

8482
["browser_taskbar_preview.js"]

browser/modules/test/browser/browser_aboutnewtab_init_gate.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

remote/shared/RecommendedPreferences.sys.mjs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,12 @@ const COMMON_PREFERENCES = new Map([
128128
// Disable CFR features for automated tests.
129129
["browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features", false],
130130

131-
// Make sure newtab weather doesn't hit the network to retrieve weather data.
132-
[
133-
"browser.newtabpage.activity-stream.discoverystream.region-weather-config",
134-
"",
135-
],
136-
137-
// Make sure newtab wallpapers don't hit the network to retrieve wallpaper data.
138-
["browser.newtabpage.activity-stream.newtabWallpapers.enabled", false],
131+
// Do not initialize any activitystream features
132+
["browser.newtabpage.activity-stream.testing.shouldInitializeFeeds", false],
139133

140134
// Make sure Topsites doesn't hit the network to retrieve sponsored tiles.
141135
["browser.newtabpage.activity-stream.showSponsoredTopSites", false],
142136

143-
// Always display a blank page
144-
["browser.newtabpage.enabled", false],
145-
146137
// Background thumbnails in particular cause grief, and disabling
147138
// thumbnails in general cannot hurt
148139
["browser.pagethumbnails.capturing_disabled", true],

testing/marionette/client/marionette_driver/geckoinstance.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ class GeckoInstance:
5050
"browser.http.blank_page_with_error_response.enabled": True,
5151
# Disable CFR features for automated tests.
5252
"browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features": False,
53-
# Don't pull weather data from the network
54-
"browser.newtabpage.activity-stream.discoverystream.region-weather-config": "",
55-
# Don't pull wallpaper content from the network
56-
"browser.newtabpage.activity-stream.newtabWallpapers.enabled": False,
57-
# Remove once Firefox 140 is no longer supported (see bug 1902921)
58-
"browser.newtabpage.activity-stream.newtabWallpapers.v2.enabled": False,
5953
# Don't pull sponsored Top Sites content from the network
6054
"browser.newtabpage.activity-stream.showSponsoredTopSites": False,
6155
# Disable geolocation ping (#1)
@@ -646,10 +640,8 @@ class DesktopInstance(GeckoInstance):
646640
"browser.EULA.override": True,
647641
# Disable all machine learning features by default
648642
"browser.ml.enable": False,
649-
# Disable Activity Stream telemetry pings
650-
"browser.newtabpage.activity-stream.telemetry": False,
651-
# Always display a blank page
652-
"browser.newtabpage.enabled": False,
643+
# Do not initialize any activitystream features
644+
"browser.newtabpage.activity-stream.testing.shouldInitializeFeeds": False,
653645
# Background thumbnails in particular cause grief, and disabling thumbnails
654646
# in general can"t hurt - we re-enable them when tests need them
655647
"browser.pagethumbnails.capturing_disabled": True,

0 commit comments

Comments
 (0)