From e53d4e3446993a756fce7b69cd5aa6317c19165a Mon Sep 17 00:00:00 2001 From: "yurys@google.com" Date: Mon, 18 May 2009 16:50:04 +0000 Subject: DevTools: utility scripts and all other scripts not having context data are filtered out on the agent side. Review URL: http://codereview.chromium.org/115466 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16288 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/glue/devtools/debugger_agent_manager.cc | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/webkit/glue/devtools/debugger_agent_manager.cc b/webkit/glue/devtools/debugger_agent_manager.cc index aa96ec8..47af450 100644 --- a/webkit/glue/devtools/debugger_agent_manager.cc +++ b/webkit/glue/devtools/debugger_agent_manager.cc @@ -167,6 +167,41 @@ void DebuggerAgentManager::OnV8DebugMessage(const v8::Debug::Message& message) { } // Otherwise it's an event message. DCHECK(message.IsEvent()); + // Filter out events from the utility context. + // TODO(yurys): add global context accessor to v8 API. + if (message.GetEvent() == v8::AfterCompile) { + // Note that message.GetEventContext() will return context active when we + // entered the debugger. It's not necessarily the global context where the + // script is compiled so to get the scripts' context we call JS methods on + // the event data. + v8::Handle compileEvent = message.GetEventData(); + v8::Handle scriptGetter = + compileEvent->Get(v8::String::New("script")); + v8::Local fun = v8::Function::Cast(*scriptGetter); + v8::Local script_mirror = + v8::Object::Cast(*fun->Call(compileEvent, 0, NULL)); + + v8::Handle contextGetter = + script_mirror->Get(v8::String::New("context")); + v8::Local contextGetterFunc = + v8::Function::Cast(*contextGetter); + v8::Local context_mirror = + v8::Object::Cast(*contextGetterFunc->Call(script_mirror, 0, NULL)); + + v8::Handle dataGetter = + context_mirror->Get(v8::String::New("data")); + v8::Local dataGetterFunc = + v8::Function::Cast(*dataGetter); + v8::Local data = + *dataGetterFunc->Call(context_mirror, 0, NULL); + + // If the context is from one of the inpected tabs it must have host_id in + // the data field. See DebuggerAgentManager::SetHostId for more details. + if (data.IsEmpty() || !data->IsInt32()) { + return; + } + } + // Agent that should be used for sending events is determined based // on the active Frame. DebuggerAgentImpl* agent = FindAgentForCurrentV8Context(); @@ -179,6 +214,7 @@ void DebuggerAgentManager::OnV8DebugMessage(const v8::Debug::Message& message) { } } + // static void DebuggerAgentManager::ExecuteDebuggerCommand( const std::string& command, -- cgit v1.1