Index: chrome/test/functional/tracing/timeline_model.js |
diff --git a/chrome/test/functional/tracing/timeline_model.js b/chrome/test/functional/tracing/timeline_model.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6c29075ea45e4c99b1026cad5eb8522f912f9061 |
--- /dev/null |
+++ b/chrome/test/functional/tracing/timeline_model.js |
@@ -0,0 +1,41 @@ |
+function invokeJsMethodFromPython(targetObject, methodName, args) { |
+ var sendToPython = function(obj) { |
nduca
2012/07/18 05:51:35
How about this being tracing_test_shim.js -- and f
nduca
2012/07/18 05:51:35
This is a private method, only to be called by the
|
+ // We use sendJSON here because domAutomationController's send() chokes |
+ // on large amounts of data. Inside of send() it converts the arg to |
+ // JSON and invokes sendJSON. The JSON conversion is what fails. This |
nduca
2012/07/18 05:51:35
Why does the json conversion fail?
|
+ // way works around the bad code, but necessitates a double JSON |
+ // conversion as the recieving python converts from JSON before passing |
+ // it back to the pyauto test. |
+ window.domAutomationController.sendJSON( |
+ JSON.stringify( |
nduca
2012/07/18 05:51:35
I'm so confused. This makes no sense. Also, does s
|
+ JSON.stringify(obj) |
+ ) |
+ ); |
+ }; |
+ try { |
nduca
2012/07/18 05:51:35
Why are you sourcing this file every time? You cou
|
+ sendToPython({ |
nduca
2012/07/18 05:51:35
Can't you break this up into individual lines inst
|
+ success: true, |
+ data: targetObject[methodName].apply(targetObject, JSON.parse(args)) |
+ }); |
+ } catch( e ) { |
+ var ret = { |
+ success: false, |
+ message: 'Unspecified error' |
+ }; |
+ if( typeof(e) == 'string' || e instanceof String ) { |
+ ret.message = e; |
+ } else { |
+ if( e.stack != undefined ) ret.stack = e.stack; |
+ if( e.message != undefined ) ret.message = e.message; |
+ } |
+ // First we'll try sending with the exception embedded, and if that |
+ // doesn't work, try sending without the exception. |
nduca
2012/07/18 05:51:35
What? Why?
|
+ try { |
+ sendToPython(ret); |
+ } catch(e2) { |
+ ret.exception = undefined; |
+ sendToPython(ret); |
+ } |
+ throw e; |
+ } |
+} |