diff options
author | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 16:50:04 +0000 |
---|---|---|
committer | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 16:50:04 +0000 |
commit | e53d4e3446993a756fce7b69cd5aa6317c19165a (patch) | |
tree | 163bb545fce45d33da2c012281a60cd000a5ad73 | |
parent | d16659fd251cabdfdbf456ab8a8e8aafdab410b3 (diff) | |
download | chromium_src-e53d4e3446993a756fce7b69cd5aa6317c19165a.zip chromium_src-e53d4e3446993a756fce7b69cd5aa6317c19165a.tar.gz chromium_src-e53d4e3446993a756fce7b69cd5aa6317c19165a.tar.bz2 |
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
-rw-r--r-- | webkit/glue/devtools/debugger_agent_manager.cc | 36 |
1 files changed, 36 insertions, 0 deletions
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<v8::Object> compileEvent = message.GetEventData(); + v8::Handle<v8::Value> scriptGetter = + compileEvent->Get(v8::String::New("script")); + v8::Local<v8::Function> fun = v8::Function::Cast(*scriptGetter); + v8::Local<v8::Object> script_mirror = + v8::Object::Cast(*fun->Call(compileEvent, 0, NULL)); + + v8::Handle<v8::Value> contextGetter = + script_mirror->Get(v8::String::New("context")); + v8::Local<v8::Function> contextGetterFunc = + v8::Function::Cast(*contextGetter); + v8::Local<v8::Object> context_mirror = + v8::Object::Cast(*contextGetterFunc->Call(script_mirror, 0, NULL)); + + v8::Handle<v8::Value> dataGetter = + context_mirror->Get(v8::String::New("data")); + v8::Local<v8::Function> dataGetterFunc = + v8::Function::Cast(*dataGetter); + v8::Local<v8::Value> 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, |