Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1037)

Unified Diff: Source/devtools/front_end/ConsoleView.js

Issue 23692002: DevTools: Dump function location when printing it in console and support inspect() for functions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed test Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/CPUProfileView.js ('k') | Source/devtools/front_end/ScriptsPanel.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/ConsoleView.js
diff --git a/Source/devtools/front_end/ConsoleView.js b/Source/devtools/front_end/ConsoleView.js
index 84a3c8ac571df8d0cd3112cc63efe2bb8859c6c3..b28bd31b91d83b8f7ef2525921fc2841947cc92d 100644
--- a/Source/devtools/front_end/ConsoleView.js
+++ b/Source/devtools/front_end/ConsoleView.js
@@ -551,6 +551,10 @@ WebInspector.ConsoleView.prototype = {
}
},
+ /**
+ * @param {string} expression
+ * @param {boolean} showResultOnly
+ */
evaluateUsingTextPrompt: function(expression, showResultOnly)
{
this._appendCommand(expression, this.prompt.text, false, showResultOnly);
@@ -571,14 +575,66 @@ WebInspector.ConsoleView.prototype = {
this._appendCommand(str, "", true, false);
},
+ /**
+ * @param {WebInspector.RemoteObject} result
+ * @param {boolean} wasThrown
+ * @param {WebInspector.ConsoleCommand} originatingCommand
+ */
_printResult: function(result, wasThrown, originatingCommand)
{
if (!result)
return;
- var message = new WebInspector.ConsoleCommandResult(result, wasThrown, originatingCommand, this._linkifier);
- WebInspector.console.addMessage(message);
+
+ /**
+ * @param {string=} url
+ * @param {number=} lineNumber
+ * @param {number=} columnNumber
+ */
+ function addMessage(url, lineNumber, columnNumber)
+ {
+ var message = new WebInspector.ConsoleCommandResult(result, wasThrown, originatingCommand, this._linkifier, url, lineNumber, columnNumber);
+ WebInspector.console.addMessage(message);
+ }
+
+ if (result.type !== "function") {
+ addMessage.call(this);
+ return;
+ }
+
+ DebuggerAgent.getFunctionDetails(result.objectId, didGetDetails.bind(this));
+
+ /**
+ * @param {?Protocol.Error} error
+ * @param {DebuggerAgent.FunctionDetails} response
+ */
+ function didGetDetails(error, response)
+ {
+ if (error) {
+ console.error(error);
+ addMessage.call(this);
+ return;
+ }
+
+ var url;
+ var lineNumber;
+ var columnNumber;
+ var script = WebInspector.debuggerModel.scriptForId(response.location.scriptId);
+ console.assert(script);
+ if (script.sourceURL) {
+ url = script.sourceURL;
+ lineNumber = response.location.lineNumber + 1;
+ columnNumber = response.location.columnNumber + 1;
+ }
+ addMessage.call(this, url, lineNumber, columnNumber);
+ }
},
+ /**
+ * @param {string} text
+ * @param {string} newPromptText
+ * @param {boolean} useCommandLineAPI
+ * @param {boolean} showResultOnly
+ */
_appendCommand: function(text, newPromptText, useCommandLineAPI, showResultOnly)
{
if (!showResultOnly) {
@@ -587,7 +643,12 @@ WebInspector.ConsoleView.prototype = {
}
this.prompt.text = newPromptText;
- function printResult(result, wasThrown)
+ /**
+ * @param {WebInspector.RemoteObject} result
+ * @param {boolean} wasThrown
+ * @param {RuntimeAgent.RemoteObject=} valueResult
+ */
+ function printResult(result, wasThrown, valueResult)
{
if (!result)
return;
@@ -596,7 +657,7 @@ WebInspector.ConsoleView.prototype = {
this.prompt.pushHistoryItem(text);
WebInspector.settings.consoleHistory.set(this.prompt.historyData.slice(-30));
}
-
+
this._printResult(result, wasThrown, commandMessage);
}
WebInspector.runtimeModel.evaluate(text, "console", useCommandLineAPI, false, false, true, printResult.bind(this));
@@ -1016,6 +1077,9 @@ WebInspector.ConsoleCommand.prototype = {
this._element.replaceChild(this._formattedCommand, highlightedMessage);
},
+ /**
+ * @param {RegExp} regexObject
+ */
highlightSearchResults: function(regexObject)
{
regexObject.lastIndex = 0;
@@ -1029,6 +1093,9 @@ WebInspector.ConsoleCommand.prototype = {
this._element.scrollIntoViewIfNeeded();
},
+ /**
+ * @param {RegExp} regexObject
+ */
matchesRegex: function(regexObject)
{
regexObject.lastIndex = 0;
@@ -1061,16 +1128,19 @@ WebInspector.ConsoleCommand.prototype = {
/**
* @extends {WebInspector.ConsoleMessageImpl}
* @constructor
- * @param {boolean} result
+ * @param {WebInspector.RemoteObject} result
* @param {boolean} wasThrown
* @param {WebInspector.ConsoleCommand} originatingCommand
* @param {WebInspector.Linkifier} linkifier
+ * @param {string=} url
+ * @param {number=} lineNumber
+ * @param {number=} columnNumber
*/
-WebInspector.ConsoleCommandResult = function(result, wasThrown, originatingCommand, linkifier)
+WebInspector.ConsoleCommandResult = function(result, wasThrown, originatingCommand, linkifier, url, lineNumber, columnNumber)
{
var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log);
this.originatingCommand = originatingCommand;
- WebInspector.ConsoleMessageImpl.call(this, WebInspector.ConsoleMessage.MessageSource.JS, level, "", linkifier, WebInspector.ConsoleMessage.MessageType.Result, undefined, undefined, undefined, undefined, [result]);
+ WebInspector.ConsoleMessageImpl.call(this, WebInspector.ConsoleMessage.MessageSource.JS, level, "", linkifier, WebInspector.ConsoleMessage.MessageType.Result, url, lineNumber, columnNumber, undefined, [result]);
}
WebInspector.ConsoleCommandResult.prototype = {
« no previous file with comments | « Source/devtools/front_end/CPUProfileView.js ('k') | Source/devtools/front_end/ScriptsPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698