[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

loislo at chromium.org loislo at chromium.org
Wed Dec 22 12:51:41 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit cb24aad112c9f399a4dbe5fd2f6857d0386723d6
Author: loislo at chromium.org <loislo at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 31 19:40:43 2010 +0000

    2010-08-31  Ilya Tikhonovsky  <loislo at chromium.org>
    
            Reviewed by Yury Semikhatsky.
    
            WebInspector: The parser of Inspector protocol messages should be covered by a test.
    
            The inspector protocol is based on messages in JSON format.
            Each message should be a JSON object with a number of properties.
            InspectorBackendDispatcher is parsing these messages and should be
            able to detect wrong formatted messages.
            It has these functionality but no tests for it.
    
            https://bugs.webkit.org/show_bug.cgi?id=44947
    
    
            * inspector/CodeGeneratorInspector.pm:
    
    2010-08-31  Ilya Tikhonovsky  <loislo at chromium.org>
    
            Reviewed by Yury Semikhatsky.
    
            WebInspector: The parser of Inspector protocol messages should be covered by a test.
    
            The inspector protocol is based on messages in JSON format.
            Each message should be a JSON object with a number of properties.
            InspectorBackendDispatcher is parsing these messages and should be
            able to detect wrong formatted messages.
            It has these functionality but no tests for it.
    
            https://bugs.webkit.org/show_bug.cgi?id=44947
    
            * http/tests/inspector/inspector-test2.js:
            (dump):
            (dumpArray):
            * inspector/report-protocol-errors-expected.txt: Added.
            * inspector/report-protocol-errors.html: Added.
    
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66523 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 479c321..3fe913b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,23 @@
+2010-08-31  Ilya Tikhonovsky  <loislo at chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        WebInspector: The parser of Inspector protocol messages should be covered by a test.
+
+        The inspector protocol is based on messages in JSON format.
+        Each message should be a JSON object with a number of properties.
+        InspectorBackendDispatcher is parsing these messages and should be
+        able to detect wrong formatted messages.
+        It has these functionality but no tests for it.
+
+        https://bugs.webkit.org/show_bug.cgi?id=44947
+
+        * http/tests/inspector/inspector-test2.js:
+        (dump):
+        (dumpArray):
+        * inspector/report-protocol-errors-expected.txt: Added.
+        * inspector/report-protocol-errors.html: Added.
+
 2010-08-31  Tony Chang  <tony at chromium.org>
 
         Unreviewed, updating chromium test_expectations.txt.
diff --git a/LayoutTests/http/tests/inspector/inspector-test2.js b/LayoutTests/http/tests/inspector/inspector-test2.js
index 4fb562b..4cb3141 100644
--- a/LayoutTests/http/tests/inspector/inspector-test2.js
+++ b/LayoutTests/http/tests/inspector/inspector-test2.js
@@ -166,11 +166,30 @@ function didEvaluateForTestInFrontend(callId, result)
     }, 0);
 }
 
+function dump(data)
+{
+    if (typeof data === "string") {
+        output(data);
+        return;
+    }
+
+    if (typeof data === "object") {
+        dumpObject(data);
+        return;
+    }
+
+    if (typeof data === "array") {
+        for (var i = 0; i < result.length; ++i)
+            dump(result[i]);
+        return;
+    }
+}
+
 function dumpArray(result)
 {
     if (result instanceof Array) {
         for (var i = 0; i < result.length; ++i)
-            output(result[i]);
+            dump(result[i]);
     } else
         output(result);
 }
diff --git a/LayoutTests/inspector/report-protocol-errors-expected.txt b/LayoutTests/inspector/report-protocol-errors-expected.txt
new file mode 100644
index 0000000..00da032
--- /dev/null
+++ b/LayoutTests/inspector/report-protocol-errors-expected.txt
@@ -0,0 +1,89 @@
+Tests that InspectorBackendDispatcher is catching incorrect messages.
+
+{
+    seq : 0
+    success : false
+    errors : {
+        0 : "Protocol Error: Invalid message format. Message should be in JSON format."
+    }
+}
+{
+    seq : 0
+    success : false
+    errors : {
+        0 : "Protocol Error: Invalid message format. 'command' property wasn't found."
+    }
+}
+{
+    seq : 0
+    success : false
+    errors : {
+        0 : "Protocol Error: Invalid message format. The type of 'command' property should be string."
+    }
+}
+{
+    seq : 0
+    success : false
+    errors : {
+        0 : "Protocol Error: Invalid message format. 'seq' property was not found in the request."
+    }
+}
+{
+    seq : 0
+    success : false
+    errors : {
+        0 : "Protocol Error: Invalid message format. The type of 'seq' property should be number."
+    }
+}
+{
+    seq : 1
+    success : false
+    errors : {
+        0 : "Protocol Error: Invalid command was received. 'test' wasn't found."
+    }
+}
+{
+    seq : 2
+    success : false
+    errors : {
+        0 : "Protocol Error: 'arguments' property with type 'object' was not found."
+    }
+}
+{
+    seq : 3
+    success : false
+    errors : {
+        0 : "Protocol Error: 'arguments' property with type 'object' was not found."
+    }
+}
+{
+    seq : 4
+    success : false
+    errors : {
+        0 : "Protocol Error: Argument 'identifier' with type 'Number' was not found."
+    }
+}
+{
+    seq : 5
+    success : false
+    errors : {
+        0 : "Protocol Error: Argument 'identifier' has wrong type. It should be 'Number'."
+    }
+}
+{
+    seq : 6
+    success : false
+    errors : {
+        0 : "Protocol Error: Debug handler is not available."
+        1 : "Protocol Error: Argument 'sourceID' with type 'String' was not found."
+        2 : "Protocol Error: Argument 'lineNumber' with type 'Number' was not found."
+    }
+}
+{
+    seq : 7
+    success : false
+    errors : {
+        0 : "Protocol Error: Debug handler is not available."
+    }
+}
+
diff --git a/LayoutTests/inspector/report-protocol-errors.html b/LayoutTests/inspector/report-protocol-errors.html
new file mode 100644
index 0000000..d0364b6
--- /dev/null
+++ b/LayoutTests/inspector/report-protocol-errors.html
@@ -0,0 +1,47 @@
+<html>
+<head>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script>
+
+function test()
+{
+    var messages = [
+        'some wrong string',
+        '{}',
+        '{"command":1}',
+        '{"command":"test"}',
+        '{"seq":"not a number","command":"test"}',
+        '{"seq":1,"command":"test"}',
+        '{"seq":2,"command":"getResourceContent"}',
+        '{"seq":3,"command":"getResourceContent","arguments":[]}',
+        '{"seq":4,"command":"getResourceContent","arguments":{}}',
+        '{"seq":5,"command":"getResourceContent","arguments":{"identifier":"not a number"}}',
+        '{"seq":6,"command":"removeBreakpoint","arguments":{}}',
+        '{"seq":7,"command":"removeBreakpoint","arguments":{"sourceID":"someSourceId","lineNumber":0}}',
+
+    ];
+    var numberOfReports = 0;
+
+    function callback(message)
+    {
+        InspectorTest.addResult(message);
+
+        if (++numberOfReports === messages.length)
+            InspectorTest.completeTest();
+    }
+
+    InspectorTest._addSniffer(WebInspector, "reportProtocolError", callback, true);
+    for (var message in messages)
+        InspectorFrontendHost.sendMessageToBackend(messages[message]);
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+<p>
+Tests that InspectorBackendDispatcher is catching incorrect messages.
+</p>
+
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3593155..f682fdd 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,20 @@
+2010-08-31  Ilya Tikhonovsky  <loislo at chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        WebInspector: The parser of Inspector protocol messages should be covered by a test.
+
+        The inspector protocol is based on messages in JSON format.
+        Each message should be a JSON object with a number of properties.
+        InspectorBackendDispatcher is parsing these messages and should be
+        able to detect wrong formatted messages.
+        It has these functionality but no tests for it.
+
+        https://bugs.webkit.org/show_bug.cgi?id=44947
+
+
+        * inspector/CodeGeneratorInspector.pm:
+
 2010-08-31  Anton Muhin  <antonm at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/WebCore/inspector/CodeGeneratorInspector.pm b/WebCore/inspector/CodeGeneratorInspector.pm
index b32e7db..d76fbd3 100644
--- a/WebCore/inspector/CodeGeneratorInspector.pm
+++ b/WebCore/inspector/CodeGeneratorInspector.pm
@@ -211,7 +211,7 @@ sub GenerateInterface
     $backendJSStubName = $className . "BackendStub";
     my @backendHead;
     push(@backendHead, "    ${backendClassName}(InspectorController* inspectorController) : m_inspectorController(inspectorController) { }");
-    push(@backendHead, "    void reportProtocolError(const long callId, const String& method, const String& errorText) const;");
+    push(@backendHead, "    void reportProtocolError(const long callId, const String& errorText) const;");
     push(@backendHead, "    void dispatch(const String& message);");
     push(@backendHead, "    static bool getCommandName(const String& message, String* result);");
     $backendConstructor = join("\n", @backendHead);
@@ -306,7 +306,7 @@ sub generateBackendFunction
     my $domainAccessor = $typeTransform{$domain}->{"domainAccessor"};
     $backendTypes{$domain} = 1;
     push(@function, "    if (!$domainAccessor)");
-    push(@function, "        protocolErrors->pushString(String::format(\"Error: %s handler is not available.\", \"$domain\"));");
+    push(@function, "        protocolErrors->pushString(String::format(\"Protocol Error: %s handler is not available.\", \"$domain\"));");
     push(@function, "");
 
     if (scalar(@inArgs)) {
@@ -316,7 +316,7 @@ sub generateBackendFunction
         push(@function, "");
         push(@function, "    RefPtr<InspectorObject> argumentsContainer;");
         push(@function, "    if (!(argumentsContainer = requestMessageObject->getObject(\"arguments\"))) {");
-        push(@function, "        protocolErrors->pushString(String::format(\"Error: arguments object was not found.\"));");
+        push(@function, "        protocolErrors->pushString(String::format(\"Protocol Error: 'arguments' property with type 'object' was not found.\"));");
         push(@function, "    } else {");
         push(@function, "        InspectorObject::const_iterator argumentsEndIterator = argumentsContainer->end();");
 
@@ -329,10 +329,10 @@ sub generateBackendFunction
             push(@function, "");
             push(@function, "        InspectorObject::const_iterator ${name}ValueIterator = argumentsContainer->find(\"$name\");");
             push(@function, "        if (${name}ValueIterator == argumentsEndIterator) {");
-            push(@function, "            protocolErrors->pushString(String::format(\"Error: Argument '%s' with type '%s' was not found.\", \"$name\", \"$JSONType\"));");
+            push(@function, "            protocolErrors->pushString(String::format(\"Protocol Error: Argument '%s' with type '%s' was not found.\", \"$name\", \"$JSONType\"));");
             push(@function, "        } else {");
             push(@function, "            if (!${name}ValueIterator->second->as$JSONType(&$name)) {");
-            push(@function, "                protocolErrors->pushString(String::format(\"Error: Argument '%s' has wrong type. It should be '%s'.\", \"$name\", \"$JSONType\"));");
+            push(@function, "                protocolErrors->pushString(String::format(\"Protocol Error: Argument '%s' has wrong type. It should be '%s'.\", \"$name\", \"$JSONType\"));");
             push(@function, "            }");
             push(@function, "        }");
         }
@@ -375,13 +375,10 @@ sub generateBackendReportProtocolError
 {
     my $reportProtocolError = << "EOF";
 
-void ${backendClassName}::reportProtocolError(const long callId, const String& method, const String& errorText) const
+void ${backendClassName}::reportProtocolError(const long callId, const String& errorText) const
 {
     RefPtr<InspectorObject> message = InspectorObject::create();
     message->setNumber("seq", callId);
-    message->setString("type", "error");
-    message->setString("domain", "inspectorProtocol");
-    message->setString("command", method);
     message->setBoolean("success", false);
     RefPtr<InspectorArray> errors = InspectorArray::create();
     errors->pushString(errorText);
@@ -414,42 +411,42 @@ $mapEntries
 
     RefPtr<InspectorValue> parsedMessage = InspectorValue::parseJSON(message);
     if (!parsedMessage) {
-        reportProtocolError(callId, "dispatch", "Error: Invalid message format. Message should be in JSON format.");
+        reportProtocolError(callId, "Protocol Error: Invalid message format. Message should be in JSON format.");
         return;
     }
 
     RefPtr<InspectorObject> messageObject = parsedMessage->asObject();
     if (!messageObject) {
-        reportProtocolError(callId, "dispatch", "Error: Invalid message format. The message should be a JSONified object.");
+        reportProtocolError(callId, "Protocol Error: Invalid message format. The message should be a JSONified object.");
         return;
     }
 
     RefPtr<InspectorValue> commandValue = messageObject->get("command");
     if (!commandValue) {
-        reportProtocolError(callId, "dispatch", "Error: Invalid message format. 'command' property wasn't found.");
+        reportProtocolError(callId, "Protocol Error: Invalid message format. 'command' property wasn't found.");
         return;
     }
 
     String command;
     if (!commandValue->asString(&command)) {
-        reportProtocolError(callId, "dispatch", "Error: Invalid message format. The type of 'command' property should be string.");
+        reportProtocolError(callId, "Protocol Error: Invalid message format. The type of 'command' property should be string.");
         return;
     }
 
     RefPtr<InspectorValue> callIdValue = messageObject->get("seq");
     if (!callIdValue) {
-        reportProtocolError(callId, command.utf8().data(), "Error: Invalid message format. 'seq' property was not found in the request.");
+        reportProtocolError(callId, "Protocol Error: Invalid message format. 'seq' property was not found in the request.");
         return;
     }
 
     if (!callIdValue->asNumber(&callId)) {
-        reportProtocolError(callId, command.utf8().data(), "Error: Invalid message format. the type of 'seq' property should be number.");
+        reportProtocolError(callId, "Protocol Error: Invalid message format. The type of 'seq' property should be number.");
         return;
     }
 
     HashMap<String, CallHandler>::iterator it = dispatchMap.find(command);
     if (it == dispatchMap.end()) {
-        reportProtocolError(callId, "dispatch", String::format("Error: Invalid command was received. '%s' wasn't found.", command.utf8().data()));
+        reportProtocolError(callId, String::format("Protocol Error: Invalid command was received. '%s' wasn't found.", command.utf8().data()));
         return;
     }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list