summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--webkit/glue/devtools/debugger_agent_impl.cc22
-rw-r--r--webkit/glue/devtools/debugger_agent_impl.h5
-rw-r--r--webkit/glue/devtools/js/devtools.js4
-rw-r--r--webkit/glue/devtools/tools_agent.h3
-rw-r--r--webkit/glue/webdevtoolsagent_impl.cc21
5 files changed, 38 insertions, 17 deletions
diff --git a/webkit/glue/devtools/debugger_agent_impl.cc b/webkit/glue/devtools/debugger_agent_impl.cc
index dd40b002..41ee6d1 100644
--- a/webkit/glue/devtools/debugger_agent_impl.cc
+++ b/webkit/glue/devtools/debugger_agent_impl.cc
@@ -29,6 +29,7 @@
using WebCore::DOMWindow;
using WebCore::Document;
+using WebCore::Frame;
using WebCore::Node;
using WebCore::Page;
using WebCore::String;
@@ -185,6 +186,27 @@ String DebuggerAgentImpl::ExecuteUtilityFunction(
}
}
+String DebuggerAgentImpl::EvaluateJavaScript(
+ Frame* frame,
+ const String &source_code,
+ bool* is_exception) {
+ v8::HandleScope scope;
+ v8::Handle<v8::Context> context = V8Proxy::GetContext(frame);
+ v8::Context::Scope context_scope(context);
+ v8::Local<v8::String> code = v8ExternalString(source_code);
+
+ V8Proxy* proxy = V8Proxy::retrieve(frame);
+ v8::TryCatch try_catch;
+ v8::Handle<v8::Script> script = proxy->CompileScript(code, "", 0);
+ v8::Local<v8::Value> object = proxy->RunScript(script, true);
+ if (try_catch.HasCaught()) {
+ *is_exception = true;
+ return WebCore::ToWebCoreString(try_catch.Message()->Get());
+ } else {
+ return WebCore::toWebCoreStringWithNullCheck(object);
+ }
+}
+
WebCore::Page* DebuggerAgentImpl::GetPage() {
return web_view_impl_->page();
}
diff --git a/webkit/glue/devtools/debugger_agent_impl.h b/webkit/glue/devtools/debugger_agent_impl.h
index e2d6b6c..55d5ec8 100644
--- a/webkit/glue/devtools/debugger_agent_impl.h
+++ b/webkit/glue/devtools/debugger_agent_impl.h
@@ -58,6 +58,11 @@ class DebuggerAgentImpl : public DebuggerAgent {
const WebCore::String& json_args,
WebCore::String* exception);
+ WebCore::String EvaluateJavaScript(
+ WebCore::Frame* frame,
+ const WebCore::String& source_code,
+ bool* is_exception);
+
WebCore::Page* GetPage();
WebDevToolsAgentImpl* webdevtools_agent() { return webdevtools_agent_; };
diff --git a/webkit/glue/devtools/js/devtools.js b/webkit/glue/devtools/js/devtools.js
index 9e93da0..b1aede6 100644
--- a/webkit/glue/devtools/js/devtools.js
+++ b/webkit/glue/devtools/js/devtools.js
@@ -805,9 +805,7 @@ WebInspector.Console.prototype._evalInInspectedWindow = function(expression) {
return WebInspector.panels.scripts.evaluateInSelectedCallFrame(expression);
var console = this;
- devtools.tools.evaluateJavaScript(expression, function(response) {
- // TODO(yurys): send exception information along with the response
- var exception = false;
+ devtools.tools.evaluateJavaScript(expression, function(response, exception) {
console.addMessage(new WebInspector.ConsoleCommandResult(
response, exception, null /* commandMessage */));
});
diff --git a/webkit/glue/devtools/tools_agent.h b/webkit/glue/devtools/tools_agent.h
index a5bb671..af8b639 100644
--- a/webkit/glue/devtools/tools_agent.h
+++ b/webkit/glue/devtools/tools_agent.h
@@ -42,7 +42,8 @@ DEFINE_RPC_CLASS(ToolsAgent, TOOLS_AGENT_STRUCT)
METHOD1(UpdateFocusedNode, int /* node_id */) \
\
/* Response message to EvaluateJavaScript. */ \
- METHOD2(DidEvaluateJavaScript, int /* call_id */, String /* result */) \
+ METHOD3(DidEvaluateJavaScript, int /* call_id */, String /* result */, \
+ bool /* isException */) \
\
/* Updates focused node on the client. */ \
METHOD2(FrameNavigate, std::string /* url */, bool /* top_level */) \
diff --git a/webkit/glue/webdevtoolsagent_impl.cc b/webkit/glue/webdevtoolsagent_impl.cc
index f617220..c3a6181 100644
--- a/webkit/glue/webdevtoolsagent_impl.cc
+++ b/webkit/glue/webdevtoolsagent_impl.cc
@@ -185,21 +185,16 @@ void WebDevToolsAgentImpl::HideDOMNodeHighlight() {
}
void WebDevToolsAgentImpl::EvaluateJavaScript(int call_id, const String& js) {
+ String result;
+ bool is_exception = false;
+
Page* page = web_view_impl_->page();
- if (!page->mainFrame()) {
- return;
- }
- ScriptValue result = page->mainFrame()->loader()->executeScript(js);
- String result_string;
- if (!result.hasNoValue()) {
- // toString() may need global context.
- v8::HandleScope scope;
- v8::Handle<v8::Context> context = WebCore::V8Proxy::GetContext(
- page->mainFrame());
- v8::Context::Scope context_scope(context);
- result_string = result.toString(NULL);
+ if (page->mainFrame()) {
+ result = debugger_agent_impl_->EvaluateJavaScript(page->mainFrame(),
+ js, &is_exception);
}
- tools_agent_delegate_stub_->DidEvaluateJavaScript(call_id, result_string);
+ tools_agent_delegate_stub_->DidEvaluateJavaScript(
+ call_id, result, is_exception);
}
void WebDevToolsAgentImpl::ExecuteUtilityFunction(