From 7207968177735021f46892b121a97a2e03186a1d Mon Sep 17 00:00:00 2001 From: Cong Liu Date: Fri, 6 Feb 2015 23:25:10 +0800 Subject: [PATCH] Fix of uncaughtException should not catch browser exception --- Source/bindings/core/v8/V8Initializer.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/bindings/core/v8/V8Initializer.cpp b/Source/bindings/core/v8/V8Initializer.cpp index fdbcf33030c..abf42677a7d 100644 --- a/Source/bindings/core/v8/V8Initializer.cpp +++ b/Source/bindings/core/v8/V8Initializer.cpp @@ -153,18 +153,24 @@ static void messageHandlerInMainThread(v8::Handle message, v8::Hand } // If called during context initialization, there will be no entered window. LocalDOMWindow* enteredWindow = enteredDOMWindow(isolate); - if (enteredWindow) { - Frame* frame = enteredWindow->document()->frame(); - if (frame && frame->isNodeJS()) { + // pass messages to node only if the object is created from node context + if (data->IsObject() && data->ToObject()->CreationContext() == node::g_context) { + if (enteredWindow) { + Frame* frame = enteredWindow->document()->frame(); + if (frame && frame->isNodeJS()) { + v8::Local node_context = + v8::Local::New(isolate, node::g_context); + node_context->Enter(); + node::OnMessage(message, data); + node_context->Exit(); + } + } else { v8::Local node_context = v8::Local::New(isolate, node::g_context); node_context->Enter(); node::OnMessage(message, data); node_context->Exit(); } - } else { - node::OnMessage(message, data); - return; } if (!enteredWindow || !enteredWindow->isCurrentlyDisplayedInFrame())