summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authoryurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-04 09:11:13 +0000
committeryurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-04 09:11:13 +0000
commit9c7121a41d8486aa45853fb3be3ebca91602316a (patch)
tree545b39058702d48c9b413c2ec0d1a1a83878902e /webkit/glue
parent61866962148bbf7e83df98c4002b053af1b19cb3 (diff)
downloadchromium_src-9c7121a41d8486aa45853fb3be3ebca91602316a.zip
chromium_src-9c7121a41d8486aa45853fb3be3ebca91602316a.tar.gz
chromium_src-9c7121a41d8486aa45853fb3be3ebca91602316a.tar.bz2
DevTools: call a no-op function from the utility context to trigger v8 execution instead of evaluating javascript:void(0). This way we don't need to filter out AfterCompile events for 'javascript:void(0)' scripts.
Review URL: http://codereview.chromium.org/195013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25439 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/devtools/debugger_agent_impl.cc15
-rw-r--r--webkit/glue/devtools/debugger_agent_impl.h5
-rw-r--r--webkit/glue/devtools/js/debugger_agent.js44
-rw-r--r--webkit/glue/devtools/js/inject_dispatch.js8
-rw-r--r--webkit/glue/devtools/tools_agent.h4
-rw-r--r--webkit/glue/webdevtoolsagent_impl.cc4
-rw-r--r--webkit/glue/webdevtoolsagent_impl.h1
-rw-r--r--webkit/glue/webkit_resources.grd2
8 files changed, 41 insertions, 42 deletions
diff --git a/webkit/glue/devtools/debugger_agent_impl.cc b/webkit/glue/devtools/debugger_agent_impl.cc
index ac4c97d..70353ae 100644
--- a/webkit/glue/devtools/debugger_agent_impl.cc
+++ b/webkit/glue/devtools/debugger_agent_impl.cc
@@ -188,6 +188,21 @@ String DebuggerAgentImpl::ExecuteUtilityFunction(
}
}
+void DebuggerAgentImpl::ExecuteVoidJavaScript(v8::Handle<v8::Context> context) {
+ v8::HandleScope scope;
+ ASSERT(!context.IsEmpty());
+ v8::Context::Scope context_scope(context);
+ DebuggerAgentManager::UtilityContextScope utility_scope;
+
+ v8::Handle<v8::Value> function =
+ context->Global()->Get(v8::String::New("devtools$$void"));
+ ASSERT(function->IsFunction());
+ v8::Handle<v8::Value> args[] = {
+ v8::Local<v8::Value>()
+ };
+ v8::Handle<v8::Function>::Cast(function)->Call(context->Global(), 0, args);
+}
+
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 20db532..ea1b0b3 100644
--- a/webkit/glue/devtools/debugger_agent_impl.h
+++ b/webkit/glue/devtools/debugger_agent_impl.h
@@ -57,6 +57,11 @@ class DebuggerAgentImpl : public DebuggerAgent {
const WebCore::String& json_args,
WebCore::String* exception);
+ // Executes a no-op function in the utility context. We don't use
+ // ExecuteUtilityFunction for that to avoid script evaluation leading to
+ // undesirable AfterCompile events.
+ void ExecuteVoidJavaScript(v8::Handle<v8::Context> context);
+
WebCore::Page* GetPage();
WebDevToolsAgentImpl* webdevtools_agent() { return webdevtools_agent_; };
diff --git a/webkit/glue/devtools/js/debugger_agent.js b/webkit/glue/devtools/js/debugger_agent.js
index ac7cdfb..421e023 100644
--- a/webkit/glue/devtools/js/debugger_agent.js
+++ b/webkit/glue/devtools/js/debugger_agent.js
@@ -117,22 +117,6 @@ devtools.DebuggerAgent.ScopeType = {
/**
- * A no-op JS expression that is sent to the inspected page in order to force v8
- * execution.
- * @type {string}
- */
-devtools.DebuggerAgent.VOID_SCRIPT = 'javascript:void(0)';
-
-/**
- * AfterCompile event source for devtools.DebuggerAgent.VOID_SCRIPT.
- * @type {string}
- */
-devtools.DebuggerAgent.VOID_SCRIPT_EVAL_SOURCE =
- 'with (window._inspectorCommandLineAPI) { with (window) { ' +
- devtools.DebuggerAgent.VOID_SCRIPT +
- ' } }';
-
-/**
* A copy of enum from include/v8.h
* @enum {number}
*/
@@ -215,7 +199,7 @@ devtools.DebuggerAgent.prototype.resolveScriptSource = function(
});
devtools.DebuggerAgent.sendCommand_(cmd);
// Force v8 execution so that it gets to processing the requested command.
- devtools.tools.evaluateJavaScript(devtools.DebuggerAgent.VOID_SCRIPT);
+ RemoteToolsAgent.ExecuteVoidJavaScript();
this.requestSeqToCallback_[cmd.getSequenceNumber()] = function(msg) {
if (msg.isSuccess()) {
@@ -297,7 +281,7 @@ devtools.DebuggerAgent.prototype.addBreakpoint = function(
// Force v8 execution so that it gets to processing the requested command.
// It is necessary for being able to change a breakpoint just after it
// has been created (since we need an existing breakpoint id for that).
- devtools.tools.evaluateJavaScript(devtools.DebuggerAgent.VOID_SCRIPT);
+ RemoteToolsAgent.ExecuteVoidJavaScript();
};
@@ -732,7 +716,7 @@ devtools.DebuggerAgent.prototype.setContextId_ = function(contextId) {
});
devtools.DebuggerAgent.sendCommand_(cmd);
// Force v8 execution so that it gets to processing the requested command.
- devtools.tools.evaluateJavaScript(devtools.DebuggerAgent.VOID_SCRIPT);
+ RemoteToolsAgent.ExecuteVoidJavaScript();
var debuggerAgent = this;
this.requestSeqToCallback_[cmd.getSequenceNumber()] = function(msg) {
@@ -837,11 +821,6 @@ devtools.DebuggerAgent.prototype.handleScriptsResponse_ = function(msg) {
continue;
}
- // There is no script source
- if (this.isVoidScript_(script)) {
- continue;
- }
-
// We may already have received the info in an afterCompile event.
if (script.id in this.parsedScripts_) {
continue;
@@ -907,10 +886,6 @@ devtools.DebuggerAgent.prototype.handleAfterCompileEvent_ = function(msg) {
}
var script = msg.getBody().script;
- if (this.isVoidScript_(script)) {
- return;
- }
-
// Ignore scripts from other tabs.
if (!this.isScriptFromInspectedContext_(script, msg)) {
return;
@@ -920,19 +895,6 @@ devtools.DebuggerAgent.prototype.handleAfterCompileEvent_ = function(msg) {
/**
- * @param {Object} script Parsed JSON object representing script.
- * @return {boolean} Whether the script is a result of the void script
- * evaluation and should not appear in the UI.
- */
-devtools.DebuggerAgent.prototype.isVoidScript_ = function(script) {
- var voidScript = devtools.DebuggerAgent.VOID_SCRIPT_EVAL_SOURCE;
- return !script.name &&
- (script.sourceStart == voidScript ||
- script.source == voidScript);
-};
-
-
-/**
* Handles current profiler status.
* @param {number} modules List of active (started) modules.
*/
diff --git a/webkit/glue/devtools/js/inject_dispatch.js b/webkit/glue/devtools/js/inject_dispatch.js
index 4b8ec04..08f5ffb 100644
--- a/webkit/glue/devtools/js/inject_dispatch.js
+++ b/webkit/glue/devtools/js/inject_dispatch.js
@@ -70,3 +70,11 @@ var dispatch = function(method, var_args) {
var call = JSON.stringify(sanitizeJson(args));
DevToolsAgentHost.dispatch(call);
};
+
+
+/**
+ * A no-op function that is called by debugger agent just to trigger v8
+ * execution.
+ */
+function devtools$$void() {
+} \ No newline at end of file
diff --git a/webkit/glue/devtools/tools_agent.h b/webkit/glue/devtools/tools_agent.h
index 6fd6e50..853d7ae 100644
--- a/webkit/glue/devtools/tools_agent.h
+++ b/webkit/glue/devtools/tools_agent.h
@@ -14,6 +14,10 @@
METHOD3(ExecuteUtilityFunction, int /* call_id */, \
String /* function_name */, String /* json_args */) \
\
+ /* Request the agent to to run a no-op JavaScript function to trigger v8
+ execution. */ \
+ METHOD0(ExecuteVoidJavaScript) \
+ \
/* Requests that the agent sends content of the resource with given id to the
delegate. */ \
METHOD2(GetResourceContent, int /* call_id */, int /* identifier */)
diff --git a/webkit/glue/webdevtoolsagent_impl.cc b/webkit/glue/webdevtoolsagent_impl.cc
index e6d267a..787af9a 100644
--- a/webkit/glue/webdevtoolsagent_impl.cc
+++ b/webkit/glue/webdevtoolsagent_impl.cc
@@ -174,6 +174,10 @@ void WebDevToolsAgentImpl::ExecuteUtilityFunction(
result, exception);
}
+void WebDevToolsAgentImpl::ExecuteVoidJavaScript() {
+ debugger_agent_impl_->ExecuteVoidJavaScript(utility_context_);
+}
+
void WebDevToolsAgentImpl::GetResourceContent(
int call_id,
int identifier) {
diff --git a/webkit/glue/webdevtoolsagent_impl.h b/webkit/glue/webdevtoolsagent_impl.h
index 14cd367..6f85fd2 100644
--- a/webkit/glue/webdevtoolsagent_impl.h
+++ b/webkit/glue/webdevtoolsagent_impl.h
@@ -47,6 +47,7 @@ class WebDevToolsAgentImpl
int call_id,
const WebCore::String& function_name,
const WebCore::String& json_args);
+ virtual void ExecuteVoidJavaScript();
virtual void GetResourceContent(
int call_id,
int identifier);
diff --git a/webkit/glue/webkit_resources.grd b/webkit/glue/webkit_resources.grd
index f940b10b..c486f5c 100644
--- a/webkit/glue/webkit_resources.grd
+++ b/webkit/glue/webkit_resources.grd
@@ -30,7 +30,7 @@
<include name="IDR_MEDIA_SOUND_DISABLED" file="resources\media_sound_disabled.png" type="BINDATA" />
<include name="IDR_MEDIA_SLIDER_THUMB" file="resources\media_slider_thumb.png" type="BINDATA" />
<include name="IDR_MEDIA_VOLUME_SLIDER_THUMB" file="resources\media_volume_slider_thumb.png" type="BINDATA" />
-
+
<if expr="os == 'linux2'">
<include name="IDR_LINUX_CHECKBOX_OFF" file="resources\linux-checkbox-off.png" type="BINDATA" />
<include name="IDR_LINUX_CHECKBOX_ON" file="resources\linux-checkbox-on.png" type="BINDATA" />