bug 1114882 - allow nsICryptoHash to be used in a content process r=mayhemer

This commit is contained in:
David Keeler 2015-01-16 11:59:25 -08:00
parent d5431fa313
commit fae1a9756b
5 changed files with 17 additions and 3 deletions

View File

@ -157,6 +157,7 @@ bool EnsureNSSInitialized(EnsureNSSOperator op)
// call do_GetService for nss component to ensure it.
case nssEnsure:
case nssEnsureOnChromeOnly:
case nssEnsureChromeOrContent:
// We are reentered during nss component creation or nss component is already up
if (PR_AtomicAdd(&haveLoaded, 0) || loading)
return true;

View File

@ -55,7 +55,8 @@ enum EnsureNSSOperator
nssInitFailed = 2,
nssShutdown = 3,
nssEnsure = 100,
nssEnsureOnChromeOnly = 101
nssEnsureOnChromeOnly = 101,
nssEnsureChromeOrContent = 102,
};
extern bool EnsureNSSInitializedChromeOrContent();

View File

@ -93,8 +93,14 @@ _InstanceClassChrome##Constructor(nsISupports *aOuter, REFNSIID aIID, \
return rv; \
} \
\
if (!EnsureNSSInitialized(ensureOperator)) \
if (!NS_IS_PROCESS_DEFAULT && \
ensureOperator == nssEnsureChromeOrContent) { \
if (!EnsureNSSInitializedChromeOrContent()) { \
return NS_ERROR_FAILURE; \
} \
} else if (!EnsureNSSInitialized(ensureOperator)) { \
return NS_ERROR_FAILURE; \
} \
\
if (NS_IS_PROCESS_DEFAULT) \
NS_NSS_INSTANTIATE(ensureOperator, _InstanceClassChrome); \
@ -193,7 +199,7 @@ NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsure, nsCertTree)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsure, nsPkcs11)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsure, nsCertPicker)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nssEnsure, nsNTLMAuthModule, InitTest)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsure, nsCryptoHash)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsureChromeOrContent, nsCryptoHash)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsure, nsCryptoHMAC)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsure, nsStreamCipher)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsure, nsKeyObject)

View File

@ -0,0 +1,3 @@
function run_test() {
run_test_in_child("test_hash_algorithms.js");
}

View File

@ -22,6 +22,9 @@ support-files =
[test_datasignatureverifier.js]
[test_hash_algorithms.js]
[test_hash_algorithms_wrap.js]
# bug 1124289 - run_test_in_child violates the sandbox on b2g
skip-if = toolkit == 'gonk'
[test_hmac.js]
[test_sts_preloadlist_perwindowpb.js]