Bug 1795568 Part 1 - Remove plugin support code r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D159465
This commit is contained in:
Robert Longson 2022-10-24 18:56:41 +00:00
parent 58379b8620
commit a546daf2d8
14 changed files with 4 additions and 222 deletions

View File

@ -118,15 +118,11 @@ class XPCShellDirProvider : public nsIDirectoryServiceProvider2 {
// The app executable
void SetAppFile(nsIFile* appFile);
void ClearAppFile() { mAppFile = nullptr; }
// An additional custom plugin dir if specified
void SetPluginDir(nsIFile* pluginDir);
void ClearPluginDir() { mPluginDir = nullptr; }
private:
nsCOMPtr<nsIFile> mGREDir;
nsCOMPtr<nsIFile> mGREBinDir;
nsCOMPtr<nsIFile> mAppDir;
nsCOMPtr<nsIFile> mPluginDir;
nsCOMPtr<nsIFile> mAppFile;
};
@ -990,18 +986,6 @@ static bool ProcessArgs(AutoJSAPI& jsapi, char** argv, int argc,
compileOnly = true;
isInteractive = false;
break;
case 'p': {
// plugins path
char* pluginPath = argv[++i];
nsCOMPtr<nsIFile> pluginsDir;
if (NS_FAILED(
XRE_GetFileFromPath(pluginPath, getter_AddRefs(pluginsDir)))) {
fprintf(gErrFile, "Couldn't use given plugins dir.\n");
return printUsageAndSetExitCode();
}
aDirProvider->SetPluginDir(pluginsDir);
break;
}
default:
return printUsageAndSetExitCode();
}
@ -1422,7 +1406,6 @@ int XRE_XPCShellMain(int argc, char** argv, char** envp,
dirprovider.ClearGREDirs();
dirprovider.ClearAppDir();
dirprovider.ClearPluginDir();
dirprovider.ClearAppFile();
} // this scopes the nsCOMPtrs
@ -1468,10 +1451,6 @@ void XPCShellDirProvider::SetAppFile(nsIFile* appFile) { mAppFile = appFile; }
void XPCShellDirProvider::SetAppDir(nsIFile* appDir) { mAppDir = appDir; }
void XPCShellDirProvider::SetPluginDir(nsIFile* pluginDir) {
mPluginDir = pluginDir;
}
NS_IMETHODIMP_(MozExternalRefCountType)
XPCShellDirProvider::AddRef() { return 2; }
@ -1543,29 +1522,6 @@ XPCShellDirProvider::GetFiles(const char* prop, nsISimpleEnumerator** result) {
return NS_NewArrayEnumerator(result, dirs, NS_GET_IID(nsIFile));
}
return NS_ERROR_FAILURE;
} else if (!strcmp(prop, NS_APP_PLUGINS_DIR_LIST)) {
nsCOMArray<nsIFile> dirs;
// Add the test plugin location passed in by the caller or through
// runxpcshelltests.
if (mPluginDir) {
dirs.AppendObject(mPluginDir);
// If there was no path specified, default to the one set up by automation
} else {
nsCOMPtr<nsIFile> file;
bool exists;
// We have to add this path, buildbot copies the test plugin directory
// to (app)/bin when unpacking test zips.
if (mGREDir) {
mGREDir->Clone(getter_AddRefs(file));
if (NS_SUCCEEDED(mGREDir->Clone(getter_AddRefs(file)))) {
file->AppendNative("plugins"_ns);
if (NS_SUCCEEDED(file->Exists(&exists)) && exists) {
dirs.AppendObject(file);
}
}
}
}
return NS_NewArrayEnumerator(result, dirs, NS_GET_IID(nsIFile));
}
return NS_ERROR_FAILURE;
}

View File

@ -301,7 +301,6 @@ config = {
"--log-raw-level=%(log_raw_level)s",
"--log-errorsummary=%(error_summary_file)s",
"--log-tbpl-level=%(log_tbpl_level)s",
"--test-plugin-path=none",
"--threads=4",
"--deviceSerial=%(device_serial)s",
"%(xpcshell_extra)s",

View File

@ -122,7 +122,6 @@ config = {
"options": [
"--self-test",
"--symbols-path=%(symbols_path)s",
"--test-plugin-path=%(test_plugin_path)s",
"--log-raw=%(raw_log_file)s",
"--log-errorsummary=%(error_summary_file)s",
"--utility-path=tests/bin",

View File

@ -102,7 +102,6 @@ config = {
"options": [
"--self-test",
"--symbols-path=%(symbols_path)s",
"--test-plugin-path=%(test_plugin_path)s",
"--log-raw=%(raw_log_file)s",
"--log-errorsummary=%(error_summary_file)s",
"--utility-path=tests/bin",

View File

@ -129,7 +129,6 @@ config = {
"options": [
"--self-test",
"--symbols-path=%(symbols_path)s",
"--test-plugin-path=%(test_plugin_path)s",
"--log-raw=%(raw_log_file)s",
"--log-errorsummary=%(error_summary_file)s",
"--utility-path=tests/bin",

View File

@ -666,10 +666,6 @@ class DesktopUnittest(TestingMixin, MercurialScript, MozbaseMixin, CodeCoverageM
if c["test_tags"]:
base_cmd.extend(["--tag={}".format(t) for t in c["test_tags"]])
# set pluginsPath
abs_res_plugins_dir = os.path.join(abs_res_dir, "plugins")
str_format_values["test_plugin_path"] = abs_res_plugins_dir
if suite_category not in c["suite_definitions"]:
self.fatal("'%s' not defined in the config!")

View File

@ -99,9 +99,6 @@ class XPCShellRunner(MozbuildObject):
if kwargs["profileName"] is None:
kwargs["profileName"] = "firefox"
if kwargs["pluginsPath"] is None:
kwargs["pluginsPath"] = os.path.join(self.distdir, "plugins")
if kwargs["testingModulesDir"] is None:
kwargs["testingModulesDir"] = os.path.join(self.topobjdir, "_tests/modules")

View File

@ -27,13 +27,6 @@ def run_xpcshell(context, **kwargs):
if not args.xpcshell:
args.xpcshell = os.path.join(args.appPath, "xpcshell")
if not args.pluginsPath:
for path in context.ancestors(args.appPath, depth=2):
test = os.path.join(path, "plugins")
if os.path.isdir(test):
args.pluginsPath = test
break
log = mozlog.commandline.setup_logging(
"XPCShellTests", args, {"mach": sys.stdout}, {"verbose": True}
)

View File

@ -215,20 +215,6 @@ class RemoteXPCShellTestThread(xpcshell.XPCShellTestThread):
self.env["XPCSHELL_TEST_TEMP_DIR"] = self.remoteTmpDir
return self.remoteTmpDir
def setupPluginsDir(self):
if not os.path.isdir(self.pluginsPath):
return None
# making sure tmp dir is set up
self.setupTempDir()
pluginsDir = posixpath.join(self.remoteTmpDir, "plugins")
self.device.push(self.pluginsPath, pluginsDir)
self.device.chmod(pluginsDir)
if self.interactive:
self.log.info("plugins dir is %s" % pluginsDir)
return pluginsDir
def setupProfileDir(self):
profileId = str(uuid.uuid4())
self.profileDir = posixpath.join(self.profileDir, profileId)

View File

@ -26,7 +26,6 @@ from argparse import Namespace
from collections import defaultdict, deque, namedtuple
from contextlib import contextmanager
from datetime import datetime, timedelta
from distutils import dir_util
from functools import partial
from multiprocessing import cpu_count
from subprocess import Popen, PIPE, STDOUT
@ -167,7 +166,6 @@ class XPCShellTestThread(Thread):
self.testingModulesDir = kwargs.get("testingModulesDir")
self.debuggerInfo = kwargs.get("debuggerInfo")
self.jsDebuggerInfo = kwargs.get("jsDebuggerInfo")
self.pluginsPath = kwargs.get("pluginsPath")
self.httpdJSPath = kwargs.get("httpdJSPath")
self.headJSPath = kwargs.get("headJSPath")
self.testharnessdir = kwargs.get("testharnessdir")
@ -481,24 +479,6 @@ class XPCShellTestThread(Thread):
self.log.info("temp dir is %s" % tempDir)
return tempDir
def setupPluginsDir(self):
if not os.path.isdir(self.pluginsPath):
return None
pluginsDir = mkdtemp(prefix="xpc-plugins-", dir=self._rootTempDir)
retries = 0
while not os.path.isdir(pluginsDir) and retries < 5:
self.log.info("plugins temp directory %s missing; waiting..." % pluginsDir)
time.sleep(1)
retries += 1
# shutil.copytree requires dst to not exist. Deleting the tempdir
# would make a race condition possible in a concurrent environment,
# so we are using dir_utils.copy_tree which accepts an existing dst
dir_util.copy_tree(self.pluginsPath, pluginsDir)
if self.interactive:
self.log.info("plugins dir is %s" % pluginsDir)
return pluginsDir
def setupProfileDir(self):
"""
Create a temporary folder for the profile and set appropriate environment variables.
@ -607,16 +587,6 @@ class XPCShellTestThread(Thread):
if self.debuggerInfo:
xpcsCmd = [self.debuggerInfo.path] + self.debuggerInfo.args + xpcsCmd
# Automation doesn't specify a pluginsPath and xpcshell defaults to
# $APPDIR/plugins. We do the same here so we can carry on with
# setting up every test with its own plugins directory.
if not self.pluginsPath:
self.pluginsPath = os.path.join(self.appPath, "plugins")
self.pluginsDir = self.setupPluginsDir()
if self.pluginsDir:
xpcsCmd.extend(["-p", self.pluginsDir])
return xpcsCmd
def cleanupDir(self, directory, name):
@ -651,9 +621,6 @@ class XPCShellTestThread(Thread):
self.cleanupDir(self.tempDir, name)
if self.pluginsDir:
self.cleanupDir(self.pluginsDir, name)
def parse_output(self, output):
"""Parses process output for structured messages and saves output as it is
read. Sets self.has_failure_output in case of evidence of a failure"""
@ -1757,7 +1724,6 @@ class XPCShellTests(object):
self.profileName = options.get("profileName") or "xpcshell"
self.mozInfo = options.get("mozInfo")
self.testingModulesDir = testingModulesDir
self.pluginsPath = options.get("pluginsPath")
self.sequential = options.get("sequential")
self.failure_manifest = options.get("failure_manifest")
self.threadCount = options.get("threadCount") or NUM_THREADS
@ -1857,7 +1823,6 @@ class XPCShellTests(object):
"testingModulesDir": self.testingModulesDir,
"debuggerInfo": self.debuggerInfo,
"jsDebuggerInfo": self.jsDebuggerInfo,
"pluginsPath": self.pluginsPath,
"httpdJSPath": self.httpdJSPath,
"headJSPath": self.headJSPath,
"tempDir": self.tempDir,

View File

@ -91,17 +91,6 @@ def add_common_arguments(parser):
default=None,
help="Directory where testing modules are located.",
)
parser.add_argument(
"--test-plugin-path",
type=str,
dest="pluginsPath",
default=None,
help="Path to the location of a plugins directory containing the "
"test plugin or plugins required for tests. "
"By default xpcshell's dir svc provider returns gre/plugins. "
"Use test-plugin-path to add a directory "
"to return for NS_APP_PLUGINS_DIR_LIST when queried.",
)
parser.add_argument(
"--total-chunks",
type=int,

View File

@ -40,7 +40,6 @@
#define NS_APP_CHROME_DIR "AChrom"
#define NS_APP_CHROME_DIR_LIST "AChromDL"
#define NS_APP_PLUGINS_DIR_LIST "APluginsDL"
// --------------------------------------------------------------------------------------
// Files and directories which exist on a per-profile basis

View File

@ -42,21 +42,10 @@
// define default product directory
#define DEFAULT_PRODUCT_DIR nsLiteralCString(MOZ_USER_DIR)
// Locally defined keys used by nsAppDirectoryEnumerator
#define NS_USER_PLUGINS_DIR "UserPlugins"
#ifdef MOZ_WIDGET_COCOA
# define NS_MACOSX_USER_PLUGIN_DIR "OSXUserPlugins"
# define NS_MACOSX_LOCAL_PLUGIN_DIR "OSXLocalPlugins"
#elif XP_UNIX
# define NS_SYSTEM_PLUGINS_DIR "SysPlugins"
#endif
#define DEFAULTS_DIR_NAME "defaults"_ns
#define DEFAULTS_PREF_DIR_NAME "pref"_ns
#define RES_DIR_NAME "res"_ns
#define CHROME_DIR_NAME "chrome"_ns
#define PLUGINS_DIR_NAME "plugins"_ns
//*****************************************************************************
// nsAppFileLocationProvider::Constructor/Destructor
@ -68,8 +57,7 @@ nsAppFileLocationProvider::nsAppFileLocationProvider() = default;
// nsAppFileLocationProvider::nsISupports
//*****************************************************************************
NS_IMPL_ISUPPORTS(nsAppFileLocationProvider, nsIDirectoryServiceProvider,
nsIDirectoryServiceProvider2)
NS_IMPL_ISUPPORTS(nsAppFileLocationProvider, nsIDirectoryServiceProvider)
//*****************************************************************************
// nsAppFileLocationProvider::nsIDirectoryServiceProvider
@ -88,11 +76,6 @@ nsAppFileLocationProvider::GetFile(const char* aProp, bool* aPersistent,
*aResult = nullptr;
*aPersistent = true;
#ifdef MOZ_WIDGET_COCOA
FSRef fileRef;
nsCOMPtr<nsILocalFileMac> macFile;
#endif
if (nsCRT::strcmp(aProp, NS_APP_APPLICATION_REGISTRY_DIR) == 0) {
rv = GetProductDirectory(getter_AddRefs(localFile));
} else if (nsCRT::strcmp(aProp, NS_APP_APPLICATION_REGISTRY_FILE) == 0) {
@ -127,56 +110,7 @@ nsAppFileLocationProvider::GetFile(const char* aProp, bool* aPersistent,
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativeNativePath(CHROME_DIR_NAME);
}
}
#ifdef MOZ_WIDGET_COCOA
else if (nsCRT::strcmp(aProp, NS_MACOSX_USER_PLUGIN_DIR) == 0) {
if (::FSFindFolder(kUserDomain, kInternetPlugInFolderType, false,
&fileRef) == noErr) {
rv = NS_NewLocalFileWithFSRef(&fileRef, true, getter_AddRefs(macFile));
if (NS_SUCCEEDED(rv)) {
localFile = macFile;
}
}
} else if (nsCRT::strcmp(aProp, NS_MACOSX_LOCAL_PLUGIN_DIR) == 0) {
if (::FSFindFolder(kLocalDomain, kInternetPlugInFolderType, false,
&fileRef) == noErr) {
rv = NS_NewLocalFileWithFSRef(&fileRef, true, getter_AddRefs(macFile));
if (NS_SUCCEEDED(rv)) {
localFile = macFile;
}
}
}
#else
else if (nsCRT::strcmp(aProp, NS_USER_PLUGINS_DIR) == 0) {
# ifdef ENABLE_SYSTEM_EXTENSION_DIRS
rv = GetProductDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME);
}
# else
rv = NS_ERROR_FAILURE;
# endif
}
# ifdef XP_UNIX
else if (nsCRT::strcmp(aProp, NS_SYSTEM_PLUGINS_DIR) == 0) {
# ifdef ENABLE_SYSTEM_EXTENSION_DIRS
static const char* const sysLPlgDir =
# if defined(HAVE_USR_LIB64_DIR) && defined(__LP64__)
"/usr/lib64/mozilla/plugins";
# elif defined(__OpenBSD__) || defined(__FreeBSD__)
"/usr/local/lib/mozilla/plugins";
# else
"/usr/lib/mozilla/plugins";
# endif
rv = NS_NewNativeLocalFile(nsDependentCString(sysLPlgDir), false,
getter_AddRefs(localFile));
# else
rv = NS_ERROR_FAILURE;
# endif
}
# endif
#endif
else if (nsCRT::strcmp(aProp, NS_APP_INSTALL_CLEANUP_DIR) == 0) {
} else if (nsCRT::strcmp(aProp, NS_APP_INSTALL_CLEANUP_DIR) == 0) {
// This is cloned so that embeddors will have a hook to override
// with their own cleanup dir. See bugzilla bug #105087
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
@ -350,7 +284,7 @@ nsresult nsAppFileLocationProvider::GetDefaultUserProfileRoot(
}
//*****************************************************************************
// nsAppFileLocationProvider::nsIDirectoryServiceProvider2
// nsAppFileLocationProvider::nsIDirectoryServiceProvider
//*****************************************************************************
class nsAppDirectoryEnumerator : public nsSimpleEnumerator {
@ -401,31 +335,3 @@ class nsAppDirectoryEnumerator : public nsSimpleEnumerator {
const char** mCurrentKey;
nsCOMPtr<nsIFile> mNext;
};
NS_IMETHODIMP
nsAppFileLocationProvider::GetFiles(const char* aProp,
nsISimpleEnumerator** aResult) {
if (NS_WARN_IF(!aResult)) {
return NS_ERROR_INVALID_ARG;
}
*aResult = nullptr;
nsresult rv = NS_ERROR_FAILURE;
if (!nsCRT::strcmp(aProp, NS_APP_PLUGINS_DIR_LIST)) {
#ifdef MOZ_WIDGET_COCOA
static const char* keys[] = {NS_MACOSX_USER_PLUGIN_DIR,
NS_MACOSX_LOCAL_PLUGIN_DIR, nullptr};
#else
# ifdef XP_UNIX
static const char* keys[] = {NS_USER_PLUGINS_DIR, NS_SYSTEM_PLUGINS_DIR,
nullptr};
# else
static const char* keys[] = {NS_USER_PLUGINS_DIR, nullptr};
# endif
#endif
*aResult = new nsAppDirectoryEnumerator(this, keys);
NS_ADDREF(*aResult);
rv = NS_OK;
}
return rv;
}

View File

@ -17,13 +17,12 @@ class nsIFile;
// class nsAppFileLocationProvider
//*****************************************************************************
class nsAppFileLocationProvider final : public nsIDirectoryServiceProvider2 {
class nsAppFileLocationProvider final : public nsIDirectoryServiceProvider {
public:
nsAppFileLocationProvider();
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIDIRECTORYSERVICEPROVIDER
NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
private:
~nsAppFileLocationProvider() = default;