Add-ons Firefox 24 crash -may be due to recent change in JSAPI.

23 views
Skip to first unread message

Vasu Yadav

unread,
Sep 18, 2013, 11:33:24 AM9/18/13
to mozill...@googlegroups.com

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

 

 

Reply all
Reply to author
Forward
0 new messages