Calling JSAPI directly from C++ addon code is extremely dangerous. You should stop doing it! I can provide advice on alternative mechanisms to do whatever you're trying to accomplish.
The crash is probably related to the lack of an nsCxPusher here. See the discussion in bug 911161. If you go that route, note that you'll have to recompile your addon with every release. bholley On Wed, Sep 18, 2013 at 9:36 PM, <vasuyadavkri...@gmail.com> wrote: > Hi > > We are facing problem with our Add-ons support for FireFox 24.Firefox is > crashing. In earlier approach we was using 'JS_GetGlobalObject' to get global > object from docShell. > https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_GetGlobalObject?redirectlocale=en-US&redirectslug=SpiderMonkey%2FJSAPI_Reference%2FJS_GetGlobalObject > > As per given above link- I should use use JS_GetGlobalForObject or > JS_GetGlobalForScopeChain instead of JS_GetGlobalObject. I tried both of them > and additionally I tried GetNativeGlobal(), GetGlobalJSObject() . but none of > them work out. Firefox is crashing in all the cases . > > Could anybody help me for this issue? what are required changes need to fix > this problem. I have paste code for yours reference. > > > > bool CFFGBrowser::GetJSGlobalContextAndWindow(nsIDocShell *docShell, > JSContext **jsContext, > > jsval &window) > > { > > bool isSuccess = false; > > nsresult rv; > > > do > > { > > nsCOMPtr< nsIScriptGlobalObject > scriptObj = do_GetInterface( docShell, &rv > ); > > > if( NS_FAILED( rv ) ) > > { > > break; > > } > > nsCOMPtr< nsIScriptContext > scriptContext = scriptObj->GetContext(); > > if ( !scriptContext ) > > { > > break; > > } > > *jsContext = static_cast<JSContext*>( scriptContext->GetNativeContext()); > > //JSObject *globalObj1 = scriptContext->GetNativeGlobal(); > > JSObject *globalObj = scriptObj->GetGlobalJSObject(); > > CLogFile::Info(111, "CFFGBrowser::GetJSGlobalContextAndObject -start...3.2."); > > //JSObject *globalObj = JS_GetArrayPrototype(*jsContext,globalObj1); > > //JS::Rooted<JSObject*> globalObj(*jsContext, > JS_GetGlobalForScopeChain(*jsContext)); > > //JS::RootedObject*globalObj =static_cast<JSObject*>( > scriptContext->GetNativeGlobal()); > > //JSObject *globalObj2 = JS_GetGlobalForScopeChain(*jsContext); > > > > //JSObject *globalObj3 = JS_GetGlobalForObject(*jsContext,globalObj2); > > //JSObject *globalObj = JS_GetGlobalForScopeChain(scriptContext); > > if ( !jsContext ) > > { > > break; > > } > > > if (!globalObj ) > > { > > break; > > } > > JSBool isSucceeded = JS_GetProperty( *jsContext, globalObj, "window", &window > ); > > if ( ( isSucceeded != JS_TRUE ) || ( window == JSVAL_VOID ) ) > > { > > break; > > } > > jsval jsargs[1]; > //jsval jscaptureSSLText = JSVAL_NULL, rval = JSVAL_NULL; > jsval rval = JSVAL_NULL; > jsargs[0] = INT_TO_JSVAL(0); > //JS::HandleValue captureSSLVal = JS::RootedValue(jsContext, > jscaptureSSLText); > JS::RootedValue captureSSLVal(*jsContext, jsargs[0]); > JS::RootedValue windowVal(*jsContext, window); > JS::RootedObject windowObj (*jsContext, JSVAL_TO_OBJECT(window)); > //JS_CallFunctionName > JSBool isSucceededd = JS_CallFunctionName(*jsContext, > globalObj, > "KeynoteCaptureSSLText", > 1, > jsargs, > &rval); > isSuccess = true; > > }while(false); > > return isSuccess; > > } > > > > Regards > > Vasu > > > > > _______________________________________________ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform