diff --git a/xpcom/tests/TestHarness.h b/xpcom/tests/TestHarness.h index a89f42d4c91d..e5754977466e 100644 --- a/xpcom/tests/TestHarness.h +++ b/xpcom/tests/TestHarness.h @@ -26,7 +26,6 @@ #include "nsIDirectoryService.h" #include "nsIFile.h" #include "nsIObserverService.h" -#include "nsIServiceManager.h" #include "nsXULAppAPI.h" #include #include @@ -78,15 +77,14 @@ class ScopedXPCOM : public nsIDirectoryServiceProvider2 { explicit ScopedXPCOM(const char* testName, nsIDirectoryServiceProvider* dirSvcProvider = nullptr) - : mServMgr(nullptr), mDirSvcProvider(dirSvcProvider) { + : mDirSvcProvider(dirSvcProvider) { mTestName = testName; printf("Running %s tests...\n", mTestName); - nsresult rv = NS_InitXPCOM(&mServMgr, nullptr, this); - if (NS_FAILED(rv)) { + mInitRv = NS_InitXPCOM(nullptr, nullptr, this); + if (NS_FAILED(mInitRv)) { fail("NS_InitXPCOM returned failure code 0x%" PRIx32, - static_cast(rv)); - mServMgr = nullptr; + static_cast(mInitRv)); return; } } @@ -112,8 +110,7 @@ class ScopedXPCOM : public nsIDirectoryServiceProvider2 { mProfD = nullptr; } - if (mServMgr) { - NS_RELEASE(mServMgr); + if (NS_SUCCEEDED(mInitRv)) { nsresult rv = NS_ShutdownXPCOM(nullptr); if (NS_FAILED(rv)) { fail("XPCOM shutdown failed with code 0x%" PRIx32, @@ -125,7 +122,7 @@ class ScopedXPCOM : public nsIDirectoryServiceProvider2 { printf("Finished running %s tests.\n", mTestName); } - bool failed() { return mServMgr == nullptr; } + bool failed() { return NS_FAILED(mInitRv); } already_AddRefed GetProfileDirectory() { if (mProfD) { @@ -252,7 +249,7 @@ class ScopedXPCOM : public nsIDirectoryServiceProvider2 { private: const char* mTestName; - nsIServiceManager* mServMgr; + nsresult mInitRv = NS_ERROR_NOT_INITIALIZED; nsCOMPtr mDirSvcProvider; nsCOMPtr mProfD; nsCOMPtr mGRED;