diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/base/test/unit/test_chromeutils_getXPCOMErrorName.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/unit/test_chromeutils_getXPCOMErrorName.js')
-rw-r--r-- | dom/base/test/unit/test_chromeutils_getXPCOMErrorName.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/dom/base/test/unit/test_chromeutils_getXPCOMErrorName.js b/dom/base/test/unit/test_chromeutils_getXPCOMErrorName.js new file mode 100644 index 0000000000..f7d6a89e71 --- /dev/null +++ b/dom/base/test/unit/test_chromeutils_getXPCOMErrorName.js @@ -0,0 +1,40 @@ +"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" + ); +}); |