Bug 1542716: Allow overriding the update channel that is used when generating the default profile name. r=froydnj

Differential Revision: https://phabricator.services.mozilla.com/D26632

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dave Townsend 2019-04-09 18:38:17 +00:00
parent a18df6e1a4
commit 58c5da3a73
4 changed files with 18 additions and 7 deletions

View File

@ -74,7 +74,7 @@ interface nsIToolkitProfileService : nsISupports
* This method is primarily for testing. It can be called only once.
*/
bool selectStartupProfile(in Array<ACString> aArgv,
in boolean aIsResetting,
in boolean aIsResetting, in AUTF8String aUpdateChannel,
out nsIFile aRootDir, out nsIFile aLocalDir,
out nsIToolkitProfile aProfile);

View File

@ -372,7 +372,8 @@ nsToolkitProfileService::nsToolkitProfileService()
#endif
mCreatedAlternateProfile(false),
mStartupReason(NS_LITERAL_STRING("unknown")),
mMaybeLockProfile(false) {
mMaybeLockProfile(false),
mUpdateChannel(NS_STRINGIFY(MOZ_UPDATE_CHANNEL)) {
#ifdef MOZ_DEV_EDITION
mUseDevEditionProfile = true;
#endif
@ -941,7 +942,7 @@ nsresult nsToolkitProfileService::CreateDefaultProfile(
if (mUseDevEditionProfile) {
name.AssignLiteral(DEV_EDITION_NAME);
} else if (mUseDedicatedProfile) {
name.AssignLiteral("default-" NS_STRINGIFY(MOZ_UPDATE_CHANNEL));
name.AppendPrintf("default-%s", mUpdateChannel.get());
} else {
name.AssignLiteral(DEFAULT_NAME);
}
@ -966,8 +967,9 @@ nsresult nsToolkitProfileService::CreateDefaultProfile(
*/
NS_IMETHODIMP
nsToolkitProfileService::SelectStartupProfile(
const nsTArray<nsCString>& aArgv, bool aIsResetting, nsIFile** aRootDir,
nsIFile** aLocalDir, nsIToolkitProfile** aProfile, bool* aDidCreate) {
const nsTArray<nsCString>& aArgv, bool aIsResetting,
const nsACString& aUpdateChannel, nsIFile** aRootDir, nsIFile** aLocalDir,
nsIToolkitProfile** aProfile, bool* aDidCreate) {
int argc = aArgv.Length();
// Our command line handling expects argv to be null-terminated so construct
// an appropriate array.
@ -982,6 +984,8 @@ nsToolkitProfileService::SelectStartupProfile(
}
argv[argc] = nullptr;
mUpdateChannel = aUpdateChannel;
bool wasDefault;
nsresult rv =
SelectStartupProfile(&argc, argv.get(), aIsResetting, aRootDir, aLocalDir,

View File

@ -150,6 +150,10 @@ class nsToolkitProfileService final : public nsIToolkitProfileService {
nsString mStartupReason;
bool mMaybeLockProfile;
// Holds the current application update channel. This is only really held
// so it can be overriden in tests.
nsCString mUpdateChannel;
static nsToolkitProfileService* gService;
class ProfileEnumerator final : public nsSimpleEnumerator {

View File

@ -11,6 +11,8 @@ const { TelemetryTestUtils } = ChromeUtils.import("resource://testing-common/Tel
const NS_ERROR_START_PROFILE_MANAGER = 0x805800c9;
const UPDATE_CHANNEL = AppConstants.MOZ_UPDATE_CHANNEL;
let gProfD = do_get_profile();
let gDataHome = gProfD.clone();
gDataHome.append("data");
@ -70,7 +72,7 @@ function getProfileService() {
}
let PROFILE_DEFAULT = "default";
let DEDICATED_NAME = `default-${AppConstants.MOZ_UPDATE_CHANNEL}`;
let DEDICATED_NAME = `default-${UPDATE_CHANNEL}`;
if (AppConstants.MOZ_DEV_EDITION) {
DEDICATED_NAME = PROFILE_DEFAULT = "dev-edition-default";
}
@ -95,7 +97,8 @@ function selectStartupProfile(args = [], isResetting = false) {
let localDir = {};
let profile = {};
let didCreate = service.selectStartupProfile(["xpcshell", ...args], isResetting,
rootDir, localDir, profile);
UPDATE_CHANNEL, rootDir, localDir,
profile);
if (profile.value) {
Assert.ok(rootDir.value.equals(profile.value.rootDir), "Should have matched the root dir.");