Backed out 5 changesets (bug 1722777) for causing xpcshell failures.

Backed out changeset 8ea40ee4caf0 (bug 1722777)
Backed out changeset 00fa6e16e916 (bug 1722777)
Backed out changeset b90cab865ce4 (bug 1722777)
Backed out changeset a8344f5044e6 (bug 1722777)
Backed out changeset 51a7df84c674 (bug 1722777)
This commit is contained in:
Butkovits Atila 2022-03-18 23:39:56 +02:00
Родитель c3cbd0c056
Коммит b18a47ce22
6 изменённых файлов: 18 добавлений и 104 удалений

Просмотреть файл

@ -8,7 +8,6 @@
#include "nsIFile.h"
#include "nsImportModule.h"
#include "nsPrintfCString.h"
#include "nsProfileLock.h"
#include "nsXULAppAPI.h"
#include "SpecialSystemDirectory.h"
@ -171,21 +170,10 @@ nsresult BackgroundTasks::CreateTemporaryProfileDirectoryImpl(
rv = GetSpecialSystemDirectory(OS_TemporaryDirectory, getter_AddRefs(file));
NS_ENSURE_SUCCESS(rv, rv);
nsCString profilePrefix =
nsPrintfCString("%sBackgroundTask-%s-%s", MOZ_APP_VENDOR,
aInstallHash.get(), mBackgroundTask.ref().get());
// Windows file cleanup is unreliable, so let's take a moment to clean up
// any prior background task profiles. We can continue if there was an error
// as creating a new temporary profile does not require cleaning up the old.
rv = RemoveStaleTemporaryProfileDirectories(file, profilePrefix);
if (NS_WARN_IF(NS_FAILED(rv))) {
MOZ_LOG(sBackgroundTasksLog, mozilla::LogLevel::Warning,
("Error cleaning up stale temporary profile directories."));
}
// The base path is /tmp/[vendor]BackgroundTask-[pathHash]-[taskName].
rv = file->AppendNative(profilePrefix);
rv = file->AppendNative(nsPrintfCString("%sBackgroundTask-%s-%s",
MOZ_APP_VENDOR, aInstallHash.get(),
mBackgroundTask.ref().get()));
NS_ENSURE_SUCCESS(rv, rv);
// Create a unique profile directory. This can fail if there are too many
@ -201,73 +189,6 @@ nsresult BackgroundTasks::CreateTemporaryProfileDirectoryImpl(
return NS_OK;
}
nsresult BackgroundTasks::RemoveStaleTemporaryProfileDirectories(
nsIFile* const aRoot, const nsCString& aPrefix) {
nsCOMPtr<nsIDirectoryEnumerator> entries;
nsresult rv = aRoot->GetDirectoryEntries(getter_AddRefs(entries));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> entry;
int removedProfiles = 0;
// Limit the number of stale temporary profiles we clean up so that we don't
// timeout the background task.
const int kMaxRemovedProfiles = 5;
// Loop over the temporary directory entries, deleting folders matching our
// profile prefix. Continue if there is an error interacting with the entry to
// more reliably make progress on cleaning up stale temporary profiles.
while (removedProfiles < kMaxRemovedProfiles &&
NS_SUCCEEDED(rv = entries->GetNextFile(getter_AddRefs(entry))) &&
entry) {
nsCString entryName;
rv = entry->GetNativeLeafName(entryName);
if (NS_FAILED(rv)) {
continue;
}
// Find profile folders matching our prefix.
if (aPrefix.Compare(entryName.get(), false, aPrefix.Length()) != 0) {
continue;
}
// Check if the profile is locked. If successful drop the lock so we can
// delete the folder. Background tasks' temporary profiles are not reused or
// remembered once released, so we don't need to hold this lock while
// deleting it.
nsProfileLock lock;
if (NS_FAILED(lock.Lock(entry, nullptr)) || NS_FAILED(lock.Unlock())) {
continue;
}
rv = entry->Remove(true);
if (NS_FAILED(rv)) {
if (MOZ_LOG_TEST(sBackgroundTasksLog, mozilla::LogLevel::Warning)) {
nsAutoString path;
if (NS_SUCCEEDED(entry->GetPath(path))) {
MOZ_LOG(sBackgroundTasksLog, mozilla::LogLevel::Warning,
("Error removing stale temporary profile directory: %s",
NS_LossyConvertUTF16toASCII(path).get()));
}
}
continue;
}
if (MOZ_LOG_TEST(sBackgroundTasksLog, mozilla::LogLevel::Info)) {
nsAutoString path;
if (NS_SUCCEEDED(entry->GetPath(path))) {
MOZ_LOG(sBackgroundTasksLog, mozilla::LogLevel::Info,
("Removed stale temporary profile directory: %s",
NS_LossyConvertUTF16toASCII(path).get()));
}
}
removedProfiles++;
}
return NS_OK;
}
nsresult BackgroundTasks::GetIsBackgroundTaskMode(bool* result) {
*result = mBackgroundTask.isSome();
return NS_OK;

Просмотреть файл

@ -75,13 +75,6 @@ class BackgroundTasks final : public nsIBackgroundTasks {
nsresult CreateTemporaryProfileDirectoryImpl(const nsCString& aInstallHash,
nsIFile** aFile);
/*
* Iterates children of `aRoot` and removes unlocked profiles matching
* `aPrefix`.
*/
static nsresult RemoveStaleTemporaryProfileDirectories(
nsIFile* const aRoot, const nsCString& aPrefix);
virtual ~BackgroundTasks() = default;
};

Просмотреть файл

@ -50,10 +50,6 @@ EXTRA_JS_MODULES.backgroundtasks += [
"BackgroundTask_success.jsm",
]
LOCAL_INCLUDES += [
"../../profile",
]
BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.ini"]
XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.ini"]

Просмотреть файл

@ -2303,11 +2303,6 @@ nsLocalFile::Remove(bool aRecursive) {
if (isDir) {
if (aRecursive) {
// WARNING: neither the `SHFileOperation` nor `IFileOperation` APIs are
// appropriate here as neither handle long path names, i.e. paths prefixed
// with `\\?\` or longer than 260 characters on Windows 10+ system with
// long paths enabled.
RefPtr<nsDirEnumerator> dirEnum = new nsDirEnumerator();
rv = dirEnum->Init(this);
@ -2315,9 +2310,14 @@ nsLocalFile::Remove(bool aRecursive) {
return rv;
}
nsCOMPtr<nsIFile> file;
while (NS_SUCCEEDED(dirEnum->GetNextFile(getter_AddRefs(file))) && file) {
file->Remove(aRecursive);
bool more = false;
while (NS_SUCCEEDED(dirEnum->HasMoreElements(&more)) && more) {
nsCOMPtr<nsISupports> item;
dirEnum->GetNext(getter_AddRefs(item));
nsCOMPtr<nsIFile> file = do_QueryInterface(item);
if (file) {
file->Remove(aRecursive);
}
}
}
if (RemoveDirectoryW(mWorkingPath.get()) == 0) {
@ -3080,8 +3080,8 @@ nsLocalFile::Contains(nsIFile* aInFile, bool* aResult) {
aInFile->GetPath(inFilePath);
}
// Make sure that the |aInFile|'s path has a trailing separator.
if (inFilePath.Length() > myFilePathLen &&
// make sure that the |aInFile|'s path has a trailing separator.
if (inFilePath.Length() >= myFilePathLen &&
inFilePath[myFilePathLen] == L'\\') {
if (_wcsnicmp(myFilePath.get(), inFilePath.get(), myFilePathLen) == 0) {
*aResult = true;

Просмотреть файл

@ -134,6 +134,11 @@ function testSymLinks(testDir, relative) {
}
function run_test() {
// Skip this test on Windows
if (mozinfo.os == "win") {
return;
}
var testDir = CWD;
testDir.append("test_symlinks");

Просмотреть файл

@ -46,7 +46,6 @@ skip-if = os == "android"
[test_streams.js]
[test_seek_multiplex.js]
[test_stringstream.js]
skip-if = os == "win"
[test_symlinks.js]
# Bug 676998: test fails consistently on Android
fail-if = os == "android"