Subj : javascript: from xul/html .vs. xpcshell ! not the same behavior.... :(
To : netscape.public.mozilla.xpcom,netscape.public.dev.xml,netscape.public.mozilla.jseng
From : jmp
Date : Wed Aug 11 2004 03:28 pm
Gurus,
I wrote an XPCOM component (in c++) that at some point loads an XML
document using nsIDOMXMLDocument interface.
When this XPCOM component is instanciated from a XUL dialog, it beahaves as expected...
If I write some javascript and try to get the same thing from xpcshell, it fails
lamentably.
I have tracked this down to the following call, where it fails
in the call to JS_GetScriptPrincipals().
The "shouldn't happen" case DO HAPPEN !!!!
I have tried with build from Mozilla 1.4.2 and from mozilla 1.7.2. Same behavior!!!!
has anyone here any ideas ????
nsresult nsScriptSecurityManager::GetScriptPrincipal(JSContext *cx,
JSScript *script,
nsIPrincipal **result)
{
if (!script)
{
*result = nsnull;
return NS_OK;
}
JSPrincipals *jsp = JS_GetScriptPrincipals(cx, script);
if (!jsp) {
// Script didn't have principals -- shouldn't happen.
return NS_ERROR_FAILURE;
}
nsJSPrincipals *nsJSPrin = NS_STATIC_CAST(nsJSPrincipals *, jsp);
*result = nsJSPrin->nsIPrincipalPtr;
if (!*result)
return NS_ERROR_FAILURE;
NS_ADDREF(*result);
return NS_OK;
}
Thanks
JM
.