Grant Gayed
unread,Aug 28, 2013, 1:53:44 PM8/28/13You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Hi all,
The SWT Browser's embedding of XULRunner uses
JS_EvaluateUCScriptForPrincipals() to evaluate arbitrary JS code in the
context of a loaded page. This invocation is preceded by a
nsIJSContextStack.Push() call to push the JSContext.
As of XULRunner 23 the nsIJSContextStack interface is gone, so I tried
to just remove our Push() invocation (testing against XULRunner 24b2),
and the JS_EvaluateUCScriptForPrincipals() call now crashes in
ScriptSourceObject::create()'s invocation of cx->global(), because the
JSContext's compartment() resolves to 0.
My question is, does the JSContext's compartment() == 0 indicate that
not pushing the JSContext is likely the underlying problem? And if so,
what is the new way of doing this? I notice within mozilla code the use
of AutoPushJSContext, but this is not exported for use by embedders.
Or, if compartment() == 0 does not necessarily point at the JSContext
not being pushed, does anything in the following sequence seem
particularly wrong?
securityManager = serviceManager.getByContractID(ScriptSecurityManager)
principal = securityManager.getSystemPrincipal()
sgo =
webBrowser.QI(nsIInterfaceRequestor).getInterface(nsIScriptGlobalObject)
sgo.EnsureScriptEnvironment()
scriptContext = sgo.getScriptContext()
jsContext = scriptContext.GetNativeContext()
jsPrincipals = principal.getJSPrincipals()
globalJSObject = sgo.GetGlobalJSObject()
JS_EvaluateUCScriptForPrincipals(jsContext, globalJSObject,
jsPrincipals, ...)
Thank-you in advance,
Grant