OLD | NEW |
---|---|
(Empty) | |
1 function invokeJsMethodFromPython(targetObject, methodName, args) { | |
2 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
| |
3 // We use sendJSON here because domAutomationController's send() chokes | |
4 // on large amounts of data. Inside of send() it converts the arg to | |
5 // JSON and invokes sendJSON. The JSON conversion is what fails. This | |
nduca
2012/07/18 05:51:35
Why does the json conversion fail?
| |
6 // way works around the bad code, but necessitates a double JSON | |
7 // conversion as the recieving python converts from JSON before passing | |
8 // it back to the pyauto test. | |
9 window.domAutomationController.sendJSON( | |
10 JSON.stringify( | |
nduca
2012/07/18 05:51:35
I'm so confused. This makes no sense. Also, does s
| |
11 JSON.stringify(obj) | |
12 ) | |
13 ); | |
14 }; | |
15 try { | |
nduca
2012/07/18 05:51:35
Why are you sourcing this file every time? You cou
| |
16 sendToPython({ | |
nduca
2012/07/18 05:51:35
Can't you break this up into individual lines inst
| |
17 success: true, | |
18 data: targetObject[methodName].apply(targetObject, JSON.parse(args)) | |
19 }); | |
20 } catch( e ) { | |
21 var ret = { | |
22 success: false, | |
23 message: 'Unspecified error' | |
24 }; | |
25 if( typeof(e) == 'string' || e instanceof String ) { | |
26 ret.message = e; | |
27 } else { | |
28 if( e.stack != undefined ) ret.stack = e.stack; | |
29 if( e.message != undefined ) ret.message = e.message; | |
30 } | |
31 // First we'll try sending with the exception embedded, and if that | |
32 // doesn't work, try sending without the exception. | |
nduca
2012/07/18 05:51:35
What? Why?
| |
33 try { | |
34 sendToPython(ret); | |
35 } catch(e2) { | |
36 ret.exception = undefined; | |
37 sendToPython(ret); | |
38 } | |
39 throw e; | |
40 } | |
41 } | |
OLD | NEW |