summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authoryurys@chromium.org <yurys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-30 09:20:45 +0000
committeryurys@chromium.org <yurys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-30 09:20:45 +0000
commit28ce8ebbf14b94ea5ddce5dcd6d2678ffc460a60 (patch)
tree80b0544dbc30f28ca8b1006c75a102cb279bc444 /chrome
parentc6dddf37aa407372f0e6ba605b8e9f00d82babdd (diff)
downloadchromium_src-28ce8ebbf14b94ea5ddce5dcd6d2678ffc460a60.zip
chromium_src-28ce8ebbf14b94ea5ddce5dcd6d2678ffc460a60.tar.gz
chromium_src-28ce8ebbf14b94ea5ddce5dcd6d2678ffc460a60.tar.bz2
DevTools: process pause script request on the IO thread. To pause already running script we need to call v8::Debug::DebugBreak() on a thread different from the Render thread which may be busy with JS execution.
BUG=28892 TEST=DevToolsSanityTest.TestPauseWhenScriptIsRunning Review URL: http://codereview.chromium.org/444017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33279 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/debugger/devtools_sanity_unittest.cc8
-rw-r--r--chrome/common/devtools_messages_internal.h6
-rw-r--r--chrome/renderer/devtools_agent_filter.cc26
-rw-r--r--chrome/renderer/devtools_agent_filter.h1
-rw-r--r--chrome/renderer/devtools_client.cc4
-rw-r--r--chrome/renderer/devtools_client.h1
-rw-r--r--chrome/test/data/devtools/pause_when_script_is_running.html13
7 files changed, 47 insertions, 12 deletions
diff --git a/chrome/browser/debugger/devtools_sanity_unittest.cc b/chrome/browser/debugger/devtools_sanity_unittest.cc
index 405d809..3c3b8d4 100644
--- a/chrome/browser/debugger/devtools_sanity_unittest.cc
+++ b/chrome/browser/debugger/devtools_sanity_unittest.cc
@@ -53,6 +53,8 @@ const wchar_t kPauseOnExceptionTestPage[] =
L"files/devtools/pause_on_exception.html";
const wchar_t kPauseWhenLoadingDevTools[] =
L"files/devtools/pause_when_loading_devtools.html";
+const wchar_t kPauseWhenScriptIsRunning[] =
+ L"files/devtools/pause_when_script_is_running.html";
const wchar_t kResourceContentLengthTestPage[] = L"files/devtools/image.html";
const wchar_t kResourceTestPage[] = L"files/devtools/resource_test_page.html";
const wchar_t kSimplePage[] = L"files/devtools/simple_page.html";
@@ -344,6 +346,12 @@ IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestPauseWhenLoadingDevTools) {
RunTest("testPauseWhenLoadingDevTools", kPauseWhenLoadingDevTools);
}
+// Tests that pressing 'Pause' will pause script execution if the script
+// is already running.
+IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestPauseWhenScriptIsRunning) {
+ RunTest("testPauseWhenScriptIsRunning", kPauseWhenScriptIsRunning);
+}
+
// Tests eval on call frame.
IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestEvalOnCallFrame) {
RunTest("testEvalOnCallFrame", kDebuggerTestPage);
diff --git a/chrome/common/devtools_messages_internal.h b/chrome/common/devtools_messages_internal.h
index be187a7..d80c0ed 100644
--- a/chrome/common/devtools_messages_internal.h
+++ b/chrome/common/devtools_messages_internal.h
@@ -86,6 +86,12 @@ IPC_BEGIN_MESSAGES(DevToolsAgent)
IPC_MESSAGE_CONTROL1(DevToolsAgentMsg_DebuggerCommand,
std::string /* command */)
+ // This command is sent to debugger when user wants to pause script execution
+ // immediately. This message should be processed on the IO thread so that it
+ // can have effect even if the Renderer thread is busy with JavaScript
+ // execution.
+ IPC_MESSAGE_CONTROL0(DevToolsAgentMsg_DebuggerPauseScript)
+
// Inspect element with the given coordinates.
IPC_MESSAGE_CONTROL2(DevToolsAgentMsg_InspectElement,
int /* x */,
diff --git a/chrome/renderer/devtools_agent_filter.cc b/chrome/renderer/devtools_agent_filter.cc
index f67f183..93b6c75 100644
--- a/chrome/renderer/devtools_agent_filter.cc
+++ b/chrome/renderer/devtools_agent_filter.cc
@@ -34,21 +34,23 @@ DevToolsAgentFilter::~DevToolsAgentFilter() {
}
bool DevToolsAgentFilter::OnMessageReceived(const IPC::Message& message) {
- if (message.type() == DevToolsAgentMsg_DebuggerCommand::ID) {
- // Dispatch command directly from IO.
- bool handled = true;
- current_routing_id_ = message.routing_id();
- IPC_BEGIN_MESSAGE_MAP(DevToolsAgentFilter, message)
- IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DebuggerCommand, OnDebuggerCommand)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
- } else {
- return false;
- }
+ // Dispatch debugger commands directly from IO.
+ bool handled = true;
+ current_routing_id_ = message.routing_id();
+ IPC_BEGIN_MESSAGE_MAP(DevToolsAgentFilter, message)
+ IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DebuggerCommand, OnDebuggerCommand)
+ IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DebuggerPauseScript,
+ OnDebuggerPauseScript)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
}
void DevToolsAgentFilter::OnDebuggerCommand(const std::string& command) {
WebDevToolsAgent::executeDebuggerCommand(
WebString::fromUTF8(command), current_routing_id_);
}
+
+void DevToolsAgentFilter::OnDebuggerPauseScript() {
+ WebDevToolsAgent::debuggerPauseScript();
+}
diff --git a/chrome/renderer/devtools_agent_filter.h b/chrome/renderer/devtools_agent_filter.h
index 9ee6296..4bf4460 100644
--- a/chrome/renderer/devtools_agent_filter.h
+++ b/chrome/renderer/devtools_agent_filter.h
@@ -31,6 +31,7 @@ class DevToolsAgentFilter : public IPC::ChannelProxy::MessageFilter {
// OnDebuggerCommand will be executed in the IO thread so that we can
// handle debug messages even when v8 is stopped.
void OnDebuggerCommand(const std::string& command);
+ void OnDebuggerPauseScript();
int current_routing_id_;
diff --git a/chrome/renderer/devtools_client.cc b/chrome/renderer/devtools_client.cc
index 9b17c8b..8083288 100644
--- a/chrome/renderer/devtools_client.cc
+++ b/chrome/renderer/devtools_client.cc
@@ -64,6 +64,10 @@ void DevToolsClient::sendDebuggerCommandToAgent(const WebString& command) {
Send(DevToolsAgentMsg_DebuggerCommand(command.utf8()));
}
+void DevToolsClient::sendDebuggerPauseScript() {
+ Send(DevToolsAgentMsg_DebuggerPauseScript());
+}
+
void DevToolsClient::activateWindow() {
render_view_->Send(new ViewHostMsg_ActivateDevToolsWindow(
render_view_->routing_id()));
diff --git a/chrome/renderer/devtools_client.h b/chrome/renderer/devtools_client.h
index e83ec12..aad5c09 100644
--- a/chrome/renderer/devtools_client.h
+++ b/chrome/renderer/devtools_client.h
@@ -43,6 +43,7 @@ class DevToolsClient : public WebKit::WebDevToolsFrontendClient {
const WebKit::WebString& param2,
const WebKit::WebString& param3);
virtual void sendDebuggerCommandToAgent(const WebKit::WebString& command);
+ virtual void sendDebuggerPauseScript();
virtual void activateWindow();
virtual void closeWindow();
diff --git a/chrome/test/data/devtools/pause_when_script_is_running.html b/chrome/test/data/devtools/pause_when_script_is_running.html
new file mode 100644
index 0000000..380d8e1
--- /dev/null
+++ b/chrome/test/data/devtools/pause_when_script_is_running.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+<script>
+function handleClick() {
+ while(true) {
+ }
+}
+</script>
+</head>
+<body>
+<input type='button' onclick='handleClick()' value='Test'/>
+</body>
+</html> \ No newline at end of file