Bug 168316 - When calling from Java into JS, add a "dummy" JS stack frame with

principal information for the security manager. r=dveditz, sr=jst, a=chofmann.


git-svn-id: svn://10.0.0.236/trunk@132679 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mstoltz%netscape.com
2002-10-30 03:15:59 +00:00
parent d00fdf43c7
commit 51f2a63b0c
4 changed files with 205 additions and 43 deletions

View File

@@ -1753,6 +1753,28 @@ nsScriptSecurityManager::GetCodebasePrincipal(nsIURI *aURI,
return NS_OK;
}
nsresult
nsScriptSecurityManager::GetPrincipalFromContext(JSContext *cx,
nsIPrincipal **result)
{
*result = nsnull;
NS_ENSURE_TRUE(::JS_GetOptions(cx) & JSOPTION_PRIVATE_IS_NSISUPPORTS,
NS_ERROR_FAILURE);
nsISupports* scriptContextSupports =
NS_REINTERPRET_CAST(nsISupports*, JS_GetContextPrivate(cx));
nsCOMPtr<nsIScriptContext> scriptContext(do_QueryInterface(scriptContextSupports));
if (scriptContext)
{
nsCOMPtr<nsIScriptGlobalObject> global;
scriptContext->GetGlobalObject(getter_AddRefs(global));
nsCOMPtr<nsIScriptObjectPrincipal> globalData(do_QueryInterface(global));
if (globalData)
globalData->GetPrincipal(result);
}
return NS_OK;
}
nsresult
nsScriptSecurityManager::GetScriptPrincipal(JSContext *cx,
JSScript *script,