Index: webkit/glue/devtools/js/inject_dispatch.js |
=================================================================== |
--- webkit/glue/devtools/js/inject_dispatch.js (revision 17071) |
+++ webkit/glue/devtools/js/inject_dispatch.js (working copy) |
@@ -40,10 +40,23 @@ |
*/ |
var dispatch = function(method, var_args) { |
// Handle all messages with non-primitieve arguments here. |
- // TODO(pfeldman): Add more. |
if (method == 'inspectedWindowCleared') { |
return; |
} |
- var call = JSON.stringify(Array.prototype.slice.call(arguments)); |
+ var args = Array.prototype.slice.call(arguments); |
yurys
2009/05/28 16:28:04
you can move this in the 'if' block below
|
+ |
+ // Serialize objects here. |
+ if (method == 'addMessageToConsole') { |
+ // Skip first argument since it is serializable. |
+ for (var i = 1; i < args.length; ++i) { |
+ var type = typeof args[i]; |
+ if (type == 'object') { |
+ args[i] = Object.prototype.toString(args[i]); |
+ } else if (type == 'function') { |
+ args[i] = args[i].toString(); |
+ } |
+ } |
+ } |
+ var call = JSON.stringify(args); |
RemoteWebInspector.dispatch(call); |
}; |