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", "");
|
pref("browser.newtabpage.activity-stream.discoverystream.spocs-endpoint", "");
|
||||||
// List of langs that get the 7 row layout.
|
// List of langs that get the 7 row layout.
|
||||||
pref("browser.newtabpage.activity-stream.discoverystream.lang-layout-config", "en");
|
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.
|
// Switch between different versions of the recommendation provider.
|
||||||
pref("browser.newtabpage.activity-stream.discoverystream.personalization.version", 1);
|
pref("browser.newtabpage.activity-stream.discoverystream.personalization.version", 1);
|
||||||
// Configurable keys used by personalization version 2.
|
// 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.
|
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`
|
#### `browser.newtabpage.activity-stream.discoverystream.spocs-endpoint`
|
||||||
|
|
||||||
- Type: `string`
|
- Type: `string`
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,8 @@ const DEFAULT_SITES = new Map([
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
const GEO_PREF = "browser.search.region";
|
const GEO_PREF = "browser.search.region";
|
||||||
|
const REGION_STORIES_CONFIG =
|
||||||
|
"browser.newtabpage.activity-stream.discoverystream.region-stories-config";
|
||||||
const SPOCS_GEOS = ["US"];
|
const SPOCS_GEOS = ["US"];
|
||||||
|
|
||||||
// Determine if spocs should be shown for a geo/locale
|
// 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",
|
"Fetches content recommendations from a configurable content provider",
|
||||||
// Dynamically determine if Pocket should be shown for a geo / locale
|
// Dynamically determine if Pocket should be shown for a geo / locale
|
||||||
getValue: ({ geo, locale }) => {
|
getValue: ({ geo, locale }) => {
|
||||||
|
const preffedRegionsString =
|
||||||
|
Services.prefs.getStringPref(REGION_STORIES_CONFIG) || "";
|
||||||
|
const preffedRegions = preffedRegionsString.split(",").map(s => s.trim());
|
||||||
const locales = {
|
const locales = {
|
||||||
US: ["en-CA", "en-GB", "en-US", "en-ZA"],
|
US: ["en-CA", "en-GB", "en-US", "en-ZA"],
|
||||||
CA: ["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"],
|
DE: ["de", "de-DE", "de-AT", "de-CH"],
|
||||||
|
JP: ["ja", "ja-JP"],
|
||||||
}[geo];
|
}[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", () => {
|
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", () => {
|
it("should be false with no geo/locale", () => {
|
||||||
|
prefHasUserValueStub.returns(false);
|
||||||
|
appLocaleAsBCP47Stub.get(() => "");
|
||||||
|
getStringPrefStub.withArgs("browser.search.region").returns("");
|
||||||
|
|
||||||
as._updateDynamicPrefs();
|
as._updateDynamicPrefs();
|
||||||
|
|
||||||
assert.isFalse(PREFS_CONFIG.get("feeds.section.topstories").value);
|
assert.isFalse(PREFS_CONFIG.get("feeds.section.topstories").value);
|
||||||
});
|
});
|
||||||
it("should be false with unexpected geo", () => {
|
it("should be false with unexpected geo", () => {
|
||||||
sandbox.stub(global.Services.prefs, "prefHasUserValue").returns(true);
|
getStringPrefStub.withArgs("browser.search.region").returns("NOGEO");
|
||||||
sandbox.stub(global.Services.prefs, "getStringPref").returns("NOGEO");
|
|
||||||
|
|
||||||
as._updateDynamicPrefs();
|
as._updateDynamicPrefs();
|
||||||
|
|
||||||
assert.isFalse(PREFS_CONFIG.get("feeds.section.topstories").value);
|
assert.isFalse(PREFS_CONFIG.get("feeds.section.topstories").value);
|
||||||
});
|
});
|
||||||
it("should be false with expected geo and unexpected locale", () => {
|
it("should be false with expected geo and unexpected locale", () => {
|
||||||
sandbox.stub(global.Services.prefs, "prefHasUserValue").returns(true);
|
appLocaleAsBCP47Stub.get(() => "no-LOCALE");
|
||||||
sandbox.stub(global.Services.prefs, "getStringPref").returns("US");
|
|
||||||
sandbox
|
|
||||||
.stub(global.Services.locale, "appLocaleAsBCP47")
|
|
||||||
.get(() => "no-LOCALE");
|
|
||||||
|
|
||||||
as._updateDynamicPrefs();
|
as._updateDynamicPrefs();
|
||||||
|
|
||||||
assert.isFalse(PREFS_CONFIG.get("feeds.section.topstories").value);
|
assert.isFalse(PREFS_CONFIG.get("feeds.section.topstories").value);
|
||||||
});
|
});
|
||||||
it("should be true with expected geo and locale", () => {
|
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();
|
as._updateDynamicPrefs();
|
||||||
|
|
||||||
assert.isTrue(PREFS_CONFIG.get("feeds.section.topstories").value);
|
assert.isTrue(PREFS_CONFIG.get("feeds.section.topstories").value);
|
||||||
});
|
});
|
||||||
it("should be false after expected geo and locale then unexpected", () => {
|
it("should be false after expected geo and locale then unexpected", () => {
|
||||||
sandbox.stub(global.Services.prefs, "prefHasUserValue").returns(true);
|
getStringPrefStub
|
||||||
sandbox
|
.withArgs("browser.search.region")
|
||||||
.stub(global.Services.prefs, "getStringPref")
|
|
||||||
.onFirstCall()
|
.onFirstCall()
|
||||||
.returns("US")
|
.returns("US")
|
||||||
.onSecondCall()
|
.onSecondCall()
|
||||||
.returns("NOGEO");
|
.returns("NOGEO");
|
||||||
sandbox
|
|
||||||
.stub(global.Services.locale, "appLocaleAsBCP47")
|
|
||||||
.get(() => "en-US");
|
|
||||||
|
|
||||||
as._updateDynamicPrefs();
|
as._updateDynamicPrefs();
|
||||||
as._updateDynamicPrefs();
|
as._updateDynamicPrefs();
|
||||||
|
|
||||||
assert.isFalse(PREFS_CONFIG.get("feeds.section.topstories").value);
|
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", () => {
|
describe("_updateDynamicPrefs topstories delayed default value", () => {
|
||||||
let clock;
|
let clock;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue