OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 function TimelineModelShim() { | |
6 tracing.TimelineModel.apply(this, arguments); | |
7 } | |
8 | |
9 TimelineModelShim.prototype = { | |
10 __proto__: tracing.TimelineModel.prototype, | |
11 | |
12 invokeMethod: function(methodName, args) { | |
13 var sendToPython = function(obj) { | |
14 // We use sendJSON here because domAutomationController's send() chokes on | |
15 // large amounts of data. Inside of send() it converts the arg to JSON and | |
16 // invokes sendJSON. The JSON conversion is what fails. This way works | |
17 // around the bad code, but note that the recieving python converts from | |
18 // JSON before passing it back to the pyauto test. | |
19 window.domAutomationController.sendJSON( | |
20 JSON.stringify(obj) | |
21 ); | |
22 }; | |
23 var result; | |
24 try { | |
25 result = this[methodName].apply(this, JSON.parse(args)); | |
26 } catch( e ) { | |
27 var ret = { | |
28 success: false, | |
29 message: 'Unspecified error', | |
30 }; | |
31 // We'll try sending the entire exception. If that doesn't work, it's ok. | |
32 try { | |
33 ret.exception = JSON.stringify(e); | |
34 } catch(e2) {} | |
35 if( typeof(e) == 'string' || e instanceof String ) { | |
36 ret.message = e; | |
37 } else { | |
38 if( e.stack != undefined ) ret.stack = e.stack; | |
39 if( e.message != undefined ) ret.message = e.message; | |
40 } | |
41 sendToPython(ret); | |
42 throw e; | |
43 } | |
44 sendToPython({ | |
45 success: true, | |
46 data: result | |
47 }); | |
48 } | |
49 }, | |
50 | |
51 // This causes the PyAuto ExecuteJavascript call which executed this file to | |
52 // return. | |
53 window.domAutomationController.send(''); | |
OLD | NEW |