summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-10 13:13:51 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-10 13:13:51 +0000
commit84077754c8129dfbc8ae6b624df34267a1e2b9ef (patch)
treea347a5f1e2646b047145e627f6bd068c544366f5 /webkit/glue
parent212ca5e4c523bffc6447c02df8a66852a76e809a (diff)
downloadchromium_src-84077754c8129dfbc8ae6b624df34267a1e2b9ef.zip
chromium_src-84077754c8129dfbc8ae6b624df34267a1e2b9ef.tar.gz
chromium_src-84077754c8129dfbc8ae6b624df34267a1e2b9ef.tar.bz2
DevTools: Show exception message in a resource message bubble while stopped on exception.
Review URL: http://codereview.chromium.org/155349 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20373 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/devtools/js/debugger_agent.js69
1 files changed, 69 insertions, 0 deletions
diff --git a/webkit/glue/devtools/js/debugger_agent.js b/webkit/glue/devtools/js/debugger_agent.js
index aa9c77e..efd7230 100644
--- a/webkit/glue/devtools/js/debugger_agent.js
+++ b/webkit/glue/devtools/js/debugger_agent.js
@@ -87,6 +87,13 @@ devtools.DebuggerAgent = function() {
* @type {Object}
*/
this.urlToBreakpoints_ = {};
+
+
+ /**
+ * Exception message that is shown to user while on exception break.
+ * @type {WebInspector.ConsoleMessage}
+ */
+ this.currentExceptionMessage_ = null;
};
@@ -303,12 +310,70 @@ devtools.DebuggerAgent.prototype.stepOverStatement = function() {
* breakpoint or an exception.
*/
devtools.DebuggerAgent.prototype.resumeExecution = function() {
+ this.clearExceptionMessage_();
var cmd = new devtools.DebugCommand('continue');
devtools.DebuggerAgent.sendCommand_(cmd);
};
/**
+ * Creates exception message and schedules it for addition to the resource upon
+ * backtrace availability.
+ * @param {string} url Resource url.
+ * @param {number} line Resource line number.
+ * @param {string} message Exception text.
+ */
+devtools.DebuggerAgent.prototype.createExceptionMessage_ = function(
+ url, line, message) {
+ this.currentExceptionMessage_ = new WebInspector.ConsoleMessage(
+ WebInspector.ConsoleMessage.MessageSource.JS,
+ WebInspector.ConsoleMessage.MessageLevel.Error,
+ line,
+ url,
+ 0 /* group level */,
+ 1 /* repeat count */,
+ '[Exception] ' + message);
+};
+
+
+/**
+ * Shows pending exception message that is created with createExceptionMessage_
+ * earlier.
+ */
+devtools.DebuggerAgent.prototype.showPendingExceptionMessage_ = function() {
+ if (!this.currentExceptionMessage_) {
+ return;
+ }
+ var msg = this.currentExceptionMessage_;
+ var resource = WebInspector.resourceURLMap[msg.url];
+ if (resource) {
+ msg.resource = resource;
+ WebInspector.panels.resources.addMessageToResource(resource, msg);
+ } else {
+ this.currentExceptionMessage_ = null;
+ }
+};
+
+
+/**
+ * Clears exception message from the resource.
+ */
+devtools.DebuggerAgent.prototype.clearExceptionMessage_ = function() {
+ if (this.currentExceptionMessage_) {
+ var messageElement =
+ this.currentExceptionMessage_._resourceMessageLineElement;
+ var bubble = messageElement.parentElement;
+ bubble.removeChild(messageElement);
+ if (!bubble.firstChild) {
+ // Last message in bubble removed.
+ bubble.parentElement.removeChild(bubble);
+ }
+ this.currentExceptionMessage_ = null;
+ }
+};
+
+
+/**
* @return {boolean} True iff the debugger will pause execution on the
* exceptions.
*/
@@ -514,6 +579,7 @@ devtools.DebuggerAgent.sendCommand_ = function(cmd) {
* @param {string} action 'in', 'out' or 'next' action.
*/
devtools.DebuggerAgent.prototype.stepCommand_ = function(action) {
+ this.clearExceptionMessage_();
var cmd = new devtools.DebugCommand('continue', {
'stepaction': action,
'stepcount': 1
@@ -626,6 +692,8 @@ devtools.DebuggerAgent.prototype.handleExceptionEvent_ = function(msg) {
this.currentCallFrame_.sourceID = sourceId;
this.currentCallFrame_.line = line;
this.currentCallFrame_.script = body.script;
+
+ this.createExceptionMessage_(body.script.name, line, body.exception.text);
this.requestBacktrace_();
} else {
this.resumeExecution();
@@ -806,6 +874,7 @@ devtools.DebuggerAgent.prototype.handleBacktraceResponse_ = function(msg) {
this.currentCallFrame_ = f;
WebInspector.pausedScript();
+ this.showPendingExceptionMessage_();
DevToolsHost.activateWindow();
};