Grant Gayed
未讀,2013年8月28日 下午1:53:442013/8/28你的權限不足,無法在這個群組刪除訊息
該群組的電子郵件地址為匿名,或你需要檢視成員電子郵件地址的權限才能查看原始貼文
收件者:
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