Bug 1750304 - Move isChinaRepack out of AppConstants r=settings-reviewers,home-newtab-reviewers,Gijs,pdahiya,omc-reviewers,mossop,mconley
AppConstants seems like the wrong place for this method Differential Revision: https://phabricator.services.mozilla.com/D239276
This commit is contained in:
@@ -852,7 +852,7 @@ function prepareMobileDownload(content) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Update CN specific QRCode url
|
// Update CN specific QRCode url
|
||||||
if (AppConstants.isChinaRepack()) {
|
if (lazy.BrowserUtils.isChinaRepack()) {
|
||||||
mobileContent.hero_image.url = `${mobileContent.hero_image.url.slice(
|
mobileContent.hero_image.url = `${mobileContent.hero_image.url.slice(
|
||||||
0,
|
0,
|
||||||
mobileContent.hero_image.url.indexOf(".svg")
|
mobileContent.hero_image.url.indexOf(".svg")
|
||||||
|
|||||||
@@ -621,7 +621,7 @@ describe("MultiStageAboutWelcomeProton module", () => {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
it("should not set url for default qrcode svg", async () => {
|
it("should not set url for default qrcode svg", async () => {
|
||||||
sandbox.stub(global.AppConstants, "isChinaRepack").returns(false);
|
sandbox.stub(global.BrowserUtils, "isChinaRepack").returns(false);
|
||||||
const data =
|
const data =
|
||||||
await AboutWelcomeDefaults.prepareContentForReact(TEST_CONTENT);
|
await AboutWelcomeDefaults.prepareContentForReact(TEST_CONTENT);
|
||||||
assert.propertyVal(
|
assert.propertyVal(
|
||||||
@@ -631,7 +631,7 @@ describe("MultiStageAboutWelcomeProton module", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
it("should set url for cn qrcode svg", async () => {
|
it("should set url for cn qrcode svg", async () => {
|
||||||
sandbox.stub(global.AppConstants, "isChinaRepack").returns(true);
|
sandbox.stub(global.BrowserUtils, "isChinaRepack").returns(true);
|
||||||
const data =
|
const data =
|
||||||
await AboutWelcomeDefaults.prepareContentForReact(TEST_CONTENT);
|
await AboutWelcomeDefaults.prepareContentForReact(TEST_CONTENT);
|
||||||
assert.propertyVal(
|
assert.propertyVal(
|
||||||
|
|||||||
@@ -106,9 +106,6 @@ const TEST_GLOBAL = {
|
|||||||
AppConstants: {
|
AppConstants: {
|
||||||
MOZILLA_OFFICIAL: true,
|
MOZILLA_OFFICIAL: true,
|
||||||
MOZ_APP_VERSION: "69.0a1",
|
MOZ_APP_VERSION: "69.0a1",
|
||||||
isChinaRepack() {
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
isPlatformAndVersionAtMost() {
|
isPlatformAndVersionAtMost() {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
@@ -135,6 +132,9 @@ const TEST_GLOBAL = {
|
|||||||
sendToDeviceEmailsSupported() {
|
sendToDeviceEmailsSupported() {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
isChinaRepack() {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
UpdateUtils: { getUpdateChannel() {} },
|
UpdateUtils: { getUpdateChannel() {} },
|
||||||
BasePromiseWorker: class {
|
BasePromiseWorker: class {
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
const FXA_ENABLED_PREF = "identity.fxaccounts.enabled";
|
const FXA_ENABLED_PREF = "identity.fxaccounts.enabled";
|
||||||
const DISTRIBUTION_ID_PREF = "distribution.id";
|
|
||||||
const DISTRIBUTION_ID_CHINA_REPACK = "MozillaOnline";
|
|
||||||
const TOPIC_SELECTION_MODAL_LAST_DISPLAYED_PREF =
|
const TOPIC_SELECTION_MODAL_LAST_DISPLAYED_PREF =
|
||||||
"browser.newtabpage.activity-stream.discoverystream.topicSelection.onboarding.lastDisplayed";
|
"browser.newtabpage.activity-stream.discoverystream.topicSelection.onboarding.lastDisplayed";
|
||||||
const NOTIFICATION_INTERVAL_AFTER_TOPIC_MODAL_MS = 60000; // Assuming avoid notification up to 1 minute after newtab Topic Notification Modal
|
const NOTIFICATION_INTERVAL_AFTER_TOPIC_MODAL_MS = 60000; // Assuming avoid notification up to 1 minute after newtab Topic Notification Modal
|
||||||
@@ -44,6 +42,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
|||||||
ASRouterPreferences:
|
ASRouterPreferences:
|
||||||
"resource:///modules/asrouter/ASRouterPreferences.sys.mjs",
|
"resource:///modules/asrouter/ASRouterPreferences.sys.mjs",
|
||||||
AttributionCode: "resource:///modules/AttributionCode.sys.mjs",
|
AttributionCode: "resource:///modules/AttributionCode.sys.mjs",
|
||||||
|
BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs",
|
||||||
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs",
|
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs",
|
||||||
ClientEnvironment: "resource://normandy/lib/ClientEnvironment.sys.mjs",
|
ClientEnvironment: "resource://normandy/lib/ClientEnvironment.sys.mjs",
|
||||||
CustomizableUI: "resource:///modules/CustomizableUI.sys.mjs",
|
CustomizableUI: "resource:///modules/CustomizableUI.sys.mjs",
|
||||||
@@ -826,12 +825,7 @@ const TargetingGetters = {
|
|||||||
return AppConstants.platform;
|
return AppConstants.platform;
|
||||||
},
|
},
|
||||||
get isChinaRepack() {
|
get isChinaRepack() {
|
||||||
return (
|
return lazy.BrowserUtils.isChinaRepack();
|
||||||
Services.prefs
|
|
||||||
.getDefaultBranch(null)
|
|
||||||
.getCharPref(DISTRIBUTION_ID_PREF, "default") ===
|
|
||||||
DISTRIBUTION_ID_CHINA_REPACK
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
get userId() {
|
get userId() {
|
||||||
return lazy.ClientEnvironment.userId;
|
return lazy.ClientEnvironment.userId;
|
||||||
|
|||||||
@@ -1475,7 +1475,7 @@ export const OnboardingMessageProvider = {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Update CN specific QRCode url
|
// Update CN specific QRCode url
|
||||||
if (AppConstants.isChinaRepack()) {
|
if (lazy.BrowserUtils.isChinaRepack()) {
|
||||||
mobileContent.hero_image.url = `${mobileContent.hero_image.url.slice(
|
mobileContent.hero_image.url = `${mobileContent.hero_image.url.slice(
|
||||||
0,
|
0,
|
||||||
mobileContent.hero_image.url.indexOf(".svg")
|
mobileContent.hero_image.url.indexOf(".svg")
|
||||||
|
|||||||
@@ -116,9 +116,6 @@ const TEST_GLOBAL = {
|
|||||||
AppConstants: {
|
AppConstants: {
|
||||||
MOZILLA_OFFICIAL: true,
|
MOZILLA_OFFICIAL: true,
|
||||||
MOZ_APP_VERSION: "69.0a1",
|
MOZ_APP_VERSION: "69.0a1",
|
||||||
isChinaRepack() {
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
isPlatformAndVersionAtMost() {
|
isPlatformAndVersionAtMost() {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ var gMoreFromMozillaPane = {
|
|||||||
id: "fxMobile",
|
id: "fxMobile",
|
||||||
type: "link",
|
type: "link",
|
||||||
label_string_id: "more-from-moz-learn-more-link",
|
label_string_id: "more-from-moz-learn-more-link",
|
||||||
actionURL: AppConstants.isChinaRepack()
|
actionURL: BrowserUtils.isChinaRepack()
|
||||||
? "https://www.firefox.com.cn/browsers/mobile/"
|
? "https://www.firefox.com.cn/browsers/mobile/"
|
||||||
: "https://www.mozilla.org/firefox/browsers/mobile/",
|
: "https://www.mozilla.org/firefox/browsers/mobile/",
|
||||||
},
|
},
|
||||||
@@ -106,7 +106,7 @@ var gMoreFromMozillaPane = {
|
|||||||
label: {
|
label: {
|
||||||
string_id: "more-from-moz-qr-code-box-firefox-mobile-button",
|
string_id: "more-from-moz-qr-code-box-firefox-mobile-button",
|
||||||
},
|
},
|
||||||
actionURL: AppConstants.isChinaRepack()
|
actionURL: BrowserUtils.isChinaRepack()
|
||||||
? "https://www.firefox.com.cn/mobile/get-app/"
|
? "https://www.firefox.com.cn/mobile/get-app/"
|
||||||
: "https://www.mozilla.org/firefox/mobile/get-app/?v=mfm",
|
: "https://www.mozilla.org/firefox/mobile/get-app/?v=mfm",
|
||||||
},
|
},
|
||||||
@@ -241,7 +241,7 @@ var gMoreFromMozillaPane = {
|
|||||||
"-" +
|
"-" +
|
||||||
this.getTemplateName() +
|
this.getTemplateName() +
|
||||||
`${
|
`${
|
||||||
AppConstants.isChinaRepack() &&
|
BrowserUtils.isChinaRepack() &&
|
||||||
this.getTemplateName().includes("simple")
|
this.getTemplateName().includes("simple")
|
||||||
? "-cn"
|
? "-cn"
|
||||||
: ""
|
: ""
|
||||||
|
|||||||
@@ -111,9 +111,6 @@ const TEST_GLOBAL = {
|
|||||||
AppConstants: {
|
AppConstants: {
|
||||||
MOZILLA_OFFICIAL: true,
|
MOZILLA_OFFICIAL: true,
|
||||||
MOZ_APP_VERSION: "69.0a1",
|
MOZ_APP_VERSION: "69.0a1",
|
||||||
isChinaRepack() {
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
isPlatformAndVersionAtMost() {
|
isPlatformAndVersionAtMost() {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -270,13 +270,4 @@ export var AppConstants = Object.freeze({
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
USE_LIBZ_RS: @USE_LIBZ_RS_BOOL@,
|
USE_LIBZ_RS: @USE_LIBZ_RS_BOOL@,
|
||||||
|
|
||||||
// Returns true for CN region build when distibution id set as 'MozillaOnline'
|
|
||||||
isChinaRepack() {
|
|
||||||
return (
|
|
||||||
Services.prefs
|
|
||||||
.getDefaultBranch("")
|
|
||||||
.getCharPref("distribution.id", "default") === "MozillaOnline"
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -558,6 +558,20 @@ export var BrowserUtils = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the build is a China repack.
|
||||||
|
*
|
||||||
|
* @return {boolean} True if the distribution ID is 'MozillaOnline',
|
||||||
|
* otherwise false.
|
||||||
|
*/
|
||||||
|
isChinaRepack() {
|
||||||
|
return (
|
||||||
|
Services.prefs
|
||||||
|
.getDefaultBranch("")
|
||||||
|
.getCharPref("distribution.id", "default") === "MozillaOnline"
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enumeration of the promotion types that can be passed to shouldShowPromo
|
* An enumeration of the promotion types that can be passed to shouldShowPromo
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user