Code: Select all
nsCOMPtr< nsIDocShell > docShell = do_GetInterface( mWebBrowser );
if (docShell)
{
nsIScriptGlobalObject *theGlobalObject ;
theGlobalObject = docShell->GetScriptGlobalObject();
nsIScriptContext *theScriptContext = theGlobalObject->GetContext();
nsresult rv ;
auto ctx = theScriptContext->GetNativeContext();
JS::CompileOptions options(ctx);
JS::Rooted<JSObject *> handle(ctx);
options.setFileAndLine("", 1);
rv = theScriptContext->EvaluateString(script,
handle, options, false, nullptr);
}
The program crashes while calling EvaluateString. I am unable to understand the reason. Please help.