From a546daf2d84ba6db03023ad47e9e2105b8a85240 Mon Sep 17 00:00:00 2001 From: Robert Longson Date: Mon, 24 Oct 2022 18:56:41 +0000 Subject: [PATCH] Bug 1795568 Part 1 - Remove plugin support code r=emilio Differential Revision: https://phabricator.services.mozilla.com/D159465 --- js/xpconnect/src/XPCShellImpl.cpp | 44 -------- .../configs/android/android_common.py | 1 - .../configs/unittests/linux_unittest.py | 1 - .../configs/unittests/mac_unittest.py | 1 - .../configs/unittests/win_unittest.py | 1 - .../mozharness/scripts/desktop_unittest.py | 4 - testing/xpcshell/mach_commands.py | 3 - .../xpcshell/mach_test_package_commands.py | 7 -- testing/xpcshell/remotexpcshelltests.py | 14 --- testing/xpcshell/runxpcshelltests.py | 35 ------ testing/xpcshell/xpcshellcommandline.py | 11 -- xpcom/io/nsAppDirectoryServiceDefs.h | 1 - xpcom/io/nsAppFileLocationProvider.cpp | 100 +----------------- xpcom/io/nsAppFileLocationProvider.h | 3 +- 14 files changed, 4 insertions(+), 222 deletions(-) diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index 8b97e2e10a3c..b8ad4ed46222 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -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 mGREDir; nsCOMPtr mGREBinDir; nsCOMPtr mAppDir; - nsCOMPtr mPluginDir; nsCOMPtr 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 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 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 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; } diff --git a/testing/mozharness/configs/android/android_common.py b/testing/mozharness/configs/android/android_common.py index ac3dd2f2dab5..a278920056e0 100644 --- a/testing/mozharness/configs/android/android_common.py +++ b/testing/mozharness/configs/android/android_common.py @@ -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", diff --git a/testing/mozharness/configs/unittests/linux_unittest.py b/testing/mozharness/configs/unittests/linux_unittest.py index 1c86e45d73f3..6383331448e1 100644 --- a/testing/mozharness/configs/unittests/linux_unittest.py +++ b/testing/mozharness/configs/unittests/linux_unittest.py @@ -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", diff --git a/testing/mozharness/configs/unittests/mac_unittest.py b/testing/mozharness/configs/unittests/mac_unittest.py index e857eb9d2021..bb06dfb8a685 100644 --- a/testing/mozharness/configs/unittests/mac_unittest.py +++ b/testing/mozharness/configs/unittests/mac_unittest.py @@ -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", diff --git a/testing/mozharness/configs/unittests/win_unittest.py b/testing/mozharness/configs/unittests/win_unittest.py index 8e4a83c17b19..c5afbfc972b1 100644 --- a/testing/mozharness/configs/unittests/win_unittest.py +++ b/testing/mozharness/configs/unittests/win_unittest.py @@ -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", diff --git a/testing/mozharness/scripts/desktop_unittest.py b/testing/mozharness/scripts/desktop_unittest.py index 760001b6deed..2257123aad0c 100755 --- a/testing/mozharness/scripts/desktop_unittest.py +++ b/testing/mozharness/scripts/desktop_unittest.py @@ -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!") diff --git a/testing/xpcshell/mach_commands.py b/testing/xpcshell/mach_commands.py index 87f713e8a81a..4489e7010abd 100644 --- a/testing/xpcshell/mach_commands.py +++ b/testing/xpcshell/mach_commands.py @@ -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") diff --git a/testing/xpcshell/mach_test_package_commands.py b/testing/xpcshell/mach_test_package_commands.py index 89c9deb8b279..16e25c7af7d7 100644 --- a/testing/xpcshell/mach_test_package_commands.py +++ b/testing/xpcshell/mach_test_package_commands.py @@ -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} ) diff --git a/testing/xpcshell/remotexpcshelltests.py b/testing/xpcshell/remotexpcshelltests.py index 1f5b316cb9f7..93e04a23f5d7 100644 --- a/testing/xpcshell/remotexpcshelltests.py +++ b/testing/xpcshell/remotexpcshelltests.py @@ -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) diff --git a/testing/xpcshell/runxpcshelltests.py b/testing/xpcshell/runxpcshelltests.py index 2f052c9b37f0..315844893023 100755 --- a/testing/xpcshell/runxpcshelltests.py +++ b/testing/xpcshell/runxpcshelltests.py @@ -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, diff --git a/testing/xpcshell/xpcshellcommandline.py b/testing/xpcshell/xpcshellcommandline.py index 48cbfccd88cc..52be7b0d5549 100644 --- a/testing/xpcshell/xpcshellcommandline.py +++ b/testing/xpcshell/xpcshellcommandline.py @@ -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, diff --git a/xpcom/io/nsAppDirectoryServiceDefs.h b/xpcom/io/nsAppDirectoryServiceDefs.h index e71a6bd72abe..5531bc83308b 100644 --- a/xpcom/io/nsAppDirectoryServiceDefs.h +++ b/xpcom/io/nsAppDirectoryServiceDefs.h @@ -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 diff --git a/xpcom/io/nsAppFileLocationProvider.cpp b/xpcom/io/nsAppFileLocationProvider.cpp index ef974f99048f..19ca2fb6efed 100644 --- a/xpcom/io/nsAppFileLocationProvider.cpp +++ b/xpcom/io/nsAppFileLocationProvider.cpp @@ -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 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 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; -} diff --git a/xpcom/io/nsAppFileLocationProvider.h b/xpcom/io/nsAppFileLocationProvider.h index 559620cc5893..d2fd9cf65132 100644 --- a/xpcom/io/nsAppFileLocationProvider.h +++ b/xpcom/io/nsAppFileLocationProvider.h @@ -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;