Skip to content

Commit

Permalink
Properly find Frame from Node context
Browse files Browse the repository at this point in the history
or debug callback can't get the listener.
Fix nwjs/nw.js#719

#0  WebCore::InspectorDebuggerAgent::didPause (this=0x7ffff7ee8800,
    scriptState=0x192e07eebb10, callFrames=..., exception=...)
    at ../../third_party/WebKit/Source/core/inspector/InspectorDebuggerAgent.cpp:682
#1  0x0000000003665f7e in WebCore::ScriptDebugServer::breakProgram (
    this=0x7ffff7ee8260, executionState=..., exception=...)
    at ../../third_party/WebKit/Source/bindings/v8/ScriptDebugServer.cpp:425
#2  0x0000000003666ceb in WebCore::ScriptDebugServer::handleV8DebugEvent (
    this=0x7ffff7ee8260, eventDetails=...)
    at ../../third_party/WebKit/Source/bindings/v8/ScriptDebugServer.cpp:503
#3  0x0000000003666012 in WebCore::ScriptDebugServer::v8DebugEventCallback (
    eventDetails=...)
    at ../../third_party/WebKit/Source/bindings/v8/ScriptDebugServer.cpp:435
#4  0x0000000000f7ecb3 in v8::internal::Debugger::CallCEventCallback (
    this=0x7ffff7eec520, event=v8::Break, exec_state=..., event_data=...,
    client_data=0x0) at ../../v8/src/debug.cc:2953
#5  0x0000000000f7ebf9 in v8::internal::Debugger::CallEventCallback (
    this=0x7ffff7eec520, event=v8::Break, exec_state=..., event_data=...,
    client_data=0x0) at ../../v8/src/debug.cc:2932
#6  0x0000000000f7eabd in v8::internal::Debugger::ProcessDebugEvent (
    this=0x7ffff7eec520, event=v8::Break, event_data=..., auto_continue=false)
    at ../../v8/src/debug.cc:2909
#7  0x0000000000f7e24d in v8::internal::Debugger::OnDebugBreak (
    this=0x7ffff7eec520, break_points_hit=..., auto_continue=false)
    at ../../v8/src/debug.cc:2750
#8  0x0000000000f7836f in v8::internal::Debug::Break (this=0x7ffff7eecc20,
    args=...) at ../../v8/src/debug.cc:992
#9  0x0000000000f787a8 in v8::internal::__RT_impl_Debug_Break (args=...,
    isolate=0x7ffff7e80020) at ../../v8/src/debug.cc:1062
#10 0x0000000000f78769 in v8::internal::Debug_Break (args_length=0,
    args_object=0x7fffffff8248, isolate=0x7ffff7e80020)
    at ../../v8/src/debug.cc:1061
  • Loading branch information
rogerwang committed Sep 21, 2013
1 parent ae3aef6 commit ee752dc
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions Source/bindings/v8/PageScriptDebugServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@

namespace WebCore {

static Frame* retrieveFrameWithNodeContext(v8::Handle<v8::Context> context)
{
v8::HandleScope handle_scope;

v8::Context::Scope context_scope(node::g_context);
v8::Handle<v8::Object> global = node::g_context->Global();
v8::Local<v8::Value> val_window = global->Get(v8::String::New("window"));
if (val_window->IsUndefined())
return 0;
v8::Local<v8::Object> window = v8::Local<v8::Object>::Cast(val_window);
global = window->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate(), worldTypeInMainThread(context->GetIsolate())));
if (global.IsEmpty())
return 0;
DOMWindow* win = V8DOMWindow::toNative(global);
if (!win)
return 0;
return win->frame();
}

static Frame* retrieveFrameWithGlobalObjectCheck(v8::Handle<v8::Context> context)
{
if (context.IsEmpty())
Expand All @@ -60,25 +79,12 @@ static Frame* retrieveFrameWithGlobalObjectCheck(v8::Handle<v8::Context> context
v8::HandleScope handle_scope;
// Test that context has associated global dom window object.
v8::Handle<v8::Object> global = context->Global();
if (global.IsEmpty()) {
v8::Context::Scope context_scope(node::g_context);
global = node::g_context->Global();
v8::Local<v8::Value> val_window = global->Get(v8::String::New("window"));
if (val_window->IsUndefined())
return 0;
v8::Local<v8::Object> window = v8::Local<v8::Object>::Cast(val_window);
global = window->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(context->GetIsolate(), worldTypeInMainThread(context->GetIsolate())));
if (global.IsEmpty())
return 0;
DOMWindow* win = V8DOMWindow::toNative(global);
if (!win)
return 0;
return win->frame();
}
if (global.IsEmpty())
return retrieveFrameWithNodeContext(context);

global = global->FindInstanceInPrototypeChain(V8Window::GetTemplate(context->GetIsolate(), worldTypeInMainThread(context->GetIsolate())));
if (global.IsEmpty())
return 0;
return retrieveFrameWithNodeContext(context);

return toFrameIfNotDetached(context);
}
Expand Down

0 comments on commit ee752dc

Please sign in to comment.