From 1b759d112f1d643cfcdc27839cbd8a2b905569c2 Mon Sep 17 00:00:00 2001 From: Norisz Fay Date: Thu, 9 Dec 2021 12:44:14 +0200 Subject: [PATCH] Backed out changeset 4628f9ff25a5 (bug 1740543) for causing build bustages on ErrorNames CLOSED TREE --- dom/base/ChromeUtils.cpp | 7 ---- dom/base/ChromeUtils.h | 3 -- .../test_chromeutils_getXPCOMErrorName.js | 40 ------------------- dom/base/test/unit/xpcshell.ini | 1 - dom/chrome-webidl/ChromeUtils.webidl | 6 --- xpcom/base/ErrorNames.cpp | 2 +- 6 files changed, 1 insertion(+), 58 deletions(-) delete mode 100644 dom/base/test/unit/test_chromeutils_getXPCOMErrorName.js diff --git a/dom/base/ChromeUtils.cpp b/dom/base/ChromeUtils.cpp index 9632c355b193..b7d22364e3ef 100644 --- a/dom/base/ChromeUtils.cpp +++ b/dom/base/ChromeUtils.cpp @@ -16,7 +16,6 @@ #include "mozilla/Base64.h" #include "mozilla/CycleCollectedJSRuntime.h" -#include "mozilla/ErrorNames.h" #include "mozilla/EventStateManager.h" #include "mozilla/IntentionalCrash.h" #include "mozilla/PerformanceMetricsCollector.h" @@ -291,12 +290,6 @@ void ChromeUtils::AddProfilerMarker( } } -/* static */ -void ChromeUtils::GetXPCOMErrorName(GlobalObject& aGlobal, uint32_t aErrorCode, - nsACString& aRetval) { - GetErrorName((nsresult)aErrorCode, aRetval); -} - /* static */ void ChromeUtils::WaiveXrays(GlobalObject& aGlobal, JS::HandleValue aVal, JS::MutableHandleValue aRetval, ErrorResult& aRv) { diff --git a/dom/base/ChromeUtils.h b/dom/base/ChromeUtils.h index 47435e516a00..4de8d799a9cb 100644 --- a/dom/base/ChromeUtils.h +++ b/dom/base/ChromeUtils.h @@ -88,9 +88,6 @@ class ChromeUtils { const ProfilerMarkerOptionsOrDouble& aOptions, const Optional& text); - static void GetXPCOMErrorName(GlobalObject& aGlobal, uint32_t aErrorCode, - nsACString& aRetval); - static void OriginAttributesToSuffix( GlobalObject& aGlobal, const dom::OriginAttributesDictionary& aAttrs, nsCString& aSuffix); diff --git a/dom/base/test/unit/test_chromeutils_getXPCOMErrorName.js b/dom/base/test/unit/test_chromeutils_getXPCOMErrorName.js deleted file mode 100644 index f7d6a89e7187..000000000000 --- a/dom/base/test/unit/test_chromeutils_getXPCOMErrorName.js +++ /dev/null @@ -1,40 +0,0 @@ -"use strict"; - -// Test ChromeUtils.getXPCOMErrorName - -add_task(function test_getXPCOMErrorName() { - info("Force the initialization of NSS to get the error names right"); - Cc["@mozilla.org/psm;1"].getService(Ci.nsISupports); - - Assert.equal( - ChromeUtils.getXPCOMErrorName(Cr.NS_OK), - "NS_OK", - "getXPCOMErrorName works for NS_OK" - ); - - Assert.equal( - ChromeUtils.getXPCOMErrorName(Cr.NS_ERROR_FAILURE), - "NS_ERROR_FAILURE", - "getXPCOMErrorName works for NS_ERROR_FAILURE" - ); - - const nssErrors = Cc["@mozilla.org/nss_errors_service;1"].getService( - Ci.nsINSSErrorsService - ); - Assert.equal( - ChromeUtils.getXPCOMErrorName( - nssErrors.getXPCOMFromNSSError(Ci.nsINSSErrorsService.NSS_SEC_ERROR_BASE) - ), - "NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SECURITY, SEC_ERROR_IO)", - "getXPCOMErrorName works for NSS_SEC_ERROR_BASE" - ); - // See https://searchfox.org/mozilla-central/rev/a48e21143960b383004afa9ff9411c5cf6d5a958/security/nss/lib/util/secerr.h#20 - const SEC_ERROR_BAD_DATA = Ci.nsINSSErrorsService.NSS_SEC_ERROR_BASE + 2; - Assert.equal( - ChromeUtils.getXPCOMErrorName( - nssErrors.getXPCOMFromNSSError(SEC_ERROR_BAD_DATA) - ), - "NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SECURITY, SEC_ERROR_BAD_DATA)", - "getXPCOMErrorName works for NSS's SEC_ERROR_BAD_DATA" - ); -}); diff --git a/dom/base/test/unit/xpcshell.ini b/dom/base/test/unit/xpcshell.ini index 2301fb041a9a..d54bc903ae8b 100644 --- a/dom/base/test/unit/xpcshell.ini +++ b/dom/base/test/unit/xpcshell.ini @@ -54,7 +54,6 @@ head = head_xml.js [test_xmlserializer.js] [test_cancelPrefetch.js] [test_chromeutils_base64.js] -[test_chromeutils_getXPCOMErrorName.js] [test_chromeutils_shallowclone.js] [test_generate_xpath.js] head = head_xml.js diff --git a/dom/chrome-webidl/ChromeUtils.webidl b/dom/chrome-webidl/ChromeUtils.webidl index 7dd0af307f74..dfa3b343f1b2 100644 --- a/dom/chrome-webidl/ChromeUtils.webidl +++ b/dom/chrome-webidl/ChromeUtils.webidl @@ -233,12 +233,6 @@ namespace ChromeUtils { optional (ProfilerMarkerOptions or DOMHighResTimeStamp) options = {}, optional UTF8String text); - /** - * Return the symbolic name of any given XPCOM error code (nsresult): - * "NS_OK", "NS_ERROR_FAILURE",... - */ - UTF8String getXPCOMErrorName(unsigned long aErrorCode); - /** * IF YOU ADD NEW METHODS HERE, MAKE SURE THEY ARE THREAD-SAFE. */ diff --git a/xpcom/base/ErrorNames.cpp b/xpcom/base/ErrorNames.cpp index 663fd6823ff0..c1540d4bd333 100644 --- a/xpcom/base/ErrorNames.cpp +++ b/xpcom/base/ErrorNames.cpp @@ -47,7 +47,7 @@ void GetErrorName(nsresult rv, nsACString& name) { name.AppendLiteral(", "); const char* nsprName = nullptr; - if (isSecurityError && NS_IsMainThread()) { + if (isSecurityError) { // Invert the logic from NSSErrorsService::GetXPCOMFromNSSError PRErrorCode nsprCode = -1 * static_cast(NS_ERROR_GET_CODE(rv)); nsprName = PR_ErrorToName(nsprCode);