|
1 // Bug 689101 - if the binary layout of jsval does not match between C and C++ |
|
2 // code, then calls to functions returning jsval may get compiled differently |
|
3 // than the callee, resulting in parameters being shifted over by one. |
|
4 // |
|
5 // An example is where on Windows, calling jsdValue.getWrappedValue() will |
|
6 // return a random floating point number instead of an object. |
|
7 // |
|
8 // This test must be run with debugging already enabled |
|
9 |
|
10 function run_test() { |
|
11 const Cc = Components.classes; |
|
12 const Ci = Components.interfaces; |
|
13 const DebuggerService = Cc["@mozilla.org/js/jsd/debugger-service;1"]; |
|
14 const jsdIDebuggerService = Ci.jsdIDebuggerService; |
|
15 var jsd = DebuggerService.getService(jsdIDebuggerService); |
|
16 |
|
17 do_check_true(jsd.isOn); |
|
18 |
|
19 var n = 0; |
|
20 function f() { |
|
21 n++; |
|
22 } |
|
23 |
|
24 jsd.enumerateScripts({ enumerateScript: function(script) { |
|
25 script.setBreakpoint(0); |
|
26 } }); |
|
27 |
|
28 jsd.breakpointHook = function(frame, type, dummy) { |
|
29 var scope = frame.scope; |
|
30 var parent = scope.jsParent; // Probably does not need to be called |
|
31 var wrapped = scope.getWrappedValue(); |
|
32 // Do not try to print 'wrapped'; it may be an internal Call object |
|
33 // that will crash when you toString it. Different bug. |
|
34 do_check_eq(typeof(wrapped), "object"); |
|
35 return Ci.jsdIExecutionHook.RETURN_CONTINUE; |
|
36 }; |
|
37 |
|
38 f(); |
|
39 |
|
40 jsd.breakpointHook = null; |
|
41 jsd = null; |
|
42 } |