Avoid calling Environment::GetCurrent for unjected contexts

It seems to cause crashes when it is called for contexts that do not
have node integrations.
This commit is contained in:
Cheng Zhao 2016-06-20 16:51:42 +09:00
parent 3428874907
commit a3dd6c635f

View file

@ -282,6 +282,11 @@ void AtomRendererClient::DidCreateScriptContext(
void AtomRendererClient::WillReleaseScriptContext(
v8::Handle<v8::Context> context, content::RenderFrame* render_frame) {
// Only allow node integration for the main frame, unless it is a devtools
// extension page.
if (!render_frame->IsMainFrame() && !IsDevToolsExtension(render_frame))
return;
node::Environment* env = node::Environment::GetCurrent(context);
if (env)
mate::EmitEvent(env->isolate(), env->process_object(), "exit");