diff --git a/security/manager/ssl/src/nsCrypto.cpp b/security/manager/ssl/src/nsCrypto.cpp index f36f1138ca9..caae70dfb78 100644 --- a/security/manager/ssl/src/nsCrypto.cpp +++ b/security/manager/ssl/src/nsCrypto.cpp @@ -373,9 +373,13 @@ nsCrypto::GetScriptPrincipal(JSContext *cx) } } - if (!principal) { - nsCOMPtr scriptContext = - NS_REINTERPRET_CAST(nsIScriptContext*,JS_GetContextPrivate(cx)); + if (principal) + return principal; + + if (JS_GetOptions(cx) & JSOPTION_PRIVATE_IS_NSISUPPORTS) { + nsISupports* scriptContextSupports = + NS_STATIC_CAST(nsISupports*, JS_GetContextPrivate(cx)); + nsCOMPtr scriptContext(do_QueryInterface(scriptContextSupports)); if (scriptContext) { nsCOMPtr global;