Skip to content

Commit 1aa5913

Browse files
author
Sandor Molnar
committed
Backed out 3 changesets (bug 1709969) for causing xpc failures in test_select_profile_package. CLOSED TREE
Backed out changeset 17ed7ca86998 (bug 1709969) Backed out changeset a6b917838765 (bug 1709969) Backed out changeset 6a80559a4055 (bug 1709969)
1 parent 107d508 commit 1aa5913

File tree

14 files changed

+68
-441
lines changed

14 files changed

+68
-441
lines changed

toolkit/components/telemetry/Scalars.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5495,7 +5495,6 @@ startup:
54955495
- 1522934
54965496
- 1570652
54975497
- 1623406
5498-
- 1709969
54995498
description: >
55005499
How the profile was selected during startup. One of the following reasons:
55015500
unknown:
@@ -5526,9 +5525,6 @@ startup:
55265525
the old default profile and created a new profile.
55275526
firstrun-created-default:
55285527
A first run of the application created a new profile to use.
5529-
firstrun-migrated-default:
5530-
A first run of the application created a new profile to use, based on
5531-
migrating an existing profile from the same application.
55325528
default:
55335529
The default profile was selected as normal.
55345530
expires: "99"

toolkit/profile/nsToolkitProfileService.cpp

Lines changed: 20 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
# include <windows.h>
2020
# include <shlobj.h>
2121
# include "mozilla/PolicyChecks.h"
22-
# include "WinUtils.h"
2322
#endif
2423
#ifdef XP_UNIX
2524
# include <unistd.h>
@@ -55,12 +54,9 @@
5554
#include "nsProxyRelease.h"
5655
#include "prinrval.h"
5756
#include "prthread.h"
58-
#include "mozilla/XREAppData.h"
5957

6058
using namespace mozilla;
6159

62-
extern const char gToolkitBuildID[];
63-
6460
#define DEV_EDITION_NAME "dev-edition-default"
6561
#define DEFAULT_NAME "default"
6662
#define COMPAT_FILE u"compatibility.ini"_ns
@@ -1535,114 +1531,6 @@ nsresult nsToolkitProfileService::SelectStartupProfile(
15351531
}
15361532
}
15371533

1538-
if (IsWinPackageEnvironment() && mIsFirstRun && !mProfiles.isEmpty()) {
1539-
// Unlike with Snap packages, Windows packages do use dedicated profiles,
1540-
// so we don't need any special behavior to create a profile for them.
1541-
// However, it's likely that a user of an app package was previously using
1542-
// a non-packaged installation, and so has a dedicated profile for that
1543-
// installation, or possibly a "normal" default profile, and we want that
1544-
// user to have some level of continuity when they make the switch. What
1545-
// that means is that we need to identify the profile that is most likely to
1546-
// be the one the user was last working in, and run a profile migration into
1547-
// our new dedicated profile for this installation. This code handles the
1548-
// first part, identifying the profile, and then hands off to the regular
1549-
// profile cleanup code in XREMain to run the actual migration.
1550-
nsCOMPtr<nsIToolkitProfile> oldProfile;
1551-
1552-
// Packages aren't really associated with any non-packaged installation, so
1553-
// we have no way to look up any specific dedicated profile. The next best
1554-
// way we have to identify the most relevant profile is to find the one
1555-
// that was used most recently.
1556-
PRTime latestTime = 0;
1557-
1558-
// We'll also check whether each profile would be a downgrade, unless
1559-
// downgrades are being allowed.
1560-
bool allowDowngrade =
1561-
EnvHasValue("MOZ_ALLOW_DOWNGRADE") ||
1562-
CheckArg(*aArgc, aArgv, "allow-downgrade",
1563-
static_cast<const char**>(nullptr), CheckArgFlag::None);
1564-
1565-
for (nsCOMPtr<nsIToolkitProfile> profile : mProfiles) {
1566-
// Get this profile's last used time by checking the modified time on
1567-
// its lock file. This isn't an ideal way to decide when the profile was
1568-
// used last, but that time doesn't seem to be reliably written anywhere
1569-
// else that we can read from here.
1570-
nsCOMPtr<nsIFile> rootDir;
1571-
profile->GetRootDir(getter_AddRefs(rootDir));
1572-
nsCOMPtr<nsIFile> lockFile;
1573-
rootDir->Clone(getter_AddRefs(lockFile));
1574-
lockFile->Append(u"parent.lock"_ns);
1575-
1576-
PRTime lastLockTime = 0;
1577-
lockFile->GetLastModifiedTime(&lastLockTime);
1578-
1579-
if (lastLockTime <= latestTime) {
1580-
continue;
1581-
}
1582-
1583-
// This is (currently) the most recently used profile, but we need to
1584-
// make sure it hasn't been used by a newer version of the application,
1585-
// because if it has then we won't be able to load it. But also, this
1586-
// whole check is a waste of time if downgrade is enabled, so check for
1587-
// that condition first.
1588-
if (allowDowngrade) {
1589-
oldProfile = profile;
1590-
latestTime = lastLockTime;
1591-
continue;
1592-
}
1593-
1594-
nsCOMPtr<nsIFile> compatIniFile;
1595-
rootDir->Clone(getter_AddRefs(compatIniFile));
1596-
if (!compatIniFile) {
1597-
continue;
1598-
}
1599-
1600-
compatIniFile->Append(COMPAT_FILE);
1601-
nsINIParser compatIniParser;
1602-
if (NS_FAILED(compatIniParser.Init(compatIniFile))) {
1603-
continue;
1604-
}
1605-
1606-
nsAutoCString lastVersion;
1607-
if (NS_FAILED(compatIniParser.GetString("Compatibility", "LastVersion",
1608-
lastVersion))) {
1609-
continue;
1610-
}
1611-
1612-
nsAutoCString currentVersion;
1613-
if (gAppData) {
1614-
BuildCompatVersion(gAppData->version, gAppData->buildID,
1615-
gToolkitBuildID, currentVersion);
1616-
} else {
1617-
// gAppData is the preferred way to get the app version and build ID,
1618-
// but xpcshell doesn't initialize it, so we need a fallback. This
1619-
// assumes that the app and toolkit version/build ID are the same, which
1620-
// is not good to assume in general, but should be fine for xpcshell.
1621-
BuildCompatVersion(MOZILLA_VERSION, gToolkitBuildID, gToolkitBuildID,
1622-
currentVersion);
1623-
}
1624-
if (CompareCompatVersions(lastVersion, currentVersion) > 0) {
1625-
continue;
1626-
}
1627-
1628-
oldProfile = profile;
1629-
latestTime = lastLockTime;
1630-
}
1631-
1632-
// We can't invoke the migrator directly from here because the component
1633-
// manager isn't running yet, so signal to our caller that it should start a
1634-
// migration whenever possible. We need to do that before creating a new
1635-
// profile here because the refresh procedure will create one later.
1636-
if (oldProfile) {
1637-
mCurrent = oldProfile.forget();
1638-
mCurrent->GetRootDir(aRootDir);
1639-
mCurrent->GetLocalDir(aLocalDir);
1640-
NS_ADDREF(*aProfile = mCurrent);
1641-
mStartupReason = u"firstrun-migrated-default"_ns;
1642-
return NS_MIGRATE_INTO_PACKAGE;
1643-
}
1644-
}
1645-
16461534
// If this is a first run then create a new profile.
16471535
if (mIsFirstRun) {
16481536
// If we're configured to always show the profile manager then don't create
@@ -1735,8 +1623,8 @@ nsresult nsToolkitProfileService::SelectStartupProfile(
17351623

17361624
GetDefaultProfile(getter_AddRefs(mCurrent));
17371625

1738-
// None of the profiles was marked as default (generally only happens if
1739-
// the user modifies profiles.ini manually). Let the user choose.
1626+
// None of the profiles was marked as default (generally only happens if the
1627+
// user modifies profiles.ini manually). Let the user choose.
17401628
if (!mCurrent) {
17411629
return NS_ERROR_SHOW_PROFILE_MANAGER;
17421630
}
@@ -1790,22 +1678,14 @@ nsresult nsToolkitProfileService::CreateResetProfile(
17901678
* default as well.
17911679
*/
17921680
nsresult nsToolkitProfileService::ApplyResetProfile(
1793-
nsIToolkitProfile* aOldProfile, bool aDeleteOldProfile) {
1681+
nsIToolkitProfile* aOldProfile) {
17941682
// If the old profile would have been the default for old installs then mark
17951683
// the new profile as such.
17961684
if (mNormalDefault == aOldProfile) {
17971685
SetNormalDefault(mCurrent);
17981686
}
17991687

1800-
// For a "standard" profile reset, the current dedicated profile (the one that
1801-
// we've just created and reset into) should match the one that we've migrated
1802-
// from; that means we want to make this one our new dedicated default.
1803-
// If they don't match, it might be because we migrated from a different
1804-
// installation's dedicated profile, or a non-dedicated profile; in that case
1805-
// we aren't deleting the old profile, but we still need to set the new one as
1806-
// this installation's default.
1807-
if (mUseDedicatedProfile &&
1808-
(mDedicatedProfile == aOldProfile || !aDeleteOldProfile)) {
1688+
if (mUseDedicatedProfile && mDedicatedProfile == aOldProfile) {
18091689
bool wasLocked = false;
18101690
nsCString val;
18111691
if (NS_SUCCEEDED(
@@ -1821,31 +1701,27 @@ nsresult nsToolkitProfileService::ApplyResetProfile(
18211701
}
18221702
}
18231703

1824-
if (aDeleteOldProfile) {
1825-
nsCString name;
1826-
nsresult rv = aOldProfile->GetName(name);
1827-
NS_ENSURE_SUCCESS(rv, rv);
1704+
nsCString name;
1705+
nsresult rv = aOldProfile->GetName(name);
1706+
NS_ENSURE_SUCCESS(rv, rv);
18281707

1829-
// Don't remove the old profile's files until after we've successfully
1830-
// flushed the profile changes to disk.
1831-
rv = aOldProfile->Remove(false);
1832-
NS_ENSURE_SUCCESS(rv, rv);
1708+
// Don't remove the old profile's files until after we've successfully flushed
1709+
// the profile changes to disk.
1710+
rv = aOldProfile->Remove(false);
1711+
NS_ENSURE_SUCCESS(rv, rv);
18331712

1834-
// Switching the name will make this the default for dev-edition if
1835-
// appropriate.
1836-
rv = mCurrent->SetName(name);
1837-
NS_ENSURE_SUCCESS(rv, rv);
1838-
}
1713+
// Switching the name will make this the default for dev-edition if
1714+
// appropriate.
1715+
rv = mCurrent->SetName(name);
1716+
NS_ENSURE_SUCCESS(rv, rv);
18391717

1840-
nsresult rv = Flush();
1718+
rv = Flush();
18411719
NS_ENSURE_SUCCESS(rv, rv);
18421720

1843-
if (aDeleteOldProfile) {
1844-
// Now that the profile changes are flushed, try to remove the old profile's
1845-
// files. If we fail the worst that will happen is that an orphan directory
1846-
// is left. Let this run in the background while we start up.
1847-
RemoveProfileFiles(aOldProfile, true);
1848-
}
1721+
// Now that the profile changes are flushed, try to remove the old profile's
1722+
// files. If we fail the worst that will happen is that an orphan directory is
1723+
// left. Let this run in the background while we start up.
1724+
RemoveProfileFiles(aOldProfile, true);
18491725

18501726
return NS_OK;
18511727
}
@@ -2057,25 +1933,6 @@ bool nsToolkitProfileService::IsSnapEnvironment() {
20571933
return (strcmp(snapName, "firefox") == 0);
20581934
}
20591935

2060-
/**
2061-
* Like Snaps, Windows app packages
2062-
* (https://docs.microsoft.com/en-us/windows/msix/overview) use a
2063-
* different installation directory for every version of the application, but
2064-
* we have an alternative method of obtaining a per-installation hash for such
2065-
* packages. Because of that, we don't disable dedicated profiles for them.
2066-
* We still need to know when we're in one though, because we have special
2067-
* migration behavior there; see comments in SelectStartupProfile.
2068-
*/
2069-
bool nsToolkitProfileService::IsWinPackageEnvironment() {
2070-
#ifdef XP_WIN
2071-
if (EnvHasValue("MOZ_TEST_EMULATE_PACKAGE") ||
2072-
mozilla::widget::WinUtils::HasPackageIdentity()) {
2073-
return true;
2074-
}
2075-
#endif
2076-
return false;
2077-
}
2078-
20791936
/**
20801937
* In some situations dedicated profile support does not work well. This
20811938
* includes a handful of linux distributions which always install different

toolkit/profile/nsToolkitProfileService.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ class nsToolkitProfileService final : public nsIToolkitProfileService {
8282
nsIToolkitProfile** aProfile, bool* aDidCreate,
8383
bool* aWasDefaultSelection);
8484
nsresult CreateResetProfile(nsIToolkitProfile** aNewProfile);
85-
nsresult ApplyResetProfile(nsIToolkitProfile* aOldProfile,
86-
bool aDeleteOldProfile = true);
85+
nsresult ApplyResetProfile(nsIToolkitProfile* aOldProfile);
8786
void CompleteStartup();
8887

8988
private:
@@ -107,7 +106,6 @@ class nsToolkitProfileService final : public nsIToolkitProfileService {
107106
nsresult MaybeMakeDefaultDedicatedProfile(nsIToolkitProfile* aProfile,
108107
bool* aResult);
109108
bool IsSnapEnvironment();
110-
bool IsWinPackageEnvironment();
111109
bool UseLegacyProfiles();
112110
nsresult CreateDefaultProfile(nsIToolkitProfile** aResult);
113111
void SetNormalDefault(nsIToolkitProfile* aProfile);

toolkit/profile/xpcshell/head.js

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,6 @@ function simulateSnapEnvironment() {
7878
gIsLegacy = true;
7979
}
8080

81-
// This doesn't actually simulate running as a Windows package, because that
82-
// isn't really possible. We're just telling the profile service to pretend it
83-
// found a package environment running.
84-
// Use of this function is not limited to Windows.
85-
function simulateWinPackageEnvironment() {
86-
let env = Cc["@mozilla.org/process/environment;1"].getService(
87-
Ci.nsIEnvironment
88-
);
89-
env.set("MOZ_TEST_EMULATE_PACKAGE", "1");
90-
91-
gIsLegacy = false;
92-
}
93-
9481
function enableLegacyProfiles() {
9582
let env = Cc["@mozilla.org/process/environment;1"].getService(
9683
Ci.nsIEnvironment
@@ -195,8 +182,7 @@ function safeGet(ini, section, key) {
195182
function writeCompatibilityIni(
196183
dir,
197184
appDir = FileUtils.getDir("CurProcD", []),
198-
greDir = FileUtils.getDir("GreD", []),
199-
options = { downgrade: false }
185+
greDir = FileUtils.getDir("GreD", [])
200186
) {
201187
let target = dir.clone();
202188
target.append("compatibility.ini");
@@ -206,23 +192,12 @@ function writeCompatibilityIni(
206192
);
207193
let ini = factory.createINIParser().QueryInterface(Ci.nsIINIParserWriter);
208194

209-
if (options.downgrade) {
210-
// Simulate attempting to downgrade a profile.
211-
ini.setString(
212-
"Compatibility",
213-
"LastVersion",
214-
"9999.0a1_99991231235959/99991231235959"
215-
);
216-
} else {
217-
// Simulate attempting to upgrade a profile.
218-
ini.setString(
219-
"Compatibility",
220-
"LastVersion",
221-
"64.0a1_20180919123806/20180919123806"
222-
);
223-
}
224-
225-
// The profile service doesn't care about these so just use fixed values.
195+
// The profile service doesn't care about these so just use fixed values
196+
ini.setString(
197+
"Compatibility",
198+
"LastVersion",
199+
"64.0a1_20180919123806/20180919123806"
200+
);
226201
ini.setString("Compatibility", "LastOSABI", "Darwin_x86_64-gcc3");
227202

228203
ini.setString(

toolkit/profile/xpcshell/test_select_profile_package.js

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)