[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:27 UTC 2010


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

    2010-08-30  Ilya Tikhonovsky  <loislo at chromium.org>
    
            Reviewed by Joseph Pecoraro.
    
            WebInspector: it'd be better to introduce inspector API related tests.
    
            As far as we have some kind of API for Inspector
            it'd be better to have API related tests. This is the test
            for API wrappers. These wrappers are tracking the types of arguments
            of API functions.
    
            https://bugs.webkit.org/show_bug.cgi?id=44875
    
            Test: inspector/protocol-error.html
    
            * inspector/CodeGeneratorInspector.pm:
            * inspector/front-end/inspector.js:
            (WebInspector_syncDispatch):
            (WebInspector.reportProtocolError):
    
    2010-08-30  Ilya Tikhonovsky  <loislo at chromium.org>
    
            Reviewed by Joseph Pecoraro.
    
            WebInspector: it'd be better to introduce inspector API related tests.
    
            As far as we have some kind of API for Inspector
            it'd be better to have API related tests. This is the test
            for API wrappers. These wrappers are tracking the types of arguments
            of API functions.
    
            https://bugs.webkit.org/show_bug.cgi?id=44875
    
            * inspector/protocol-error-expected.txt: Added.
            * inspector/protocol-error.html: Added.
    
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66516 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index c35157c..51484ce 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,19 @@
+2010-08-30  Ilya Tikhonovsky  <loislo at chromium.org>
+
+        Reviewed by Joseph Pecoraro.
+
+        WebInspector: it'd be better to introduce inspector API related tests.
+
+        As far as we have some kind of API for Inspector
+        it'd be better to have API related tests. This is the test
+        for API wrappers. These wrappers are tracking the types of arguments
+        of API functions.
+
+        https://bugs.webkit.org/show_bug.cgi?id=44875
+
+        * inspector/protocol-error-expected.txt: Added.
+        * inspector/protocol-error.html: Added.
+
 2010-08-31  Evan Martin  <evan at chromium.org>
 
         Reviewed by Tony Chang.
diff --git a/LayoutTests/inspector/report-API-errors-expected.txt b/LayoutTests/inspector/report-API-errors-expected.txt
new file mode 100644
index 0000000..d3e5072
--- /dev/null
+++ b/LayoutTests/inspector/report-API-errors-expected.txt
@@ -0,0 +1,7 @@
+Tests that InspectorBackendStub is catching incorrect arguments.
+
+Protocol Error: Invalid type of argument 'always' for 'InspectorBackend.enableResourceTracking' call. It should be 'boolean' but it is 'number'.
+Protocol Error: Invalid number of arguments for 'InspectorBackend.enableResourceTracking' call. It should have the next arguments '{"always":"boolean"}'.
+Protocol Error: Optional callback argument for 'InspectorBackend.enableResourceTracking' call should be a function but its type is 'string'.
+Protocol Error: Attempted to dispatch an unimplemented WebInspector method 'something-strange'
+
diff --git a/LayoutTests/inspector/report-API-errors.html b/LayoutTests/inspector/report-API-errors.html
new file mode 100644
index 0000000..07d0b66
--- /dev/null
+++ b/LayoutTests/inspector/report-API-errors.html
@@ -0,0 +1,32 @@
+<html>
+<head>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
+<script>
+
+function test()
+{
+    function callback()
+    {
+        InspectorTest.addResult(String.sprintf.apply(this, arguments));
+    }
+
+    InspectorTest._addSniffer(console, "error", callback, true);
+
+    InspectorBackend.enableResourceTracking(1, callback);
+    InspectorBackend.enableResourceTracking();
+    InspectorBackend.enableResourceTracking(true, "not a function");
+    WebInspector_syncDispatch('{"type": "event", "domain": "dom", "event": "something-strange", "data": {}}');
+
+    InspectorTest.completeTest();
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+<p>
+Tests that InspectorBackendStub is catching incorrect arguments.
+</p>
+
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 083587b..3bd49db 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2010-08-30  Ilya Tikhonovsky  <loislo at chromium.org>
+
+        Reviewed by Joseph Pecoraro.
+
+        WebInspector: it'd be better to introduce inspector API related tests.
+
+        As far as we have some kind of API for Inspector
+        it'd be better to have API related tests. This is the test
+        for API wrappers. These wrappers are tracking the types of arguments
+        of API functions.
+
+        https://bugs.webkit.org/show_bug.cgi?id=44875
+
+        Test: inspector/protocol-error.html
+
+        * inspector/CodeGeneratorInspector.pm:
+        * inspector/front-end/inspector.js:
+        (WebInspector_syncDispatch):
+        (WebInspector.reportProtocolError):
+
 2010-08-31  Sheriff Bot  <webkit.review.bot at gmail.com>
 
         Unreviewed, rolling out r66484.
diff --git a/WebCore/inspector/CodeGeneratorInspector.pm b/WebCore/inspector/CodeGeneratorInspector.pm
index bc650ba..b32e7db 100644
--- a/WebCore/inspector/CodeGeneratorInspector.pm
+++ b/WebCore/inspector/CodeGeneratorInspector.pm
@@ -316,7 +316,6 @@ sub generateBackendFunction
         push(@function, "");
         push(@function, "    RefPtr<InspectorObject> argumentsContainer;");
         push(@function, "    if (!(argumentsContainer = requestMessageObject->getObject(\"arguments\"))) {");
-        push(@function, "        ASSERT_NOT_REACHED();");
         push(@function, "        protocolErrors->pushString(String::format(\"Error: arguments object was not found.\"));");
         push(@function, "    } else {");
         push(@function, "        InspectorObject::const_iterator argumentsEndIterator = argumentsContainer->end();");
@@ -330,11 +329,9 @@ sub generateBackendFunction
             push(@function, "");
             push(@function, "        InspectorObject::const_iterator ${name}ValueIterator = argumentsContainer->find(\"$name\");");
             push(@function, "        if (${name}ValueIterator == argumentsEndIterator) {");
-            push(@function, "            ASSERT_NOT_REACHED();");
             push(@function, "            protocolErrors->pushString(String::format(\"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, "                ASSERT_NOT_REACHED();");
             push(@function, "                protocolErrors->pushString(String::format(\"Error: Argument '%s' has wrong type. It should be '%s'.\", \"$name\", \"$JSONType\"));");
             push(@function, "            }");
             push(@function, "        }");
@@ -417,48 +414,41 @@ $mapEntries
 
     RefPtr<InspectorValue> parsedMessage = InspectorValue::parseJSON(message);
     if (!parsedMessage) {
-        ASSERT_NOT_REACHED();
         reportProtocolError(callId, "dispatch", "Error: Invalid message format. Message should be in JSON format.");
         return;
     }
 
     RefPtr<InspectorObject> messageObject = parsedMessage->asObject();
     if (!messageObject) {
-        ASSERT_NOT_REACHED();
         reportProtocolError(callId, "dispatch", "Error: Invalid message format. The message should be a JSONified object.");
         return;
     }
 
     RefPtr<InspectorValue> commandValue = messageObject->get("command");
     if (!commandValue) {
-        ASSERT_NOT_REACHED();
         reportProtocolError(callId, "dispatch", "Error: Invalid message format. 'command' property wasn't found.");
         return;
     }
 
     String command;
     if (!commandValue->asString(&command)) {
-        ASSERT_NOT_REACHED();
         reportProtocolError(callId, "dispatch", "Error: Invalid message format. The type of 'command' property should be string.");
         return;
     }
 
     RefPtr<InspectorValue> callIdValue = messageObject->get("seq");
     if (!callIdValue) {
-        ASSERT_NOT_REACHED();
         reportProtocolError(callId, command.utf8().data(), "Error: Invalid message format. 'seq' property was not found in the request.");
         return;
     }
 
     if (!callIdValue->asNumber(&callId)) {
-        ASSERT_NOT_REACHED();
         reportProtocolError(callId, command.utf8().data(), "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()) {
-        ASSERT_NOT_REACHED();
         reportProtocolError(callId, "dispatch", String::format("Error: Invalid command was received. '%s' wasn't found.", command.utf8().data()));
         return;
     }
@@ -533,14 +523,25 @@ WebInspector.InspectorBackendStub.prototype = {
         var request = JSON.parse(args.shift());
 
         for (var key in request.arguments) {
+            if (args.length === 0) {
+                console.error("Protocol Error: Invalid number of arguments for 'InspectorBackend.%s' call. It should have the next arguments '%s'.", request.command, JSON.stringify(request.arguments));
+                return;
+            }
             var value = args.shift();
-            if (typeof value !== request.arguments[key])
-                throw("Invalid type of property " + key + ". It should be '" + request.arguments[key] + "' but it is '" + typeof value + "'." );
+            if (typeof value !== request.arguments[key]) {
+                console.error("Protocol Error: Invalid type of argument '%s' for 'InspectorBackend.%s' call. It should be '%s' but it is '%s'.", key, request.command, request.arguments[key], typeof value);
+                return;
+            }
             request.arguments[key] = value;
         }
 
-        if (args.length === 1 && typeof args[0] === "function")
+        if (args.length === 1) {
+            if (typeof args[0] !== "function") {
+                console.error("Protocol Error: Optional callback argument for 'InspectorBackend.%s' call should be a function but its type is '%s'.", request.command, typeof args[0]);
+                return;
+            }
             request.seq = WebInspector.Callback.wrap(args[0]);
+        }
 
         var message = JSON.stringify(request);
         InspectorFrontendHost.sendMessageToBackend(message);
diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js
index c8f53d7..0bff335 100644
--- a/WebCore/inspector/front-end/inspector.js
+++ b/WebCore/inspector/front-end/inspector.js
@@ -651,8 +651,8 @@ WebInspector_syncDispatch = function(message)
     }
 
     if (messageObject.type === "event") {
-        if (!messageObject.event in WebInspector) {
-            console.error("Attempted to dispatch unimplemented WebInspector method: %s", messageObject.event);
+        if (!(messageObject.event in WebInspector)) {
+            console.error("Protocol Error: Attempted to dispatch an unimplemented WebInspector method '%s'", messageObject.event);
             return;
         }
         WebInspector[messageObject.event].apply(WebInspector, arguments);
@@ -666,7 +666,7 @@ WebInspector.dispatchMessageFromBackend = function(messageObject)
 
 WebInspector.reportProtocolError = function(messageObject)
 {
-    console.error("Error: InspectorBackend request with seq = " + messageObject.seq + " failed.");
+    console.error("Protocol Error: InspectorBackend request with seq = %d failed.", messageObject.seq);
     for (var error in messageObject.errors)
         console.error("    " + error);
     WebInspector.removeResponseCallbackEntry(messageObject.seq);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list