forked from mirrors/gecko-dev
Bug 1746657 - Only show Rally in MoreForMozilla when region is US and language is en r=preferences-reviewers,dmose,Gijs
Differential Revision: https://phabricator.services.mozilla.com/D134191
This commit is contained in:
parent
523b1551b3
commit
33573e7fbc
3 changed files with 103 additions and 15 deletions
|
|
@ -109,17 +109,19 @@ var gMoreFromMozillaPane = {
|
|||
products.push(vpn);
|
||||
}
|
||||
|
||||
const rally = {
|
||||
id: "mozilla-rally",
|
||||
title_string_id: "more-from-moz-mozilla-rally-title",
|
||||
description_string_id: "more-from-moz-mozilla-rally-description",
|
||||
button: {
|
||||
id: "mozillaRally",
|
||||
label_string_id: "more-from-moz-button-mozilla-rally",
|
||||
actionURL: "https://rally.mozilla.org/",
|
||||
},
|
||||
};
|
||||
products.push(rally);
|
||||
if (BrowserUtils.shouldShowRallyPromo()) {
|
||||
const rally = {
|
||||
id: "mozilla-rally",
|
||||
title_string_id: "more-from-moz-mozilla-rally-title",
|
||||
description_string_id: "more-from-moz-mozilla-rally-description",
|
||||
button: {
|
||||
id: "mozillaRally",
|
||||
label_string_id: "more-from-moz-button-mozilla-rally",
|
||||
actionURL: "https://rally.mozilla.org/",
|
||||
},
|
||||
};
|
||||
products.push(rally);
|
||||
}
|
||||
|
||||
this._productsContainer = document.getElementById(
|
||||
"moreFromMozillaCategory"
|
||||
|
|
|
|||
|
|
@ -11,10 +11,6 @@ let { TelemetryTestUtils } = ChromeUtils.import(
|
|||
"resource://testing-common/TelemetryTestUtils.jsm"
|
||||
);
|
||||
|
||||
let { RegionTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/RegionTestUtils.jsm"
|
||||
);
|
||||
|
||||
let { Region } = ChromeUtils.import("resource://gre/modules/Region.jsm");
|
||||
|
||||
const initialHomeRegion = Region._home;
|
||||
|
|
@ -405,3 +401,83 @@ add_task(async function test_VPN_promo_in_illegal_current_region() {
|
|||
setupRegions(initialHomeRegion, intialCurrentRegion); // revert changes to regions
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
|
||||
add_task(
|
||||
async function test_rally_promo_with_approved_home_region_and_language() {
|
||||
// Only show the Rally promo when US is the region and English is the langauge
|
||||
setupRegions("US");
|
||||
|
||||
await openPreferencesViaOpenPreferencesAPI("paneMoreFromMozilla", {
|
||||
leaveOpen: true,
|
||||
});
|
||||
|
||||
let doc = gBrowser.contentDocument;
|
||||
let rallyPromoCard = doc.getElementById("mozilla-rally");
|
||||
let mobileCard = doc.getElementById("firefox-mobile");
|
||||
ok(rallyPromoCard, "The Rally promo is visible");
|
||||
ok(mobileCard, "The Mobile promo is visible");
|
||||
|
||||
setupRegions(initialHomeRegion, intialCurrentRegion); // revert changes to regions
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
}
|
||||
);
|
||||
|
||||
add_task(async function test_rally_promo_with_unapproved_home_region() {
|
||||
setupRegions("IS");
|
||||
|
||||
await openPreferencesViaOpenPreferencesAPI("paneMoreFromMozilla", {
|
||||
leaveOpen: true,
|
||||
});
|
||||
|
||||
let doc = gBrowser.contentDocument;
|
||||
let rallyPromoCard = doc.getElementById("mozilla-rally");
|
||||
let mobileCard = doc.getElementById("firefox-mobile");
|
||||
ok(!rallyPromoCard, "The Rally promo is not visible");
|
||||
ok(mobileCard, "The Mobile promo is visible");
|
||||
|
||||
setupRegions(initialHomeRegion, intialCurrentRegion); // revert changes to regions
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
|
||||
add_task(async function test_rally_promo_with_unapproved_current_region() {
|
||||
setupRegions("US", "IS");
|
||||
|
||||
await openPreferencesViaOpenPreferencesAPI("paneMoreFromMozilla", {
|
||||
leaveOpen: true,
|
||||
});
|
||||
|
||||
let doc = gBrowser.contentDocument;
|
||||
let rallyPromoCard = doc.getElementById("mozilla-rally");
|
||||
let mobileCard = doc.getElementById("firefox-mobile");
|
||||
ok(!rallyPromoCard, "The Rally promo is not visible");
|
||||
ok(mobileCard, "The Mobile promo is visible");
|
||||
|
||||
setupRegions(initialHomeRegion, intialCurrentRegion); // revert changes to regions
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
|
||||
add_task(async function test_rally_promo_with_unapproved_language() {
|
||||
function setLanguage(language) {
|
||||
Services.locale.availableLocales = [language];
|
||||
Services.locale.requestedLocales = [language];
|
||||
}
|
||||
// Rally promo should be hidden in the US for languages other than English
|
||||
setupRegions("US");
|
||||
const initialLanguage = Services.locale.appLocaleAsBCP47;
|
||||
setLanguage("ko-KR");
|
||||
|
||||
await openPreferencesViaOpenPreferencesAPI("paneMoreFromMozilla", {
|
||||
leaveOpen: true,
|
||||
});
|
||||
|
||||
let doc = gBrowser.contentDocument;
|
||||
let rallyPromoCard = doc.getElementById("mozilla-rally");
|
||||
let mobileCard = doc.getElementById("firefox-mobile");
|
||||
ok(!rallyPromoCard, "The Rally promo is not visible");
|
||||
ok(mobileCard, "The Mobile promo is visible");
|
||||
|
||||
setupRegions(initialHomeRegion, intialCurrentRegion); // revert changes to regions
|
||||
// revert changes to language
|
||||
setLanguage(initialLanguage);
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -321,6 +321,16 @@ var BrowserUtils = {
|
|||
!avoidAdsCountries.has(currentRegion.toLowerCase())
|
||||
);
|
||||
},
|
||||
|
||||
// Returns true if user should see Rally promos
|
||||
shouldShowRallyPromo() {
|
||||
const homeRegion = Region.home || "";
|
||||
const currentRegion = Region.current || "";
|
||||
const region = currentRegion || homeRegion;
|
||||
const language = Services.locale.appLocaleAsBCP47;
|
||||
|
||||
return language.startsWith("en-") && region.toLowerCase() == "us";
|
||||
},
|
||||
};
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
|
|
|
|||
Loading…
Reference in a new issue