Web Inspector: DevTools InspectorStubs.js incorrectly converting responses to arguments.
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Nov 2011 14:50:56 +0000 (14:50 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Nov 2011 14:50:56 +0000 (14:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=72096

JSON.parse doesn't garantee the order of keys.
We have to explicitly order the results according to Inspector.json spec.

Patch by Mike Lewis <mikelikespie@gmail.com> on 2011-11-11
Reviewed by Pavel Feldman.

* inspector/CodeGeneratorInspector.py:

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/CodeGeneratorInspector.py

index 4a450753ac06d435bf44459b0a41f8e5befb1a12..8fb57db6d225ea35777066239eef6e025e82d53f 100644 (file)
@@ -1,3 +1,15 @@
+2011-11-11  Mike Lewis <mikelikespie@gmail.com>
+
+        Web Inspector: DevTools InspectorStubs.js incorrectly converting responses to arguments.
+        https://bugs.webkit.org/show_bug.cgi?id=72096
+
+        JSON.parse doesn't garantee the order of keys.
+        We have to explicitly order the results according to Inspector.json spec.
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/CodeGeneratorInspector.py:
+
 2011-11-10  Andreas Kling  <kling@webkit.org>
 
         Remove ability to call HTMLCollections in V8 bindings as well.
index 41f3b84fb84b124884f61e4a7ff41471395ae5e8..33b5f189c92d9591a0016bee187e56d56c60bfed 100644 (file)
@@ -939,7 +939,8 @@ InspectorBackendStub = function()
     this._callbacks = {};
     this._domainDispatchers = {};
     this._eventArgs = {};
-$delegates$eventArgs$domainDispatchers    }
+    this._replyArgs = {};
+$delegates$eventArgs$replyArgs$domainDispatchers}
 
 InspectorBackendStub.prototype = {
     dumpInspectorTimeStats: 0,
@@ -1020,11 +1021,11 @@ InspectorBackendStub.prototype = {
     {
         messageObject.id = this._wrap(callback);
 
-        if (this.dumpInspectorTimeStats) {
-            var wrappedCallback = this._callbacks[messageObject.id];
-            wrappedCallback.methodName = messageObject.method;
+        var wrappedCallback = this._callbacks[messageObject.id];
+        wrappedCallback.methodName = messageObject.method;
+
+        if (this.dumpInspectorTimeStats)
             wrappedCallback.sendRequestTime = Date.now();
-        }
 
         if (this.dumpInspectorProtocolMessages)
             console.log("frontend: " + JSON.stringify(messageObject));
@@ -1083,13 +1084,17 @@ InspectorBackendStub.prototype = {
                     this.reportProtocolError(messageObject);
             }
 
+            var callback = this._callbacks[messageObject.id];
+
             var arguments = [];
             if (messageObject.result) {
-                for (var key in messageObject.result)
-                    arguments.push(messageObject.result[key]);
+                var paramNames = this._replyArgs[callback.methodName];
+                if (paramNames) {
+                    for (var i = 0; i < paramNames.length; ++i)
+                        arguments.push(messageObject.result[paramNames[i]]);
+                }
             }
 
-            var callback = this._callbacks[messageObject.id];
             if (callback) {
                 var processingStartTime;
                 if (this.dumpInspectorTimeStats && callback.methodName)
@@ -1191,6 +1196,7 @@ class Generator:
     frontend_method_list = []
     backend_js_initializer_list = []
     backend_js_event_list = []
+    backend_js_reply_list = []
     backend_js_domain_dispatcher_list = []
 
     backend_constructor_param_list = []
@@ -1306,6 +1312,7 @@ class Generator:
         method_out_code = ""
         agent_call_param_list = []
         response_cook_list = []
+        backend_js_reply_param_list = []
         request_message_param = ""
         js_parameters_text = ""
         if "parameters" in json_command:
@@ -1364,6 +1371,12 @@ class Generator:
                 method_out_code += code
                 agent_call_param_list.append(param)
                 response_cook_list.append(cook)
+
+                backend_js_reply_param_list.append("\"%s\"" % json_return_name)
+
+            Generator.backend_js_reply_list.append("    this._replyArgs[\"%s.%s\"] = [%s];\n" % (
+                domain_name, json_command_name, join(backend_js_reply_param_list, ", ")))
+
             response_cook_text = "    if (!protocolErrors->length() && !error.length()) {\n%s    }\n" % join(response_cook_list, "")
 
         Generator.backend_method_implementation_list.append(Templates.backend_method.substitute(None,
@@ -1376,7 +1389,7 @@ class Generator:
             responseCook=response_cook_text))
         Generator.backend_method_name_declaration_list.append("    \"%s.%s\"," % (domain_name, json_command_name))
 
-        Generator.backend_js_initializer_list.append("        this._registerDelegate('{\"method\": \"%s.%s\"%s, \"id\": 0}');\n" % (domain_name, json_command_name, js_parameters_text))
+        Generator.backend_js_initializer_list.append("    this._registerDelegate('{\"method\": \"%s.%s\"%s, \"id\": 0}');\n" % (domain_name, json_command_name, js_parameters_text))
 
 
 Generator.go()
@@ -1414,6 +1427,7 @@ backend_cpp_file.write(Templates.backend_cpp.substitute(None,
 
 backend_js_file.write(Templates.backend_js.substitute(None,
     delegates=join(Generator.backend_js_initializer_list, ""),
+    replyArgs=join(Generator.backend_js_reply_list, ""),
     eventArgs=join(Generator.backend_js_event_list, ""),
     domainDispatchers=join(Generator.backend_js_domain_dispatcher_list, "")))