Backed out 2 changesets (bug 1783099, bug 1772178) for causing bc failures on browser_all_files_referenced.js. CLOSED TREE

Backed out changeset c4ca03b83a54 (bug 1772178)
Backed out changeset c5690a290bfe (bug 1783099)
This commit is contained in:
Marian-Vasile Laza 2022-08-25 18:19:23 +03:00
Родитель c7e2579b91
Коммит 36e9738343
5 изменённых файлов: 56 добавлений и 79 удалений

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

@ -798,7 +798,11 @@ function findChromeUrlsFromArray(array, prefix) {
}
add_task(async function checkAllTheFiles() {
const libxul = await IOUtils.read(PathUtils.xulLibraryPath);
let libxulPath = OS.Constants.Path.libxul;
if (AppConstants.platform != "macosx") {
libxulPath = PathUtils.join(OS.Constants.Path.libDir, libxulPath);
}
let libxul = await IOUtils.read(libxulPath);
findChromeUrlsFromArray(libxul, "chrome://");
findChromeUrlsFromArray(libxul, "resource://");
// Handle NS_LITERAL_STRING.

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

@ -20,6 +20,7 @@ const IS_ALPHA = /^[a-z]+$/i;
var { PerfTestHelpers } = ChromeUtils.import(
"resource://testing-common/PerfTestHelpers.jsm"
);
var { OS, require } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
/**
* Returns a promise that is resolved with a list of files that have one of the
@ -47,52 +48,61 @@ function generateURIsFromDirTree(dir, extensions) {
}
/**
* Iterate over the children of |path| and find subdirectories and files with
* the given extension.
* Uses OS.File.DirectoryIterator to asynchronously iterate over a directory.
* It returns a promise that is resolved with an object with two properties:
* - files: an array of nsIURIs corresponding to files that match the extensions passed
* - subdirs: an array of paths for subdirectories we need to recurse into
* (handled by generateURIsFromDirTree above)
*
* This function recurses into ZIP and JAR archives as well.
*
* @param {string} path The path to check.
* @param {string[]} extensions The file extensions we're interested in.
*
* @returns {Promise<object>}
* A promise that resolves to an object containing the following
* properties:
* - files: an array of nsIURIs corresponding to
* files that match the extensions passed
* - subdirs: an array of paths for subdirectories we need to recurse
* into (handled by generateURIsFromDirTree above)
* @param path the path to check (string)
* @param extensions the file extensions we're interested in.
*/
async function iterateOverPath(path, extensions) {
const children = await IOUtils.getChildren(path);
function iterateOverPath(path, extensions) {
let iterator = new OS.File.DirectoryIterator(path);
let parentDir = new LocalFile(path);
let subdirs = [];
let files = [];
const files = [];
const subdirs = [];
for (const entry of children) {
const stat = await IOUtils.stat(entry);
if (stat.type === "directory") {
subdirs.push(entry);
} else if (extensions.some(extension => entry.endsWith(extension))) {
if (await IOUtils.exists(entry)) {
const spec = PathUtils.toFileURI(entry);
files.push(spec);
let pathEntryIterator = entry => {
if (entry.isDir) {
subdirs.push(entry.path);
} else if (extensions.some(extension => entry.name.endsWith(extension))) {
let file = parentDir.clone();
file.append(entry.name);
// the build system might leave dead symlinks hanging around, which are
// returned as part of the directory iterator, but don't actually exist:
if (file.exists()) {
let uriSpec = getURLForFile(file);
files.push(Services.io.newURI(uriSpec));
}
} else if (
entry.endsWith(".ja") ||
entry.endsWith(".jar") ||
entry.endsWith(".zip") ||
entry.endsWith(".xpi")
entry.name.endsWith(".ja") ||
entry.name.endsWith(".jar") ||
entry.name.endsWith(".zip") ||
entry.name.endsWith(".xpi")
) {
const file = new LocalFile(entry);
for (const extension of extensions) {
files.push(...generateEntriesFromJarFile(file, extension));
let file = parentDir.clone();
file.append(entry.name);
for (let extension of extensions) {
let jarEntryIterator = generateEntriesFromJarFile(file, extension);
files.push(...jarEntryIterator);
}
}
}
};
return { files, subdirs };
return new Promise((resolve, reject) => {
(async function() {
try {
// Iterate through the directory
await iterator.forEach(pathEntryIterator);
resolve({ files, subdirs });
} catch (ex) {
reject(ex);
} finally {
iterator.close();
}
})();
});
}
/* Helper function to generate a URI spec (NB: not an nsIURI yet!)

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

@ -126,12 +126,6 @@ partial namespace PathUtils {
*/
[Throws, BinaryName="OSTempDirSync"]
readonly attribute DOMString osTempDir;
/**
* The libxul path.
*/
[Throws, BinaryName="XulLibraryPathSync"]
readonly attribute DOMString xulLibraryPath;
};
[Exposed=Worker]
@ -159,10 +153,4 @@ partial namespace PathUtils {
*/
[NewObject, BinaryName="GetOSTempDirAsync"]
Promise<DOMString> getOSTempDir();
/**
* The libxul path.
*/
[NewObject, BinaryName="GetXulLibraryPathAsync"]
Promise<DOMString> getXulLibraryPath();
};

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

@ -384,15 +384,6 @@ void PathUtils::GetOSTempDirSync(const GlobalObject&, nsString& aResult,
.GetDirectorySync(aResult, aErr, DirectoryCache::Directory::OSTemp);
}
void PathUtils::GetXulLibraryPathSync(const GlobalObject&, nsString& aResult,
ErrorResult& aErr) {
MOZ_ASSERT(NS_IsMainThread());
auto guard = sDirCache.Lock();
DirectoryCache::Ensure(guard.ref())
.GetDirectorySync(aResult, aErr, DirectoryCache::Directory::XulLibrary);
}
already_AddRefed<Promise> PathUtils::GetProfileDirAsync(
const GlobalObject& aGlobal, ErrorResult& aErr) {
MOZ_ASSERT(!NS_IsMainThread());
@ -430,15 +421,6 @@ already_AddRefed<Promise> PathUtils::GetOSTempDirAsync(
.GetDirectoryAsync(aGlobal, aErr, DirectoryCache::Directory::OSTemp);
}
already_AddRefed<Promise> PathUtils::GetXulLibraryPathAsync(
const GlobalObject& aGlobal, ErrorResult& aErr) {
MOZ_ASSERT(!NS_IsMainThread());
auto guard = sDirCache.Lock();
return DirectoryCache::Ensure(guard.ref())
.GetDirectoryAsync(aGlobal, aErr, DirectoryCache::Directory::XulLibrary);
}
PathUtils::DirectoryCache::DirectoryCache() {
for (auto& dir : mDirectories) {
dir.SetIsVoid(true);

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

@ -76,8 +76,6 @@ class PathUtils final {
ErrorResult& aErr);
static void GetOSTempDirSync(const GlobalObject&, nsString& aResult,
ErrorResult& aErr);
static void GetXulLibraryPathSync(const GlobalObject&, nsString& aResult,
ErrorResult& aErr);
static already_AddRefed<Promise> GetProfileDirAsync(
const GlobalObject& aGlobal, ErrorResult& aErr);
@ -87,8 +85,6 @@ class PathUtils final {
ErrorResult& aErr);
static already_AddRefed<Promise> GetOSTempDirAsync(
const GlobalObject& aGlobal, ErrorResult& aErr);
static already_AddRefed<Promise> GetXulLibraryPathAsync(
const GlobalObject& aGlobal, ErrorResult& aErr);
private:
class DirectoryCache;
@ -123,10 +119,6 @@ class PathUtils::DirectoryCache final {
* The OS temporary directory.
*/
OSTemp,
/**
* The libxul path.
*/
XulLibrary,
/**
* The number of Directory entries.
*/
@ -236,9 +228,10 @@ class PathUtils::DirectoryCache final {
DirectoryArray<MozPromiseHolder<PopulateDirectoriesPromise>> mPromises;
static constexpr DirectoryArray<const char*> kDirectoryNames{
NS_APP_USER_PROFILE_50_DIR, NS_APP_USER_PROFILE_LOCAL_50_DIR,
NS_APP_CONTENT_PROCESS_TEMP_DIR, NS_OS_TEMP_DIR,
NS_XPCOM_LIBRARY_FILE,
NS_APP_USER_PROFILE_50_DIR,
NS_APP_USER_PROFILE_LOCAL_50_DIR,
NS_APP_CONTENT_PROCESS_TEMP_DIR,
NS_OS_TEMP_DIR,
};
};