forked from mirrors/gecko-dev
Bug 1612984 - Enable regions that get stories via a pref r=gvn
Differential Revision: https://phabricator.services.mozilla.com/D61510 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
05c4d91a51
commit
8dc9ea96b7
4 changed files with 66 additions and 21 deletions
|
|
@ -1306,6 +1306,8 @@ pref("browser.newtabpage.activity-stream.discoverystream.hardcoded-basic-layout"
|
|||
pref("browser.newtabpage.activity-stream.discoverystream.spocs-endpoint", "");
|
||||
// List of langs that get the 7 row layout.
|
||||
pref("browser.newtabpage.activity-stream.discoverystream.lang-layout-config", "en");
|
||||
// List of regions that get stories by default.
|
||||
pref("browser.newtabpage.activity-stream.discoverystream.region-stories-config", "US,DE,CA");
|
||||
// Switch between different versions of the recommendation provider.
|
||||
pref("browser.newtabpage.activity-stream.discoverystream.personalization.version", 1);
|
||||
// Configurable keys used by personalization version 2.
|
||||
|
|
|
|||
|
|
@ -177,6 +177,14 @@ Programmatically generated hash table where the keys are recommendation IDs and
|
|||
|
||||
Programmatically generated hash table where the keys are sponsored content IDs and the values are arrays of timestamps for every impression.
|
||||
|
||||
#### `browser.newtabpage.activity-stream.discoverystream.region-stories-config`
|
||||
|
||||
- Type: `string`
|
||||
- Default: `US,DE,CA`
|
||||
- Pref Type: Firefox
|
||||
|
||||
A comma separated list of geos that by default have stories enabled in newtab. It matches the client's geo with that list, then looks for a matching locale.
|
||||
|
||||
#### `browser.newtabpage.activity-stream.discoverystream.spocs-endpoint`
|
||||
|
||||
- Type: `string`
|
||||
|
|
|
|||
|
|
@ -133,6 +133,8 @@ const DEFAULT_SITES = new Map([
|
|||
],
|
||||
]);
|
||||
const GEO_PREF = "browser.search.region";
|
||||
const REGION_STORIES_CONFIG =
|
||||
"browser.newtabpage.activity-stream.discoverystream.region-stories-config";
|
||||
const SPOCS_GEOS = ["US"];
|
||||
|
||||
// Determine if spocs should be shown for a geo/locale
|
||||
|
|
@ -576,12 +578,19 @@ const FEEDS_DATA = [
|
|||
"Fetches content recommendations from a configurable content provider",
|
||||
// Dynamically determine if Pocket should be shown for a geo / locale
|
||||
getValue: ({ geo, locale }) => {
|
||||
const preffedRegionsString =
|
||||
Services.prefs.getStringPref(REGION_STORIES_CONFIG) || "";
|
||||
const preffedRegions = preffedRegionsString.split(",").map(s => s.trim());
|
||||
const locales = {
|
||||
US: ["en-CA", "en-GB", "en-US", "en-ZA"],
|
||||
CA: ["en-CA", "en-GB", "en-US", "en-ZA"],
|
||||
GB: ["en-CA", "en-GB", "en-US", "en-ZA"],
|
||||
DE: ["de", "de-DE", "de-AT", "de-CH"],
|
||||
JP: ["ja", "ja-JP"],
|
||||
}[geo];
|
||||
return !!locales && locales.includes(locale);
|
||||
return (
|
||||
preffedRegions.includes(geo) && !!locales && locales.includes(locale)
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -248,58 +248,84 @@ describe("ActivityStream", () => {
|
|||
});
|
||||
});
|
||||
describe("_updateDynamicPrefs topstories default value", () => {
|
||||
let getStringPrefStub;
|
||||
let appLocaleAsBCP47Stub;
|
||||
let prefHasUserValueStub;
|
||||
beforeEach(() => {
|
||||
prefHasUserValueStub = sandbox.stub(
|
||||
global.Services.prefs,
|
||||
"prefHasUserValue"
|
||||
);
|
||||
getStringPrefStub = sandbox.stub(global.Services.prefs, "getStringPref");
|
||||
appLocaleAsBCP47Stub = sandbox.stub(
|
||||
global.Services.locale,
|
||||
"appLocaleAsBCP47"
|
||||
);
|
||||
|
||||
prefHasUserValueStub.returns(true);
|
||||
appLocaleAsBCP47Stub.get(() => "en-US");
|
||||
|
||||
getStringPrefStub.withArgs("browser.search.region").returns("US");
|
||||
|
||||
getStringPrefStub
|
||||
.withArgs(
|
||||
"browser.newtabpage.activity-stream.discoverystream.region-stories-config"
|
||||
)
|
||||
.returns("US,CA");
|
||||
});
|
||||
it("should be false with no geo/locale", () => {
|
||||
prefHasUserValueStub.returns(false);
|
||||
appLocaleAsBCP47Stub.get(() => "");
|
||||
getStringPrefStub.withArgs("browser.search.region").returns("");
|
||||
|
||||
as._updateDynamicPrefs();
|
||||
|
||||
assert.isFalse(PREFS_CONFIG.get("feeds.section.topstories").value);
|
||||
});
|
||||
it("should be false with unexpected geo", () => {
|
||||
sandbox.stub(global.Services.prefs, "prefHasUserValue").returns(true);
|
||||
sandbox.stub(global.Services.prefs, "getStringPref").returns("NOGEO");
|
||||
getStringPrefStub.withArgs("browser.search.region").returns("NOGEO");
|
||||
|
||||
as._updateDynamicPrefs();
|
||||
|
||||
assert.isFalse(PREFS_CONFIG.get("feeds.section.topstories").value);
|
||||
});
|
||||
it("should be false with expected geo and unexpected locale", () => {
|
||||
sandbox.stub(global.Services.prefs, "prefHasUserValue").returns(true);
|
||||
sandbox.stub(global.Services.prefs, "getStringPref").returns("US");
|
||||
sandbox
|
||||
.stub(global.Services.locale, "appLocaleAsBCP47")
|
||||
.get(() => "no-LOCALE");
|
||||
appLocaleAsBCP47Stub.get(() => "no-LOCALE");
|
||||
|
||||
as._updateDynamicPrefs();
|
||||
|
||||
assert.isFalse(PREFS_CONFIG.get("feeds.section.topstories").value);
|
||||
});
|
||||
it("should be true with expected geo and locale", () => {
|
||||
sandbox.stub(global.Services.prefs, "prefHasUserValue").returns(true);
|
||||
sandbox.stub(global.Services.prefs, "getStringPref").returns("US");
|
||||
sandbox
|
||||
.stub(global.Services.locale, "appLocaleAsBCP47")
|
||||
.get(() => "en-US");
|
||||
|
||||
as._updateDynamicPrefs();
|
||||
|
||||
assert.isTrue(PREFS_CONFIG.get("feeds.section.topstories").value);
|
||||
});
|
||||
it("should be false after expected geo and locale then unexpected", () => {
|
||||
sandbox.stub(global.Services.prefs, "prefHasUserValue").returns(true);
|
||||
sandbox
|
||||
.stub(global.Services.prefs, "getStringPref")
|
||||
getStringPrefStub
|
||||
.withArgs("browser.search.region")
|
||||
.onFirstCall()
|
||||
.returns("US")
|
||||
.onSecondCall()
|
||||
.returns("NOGEO");
|
||||
sandbox
|
||||
.stub(global.Services.locale, "appLocaleAsBCP47")
|
||||
.get(() => "en-US");
|
||||
|
||||
as._updateDynamicPrefs();
|
||||
as._updateDynamicPrefs();
|
||||
|
||||
assert.isFalse(PREFS_CONFIG.get("feeds.section.topstories").value);
|
||||
});
|
||||
it("should be true with updated pref change", () => {
|
||||
appLocaleAsBCP47Stub.get(() => "en-GB");
|
||||
getStringPrefStub.withArgs("browser.search.region").returns("GB");
|
||||
getStringPrefStub
|
||||
.withArgs(
|
||||
"browser.newtabpage.activity-stream.discoverystream.region-stories-config"
|
||||
)
|
||||
.returns("US,CA,GB");
|
||||
|
||||
as._updateDynamicPrefs();
|
||||
|
||||
assert.isTrue(PREFS_CONFIG.get("feeds.section.topstories").value);
|
||||
});
|
||||
});
|
||||
describe("_updateDynamicPrefs topstories delayed default value", () => {
|
||||
let clock;
|
||||
|
|
|
|||
Loading…
Reference in a new issue