2011-04-12 Pavel Feldman <pfeldman@google.com>
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Apr 2011 11:35:50 +0000 (11:35 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Apr 2011 11:35:50 +0000 (11:35 +0000)
        Reviewed by Yury Semikhatsky.

        Web Inspector: document console domain, support cross-domain type references.
        https://bugs.webkit.org/show_bug.cgi?id=58240

        * inspector/protocol/console-agent-expected.txt:
2011-04-12  Pavel Feldman  <pfeldman@google.com>

        Reviewed by Yury Semikhatsky.

        Web Inspector: document console domain, support cross-domain type references.
        https://bugs.webkit.org/show_bug.cgi?id=58240

        * inspector/ConsoleMessage.cpp:
        (WebCore::messageSourceValue):
        (WebCore::messageTypeValue):
        (WebCore::messageLevelValue):
        (WebCore::ConsoleMessage::addToFrontend):
        * inspector/Inspector.json:
        * inspector/ScriptCallFrame.cpp:
        (WebCore::ScriptCallFrame::buildInspectorObject):
        * inspector/front-end/ConsoleView.js:
        (WebInspector.ConsoleView.prototype._registerConsoleDomainDispatcher.dispatcher.messageAdded):
        (WebInspector.ConsoleMessage):
        (WebInspector.ConsoleMessage.prototype._populateStackTraceTreeElement):
        (WebInspector.ConsoleMessage.prototype.isEqual):
        * inspector/front-end/NetworkManager.js:
        (WebInspector.NetworkDispatcher.prototype.requestWillBeSent):
        * inspector/generate-inspector-idl:
        * page/Console.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83575 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/protocol/console-agent-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/inspector/ConsoleMessage.cpp
Source/WebCore/inspector/Inspector.json
Source/WebCore/inspector/ScriptCallFrame.cpp
Source/WebCore/inspector/front-end/ConsoleView.js
Source/WebCore/inspector/front-end/NetworkManager.js
Source/WebCore/inspector/generate-inspector-idl
Source/WebCore/page/Console.h

index deefbc4..a94e0b2 100644 (file)
@@ -1,3 +1,12 @@
+2011-04-12  Pavel Feldman  <pfeldman@google.com>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: document console domain, support cross-domain type references.
+        https://bugs.webkit.org/show_bug.cgi?id=58240
+
+        * inspector/protocol/console-agent-expected.txt:
+
 2011-04-12  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         [Qt] inspector/styles/styles-disable-then-enable.html make inspector/styles/styles-iframe.html fail in debug mode
index b9c3c4a..412d82d 100644 (file)
@@ -54,13 +54,13 @@ event ConsoleAgent.messageAdded
     method : "Console.messageAdded"
     params : {
         messageObj : {
-            source : 3
-            type : 0
-            level : 1
+            source : "javascript"
+            type : "log"
+            level : "log"
             line : 0
             url : ""
             repeatCount : 1
-            message : "test"
+            text : "test"
             parameters : {
                 0 : {
                     type : "string"
index b5f66de..7d16f76 100644 (file)
@@ -1,3 +1,28 @@
+2011-04-12  Pavel Feldman  <pfeldman@google.com>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: document console domain, support cross-domain type references.
+        https://bugs.webkit.org/show_bug.cgi?id=58240
+
+        * inspector/ConsoleMessage.cpp:
+        (WebCore::messageSourceValue):
+        (WebCore::messageTypeValue):
+        (WebCore::messageLevelValue):
+        (WebCore::ConsoleMessage::addToFrontend):
+        * inspector/Inspector.json:
+        * inspector/ScriptCallFrame.cpp:
+        (WebCore::ScriptCallFrame::buildInspectorObject):
+        * inspector/front-end/ConsoleView.js:
+        (WebInspector.ConsoleView.prototype._registerConsoleDomainDispatcher.dispatcher.messageAdded):
+        (WebInspector.ConsoleMessage):
+        (WebInspector.ConsoleMessage.prototype._populateStackTraceTreeElement):
+        (WebInspector.ConsoleMessage.prototype.isEqual):
+        * inspector/front-end/NetworkManager.js:
+        (WebInspector.NetworkDispatcher.prototype.requestWillBeSent):
+        * inspector/generate-inspector-idl:
+        * page/Console.h:
+
 2011-04-06  Philippe Normand  <pnormand@igalia.com>
 
         Reviewed by Martin Robinson.
index 9bf89f4..5ced69a 100644 (file)
@@ -86,18 +86,60 @@ ConsoleMessage::~ConsoleMessage()
 {
 }
 
+// Keep in sync with inspector/front-end/ConsoleView.js
+static String messageSourceValue(MessageSource source)
+{
+    switch (source) {
+    case HTMLMessageSource: return "html";
+    case WMLMessageSource: return "wml";
+    case XMLMessageSource: return "xml";
+    case JSMessageSource: return "javascript";
+    case CSSMessageSource: return "css";
+    case OtherMessageSource: return "other";
+    }
+    return "other";
+}
+
+static String messageTypeValue(MessageType type)
+{
+    switch (type) {
+    case LogMessageType: return "log";
+    case ObjectMessageType: return "other";
+    case TraceMessageType: return "trace";
+    case StartGroupMessageType: return "startGroup";
+    case StartGroupCollapsedMessageType: return "startGroupCollapsed";
+    case EndGroupMessageType: return "endGroup";
+    case AssertMessageType: return "assert";
+    case UncaughtExceptionMessageType: return "uncaughtException";
+    case NetworkErrorMessageType: return "networkError";
+    }
+    return "other";
+}
+
+static String messageLevelValue(MessageLevel level)
+{
+    switch (level) {
+    case TipMessageLevel: return "tip";
+    case LogMessageLevel: return "log";
+    case WarningMessageLevel: return "warning";
+    case ErrorMessageLevel: return "error";
+    case DebugMessageLevel: return "debug";
+    }
+    return "log";
+}
+
 void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, InjectedScriptManager* injectedScriptManager)
 {
     RefPtr<InspectorObject> jsonObj = InspectorObject::create();
-    jsonObj->setNumber("source", static_cast<int>(m_source));
-    jsonObj->setNumber("type", static_cast<int>(m_type));
-    jsonObj->setNumber("level", static_cast<int>(m_level));
+    jsonObj->setString("source", messageSourceValue(m_source));
+    jsonObj->setString("type", messageTypeValue(m_type));
+    jsonObj->setString("level", messageLevelValue(m_level));
     jsonObj->setNumber("line", static_cast<int>(m_line));
     jsonObj->setString("url", m_url);
     jsonObj->setNumber("repeatCount", static_cast<int>(m_repeatCount));
-    jsonObj->setString("message", m_message);
+    jsonObj->setString("text", m_message);
     if (m_type == NetworkErrorMessageType) 
-        jsonObj->setNumber("requestId", m_requestId);
+        jsonObj->setNumber("networkIdentifier", m_requestId);
     if (m_arguments && m_arguments->argumentCount()) {
         InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(m_arguments->globalState());
         if (!injectedScript.hasNoValue()) {
index ca9b88c..6eb24b4 100644 (file)
     },
     {
         "domain": "Console",
-        "types": [],
+        "description": "Console domain defines methods and events for interaction with the JavaScript console. One needs to enable this domain using <code>enable</code> function in order to start receiving the console messages.",  
+        "types": [
+            {
+                "id": "ConsoleMessage",
+                "type": "object",
+                "description": "Console message.",
+                "properties": {
+                    "source": { "type": "string", "enum": ["html", "wml", "xml", "javascript", "css", "other"], "description": "Message source." },
+                    "type": { "type": "string", "enum": ["log", "other", "trace", "startGroup", "startGroupCollapsed", "endGroup", "assert", "uncaughtException", "networkError", "result"], "description": "Message type." },
+                    "level": { "type": "string", "enum": ["tip", "log", "warning", "error", "debug"], "description": "Message severity." },
+                    "line": { "type": "integer", "description": "JavaScript source line that created console message." },
+                    "url": { "type": "string", "description": "JavaScript source url that created console message." },
+                    "repeatCount": { "type": "integer", "optional": true, "description": "Repeat count for repeated messages." },
+                    "text": { "type": "string", "description": "Message text." },
+                    "networkIdentifier": { "type": "integer", "optional": true, "description": "Identifier of the network request associated with the console message." },
+                    "parameters": { "type": "array", "items": { "$ref": "RuntimeObject" }, "description": "Message parameters in case of the formatted message." },
+                    "stackTrace": { "type": "array", "optional": true, "items": { "$ref": "CallFrame" }, "description": "Call frames for assert and error messages." }
+                }
+            },
+            {
+                "id": "CallFrame",
+                "type": "object",
+                "description": "Stack entry for console errors and assertions.",
+                "properties": {
+                    "functionName": { "type": "string", "description": "JavaScript function name." },
+                    "url": { "type": "string", "description": "JavaScript source name / url." },
+                    "lineNumber": { "type": "string", "description": "JavaScript source line number." },
+                    "columnNumber": { "type": "string", "description": "JavaScript source column number." }
+                }
+            }
+        ],
         "commands": [
             {
                 "name": "enable",
                 "returns": [
-                   { "name": "expiredMessagesCount", "type": "integer" }
-                ]
+                    { "name": "expiredMessagesCount", "type": "integer", "description": "Number of messages cleared due to message threashold overflow." }
+                ],
+                "description": "Enables console domain, sends all the messages collected so far to the client." 
             },
             {
-                "name": "disable"
+                "name": "disable",
+                "description": "Disables console domain, prevents further console messages from being sent to the client." 
             },
             {
-                "name": "clearConsoleMessages"
+                "name": "clearConsoleMessages",
+                "description": "Clears collected console messages." 
             },
             {
                 "name": "setMonitoringXHREnabled",
                 "parameters": [
-                    { "name": "enabled", "type": "boolean" }
-                ]
+                    { "name": "enabled", "type": "boolean", "description": "Monitoring enabled state." }
+                ],
+                "description": "Toggles monitoring of XMLHttpRequest. If <code>true</code>, console will receive messages upon each XHR issued." 
             },
             {
                 "name": "addInspectedNode",
                 "parameters": [
-                    { "name": "nodeId", "type": "integer" }
-                ]
+                    { "name": "nodeId", "type": "integer", "description": "DOM node id to be accessible by means of $x command line API." }
+                ],
+                "description": "Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions)." 
             }
         ],
         "events": [
             {
                 "name": "messageAdded",
                 "parameters": [
-                    { "name": "messageObj", "$ref": "ConsoleMessage" }
-                ]
+                    { "name": "messageObj", "$ref": "ConsoleMessage", "description": "Console message that has been added." }
+                ],
+                "description": "Issued for each console message added."
             },
             {
                 "name": "messageRepeatCountUpdated",
                 "parameters": [
-                    { "name": "count", "type": "integer" }
-                ]
+                    { "name": "count", "type": "integer", "description": "New repeat count value." }
+                ],
+                "description": "In case of subsequent message being equal to the previous one, only repeat count is being updated."
             },
             {
-                "name": "messagesCleared"
+                "name": "messagesCleared",
+                "description": "Issued when console is cleared."
             }
         ]
     },
                     { "name": "request", "$ref": "ResourceRequest", "description": "Request data." },
                     { "name": "redirectResponse", "optional": true, "$ref": "ResourceResponse", "description": "Redirect response data." },
                     { "name": "time", "type": "number", "description": "Timestamp." },
-                    { "name": "callStack", "type": "array", "items": { "$ref" : "DebuggerStackFrame"}, "description": "JavaScript stack trace upon issuing this request." }
+                    { "name": "stackTrace", "type": "array", "items": { "$ref" : "Console.CallFrame"}, "description": "JavaScript stack trace upon issuing this request." }
                 ]
             },
             {
                 "properties": {
                     "type": { "type": "string",  "enum": ["global", "local", "with", "closure", "catch"], "description": "Scope type." },
                     "object": { "$ref": "RemoteObject", "description": "Object representing the scope." },
-                    "this": { "$ref": "RemoteObject", "optional": true, "description": "<code>this</code> object for local scope." },
+                    "this": { "$ref": "RemoteObject", "optional": true, "description": "<code>this</code> object for local scope." }
                 },
                 "description": "Debugger call frame. Array of call frames form call stack."
             }
index 0b5204b..641d192 100644 (file)
@@ -60,9 +60,9 @@ PassRefPtr<InspectorObject> ScriptCallFrame::buildInspectorObject() const
 {
     RefPtr<InspectorObject> frame = InspectorObject::create();
     frame->setString("functionName", m_functionName);
-    frame->setString("scriptName", m_scriptName);
+    frame->setString("url", m_scriptName);
     frame->setNumber("lineNumber", m_lineNumber);
-    frame->setNumber("column", m_column);
+    frame->setNumber("columnNumber", m_column);
     return frame;
 }
 #endif
index 9c70941..4ab16d9 100644 (file)
@@ -114,10 +114,10 @@ WebInspector.ConsoleView.prototype = {
                     payload.line,
                     payload.url,
                     payload.repeatCount,
-                    payload.message,
+                    payload.text,
                     payload.parameters,
                     payload.stackTrace,
-                    payload.requestId);
+                    payload.networkIdentifier);
                 console.addMessage(consoleMessage);
             },
 
@@ -691,7 +691,7 @@ WebInspector.ConsoleMessage = function(source, type, level, line, url, repeatCou
     if (stackTrace && stackTrace.length) {
         var topCallFrame = stackTrace[0];
         if (!this.url)
-            this.url = topCallFrame.scriptName;
+            this.url = topCallFrame.url;
         if (!this.line)
             this.line = topCallFrame.lineNumber;
     }
@@ -923,7 +923,7 @@ WebInspector.ConsoleMessage.prototype = {
             messageTextElement.appendChild(document.createTextNode(functionName));
             content.appendChild(messageTextElement);
 
-            var urlElement = WebInspector.linkifyResourceAsNode(frame.scriptName, "scripts", frame.lineNumber, "console-message-url");
+            var urlElement = WebInspector.linkifyResourceAsNode(frame.url, "scripts", frame.lineNumber, "console-message-url");
             content.appendChild(urlElement);
 
             var treeElement = new TreeElement(content);
@@ -1027,10 +1027,10 @@ WebInspector.ConsoleMessage.prototype = {
             var l = this._stackTrace;
             var r = msg._stackTrace;
             for (var i = 0; i < l.length; i++) {
-                if (l[i].scriptName !== r[i].scriptName ||
+                if (l[i].url !== r[i].url ||
                     l[i].functionName !== r[i].functionName ||
                     l[i].lineNumber !== r[i].lineNumber ||
-                    l[i].column !== r[i].column)
+                    l[i].columnNumber !== r[i].columnNumber)
                     return false;
             }
         }
@@ -1047,33 +1047,33 @@ WebInspector.ConsoleMessage.prototype = {
 
 // Note: Keep these constants in sync with the ones in Console.h
 WebInspector.ConsoleMessage.MessageSource = {
-    HTML: 0,
-    WML: 1,
-    XML: 2,
-    JS: 3,
-    CSS: 4,
-    Other: 5
+    HTML: "html",
+    WML: "wml",
+    XML: "xml",
+    JS: "javascript",
+    CSS: "css",
+    Other: "other"
 }
 
 WebInspector.ConsoleMessage.MessageType = {
-    Log: 0,
-    Object: 1,
-    Trace: 2,
-    StartGroup: 3,
-    StartGroupCollapsed: 4,
-    EndGroup: 5,
-    Assert: 6,
-    UncaughtException: 7,
-    NetworkError:8,
-    Result: 9
+    Log: "log",
+    Object: "other",
+    Trace: "trace",
+    StartGroup: "startGroup",
+    StartGroupCollapsed: "startGroupCollapsed",
+    EndGroup: "endGroup",
+    Assert: "assert",
+    UncaughtException: "uncaughtException",
+    NetworkError: "networkError",
+    Result: "result"
 }
 
 WebInspector.ConsoleMessage.MessageLevel = {
-    Tip: 0,
-    Log: 1,
-    Warning: 2,
-    Error: 3,
-    Debug: 4
+    Tip: "tip",
+    Log: "log",
+    Warning: "warning",
+    Error: "error",
+    Debug: "debug"
 }
 
 WebInspector.ConsoleCommand = function(command)
index aa7c89d..00c11e6 100644 (file)
@@ -112,14 +112,14 @@ WebInspector.NetworkDispatcher.prototype = {
         this._updateResourceWithResponse(resource, cachedResource.response);
     },
 
-    requestWillBeSent: function(identifier, frameId, loaderId, documentURL, request, redirectResponse, time, callStack)
+    requestWillBeSent: function(identifier, frameId, loaderId, documentURL, request, redirectResponse, time, stackTrace)
     {
         var resource = this._inflightResourcesById[identifier];
         if (resource) {
             this.responseReceived(identifier, time, "Other", redirectResponse);
             resource = this._appendRedirect(identifier, time, request.url);
         } else
-            resource = this._createResource(identifier, frameId, loaderId, request.url, documentURL, callStack);
+            resource = this._createResource(identifier, frameId, loaderId, request.url, documentURL, stackTrace);
         this._updateResourceWithRequest(resource, request);
         resource.startTime = time;
 
index 38dd0db..b5ecb78 100755 (executable)
@@ -92,11 +92,17 @@ macro_traits = {
     "Profiler": "JAVASCRIPT_DEBUGGER"
 }
 
-def param_type(param):
+def full_qualified_type_id(domain_name, type_id):
+    if type_id.find(".") == -1:
+       return "%s.%s" % (domain_name, type_id)
+    return type_id
+    
+
+def param_type(domain_name, param):
     if "type" in param:
         return type_traits[param["type"]]
     if "$ref" in param:
-        type_id = param["$ref"]
+        type_id = full_qualified_type_id(domain_name, param["$ref"])
         if type_id in ref_types:
             ref_type = ref_types[type_id]
             return type_traits[ref_type["type"]]
@@ -108,9 +114,12 @@ for domain in json_api:
     if domain_name in macro_traits:
         output_file.write("\n#if defined(ENABLE_%s) && ENABLE_%s" % (macro_traits[domain_name], macro_traits[domain_name]))
     output_file.write("\n    interface [Conditional=INSPECTOR] %s {" % domain_name)
+
     if "types" in domain:
         for type in domain["types"]:
-            ref_types[type["id"]] = type
+            type_id = full_qualified_type_id(domain_name, type["id"])
+            ref_types[type_id] = type;
+
     if "commands" in domain:
         for command in domain["commands"]:
             params = []
@@ -120,11 +129,12 @@ for domain in json_api:
                         optional = " [optional]"
                     else:
                         optional = ""
-                    params.append("in%s %s %s" % (optional, param_type(in_param), in_param["name"]))
+                    params.append("in%s %s %s" % (optional, param_type(domain_name, in_param), in_param["name"]))
             if ("returns" in command):
                 for out_param in command["returns"]:
-                    params.append("out %s %s" % (param_type(out_param), out_param["name"]))
+                    params.append("out %s %s" % (param_type(domain_name, out_param), out_param["name"]))
             output_file.write("\n        void %s(%s);" % (command["name"], ", ".join(params)))
+
     if "events" in domain:
         for event in domain["events"]:
             params = []
@@ -134,8 +144,9 @@ for domain in json_api:
                         optional = " [optional]"
                     else:
                         optional = ""
-                    params.append("out%s %s %s" % (optional, param_type(in_param), in_param["name"]))
+                    params.append("out%s %s %s" % (optional, param_type(domain_name, in_param), in_param["name"]))
             output_file.write("\n        [event] void %s(%s);" % (event["name"], ", ".join(params)))
+
     output_file.write("\n    };")
     if domain["domain"] in macro_traits:
         output_file.write("\n#endif // ENABLE_%s" % macro_traits[domain["domain"]])
index ceefb38..bfdcaa7 100644 (file)
@@ -50,7 +50,6 @@ class Frame;
 class Page;
 class ScriptCallStack;
 
-// Keep in sync with inspector/front-end/Console.js
 enum MessageSource {
     HTMLMessageSource,
     WMLMessageSource,