1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/jsd/test/test_jsval_retval.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,42 @@ 1.4 +// Bug 689101 - if the binary layout of jsval does not match between C and C++ 1.5 +// code, then calls to functions returning jsval may get compiled differently 1.6 +// than the callee, resulting in parameters being shifted over by one. 1.7 +// 1.8 +// An example is where on Windows, calling jsdValue.getWrappedValue() will 1.9 +// return a random floating point number instead of an object. 1.10 +// 1.11 +// This test must be run with debugging already enabled 1.12 + 1.13 +function run_test() { 1.14 + const Cc = Components.classes; 1.15 + const Ci = Components.interfaces; 1.16 + const DebuggerService = Cc["@mozilla.org/js/jsd/debugger-service;1"]; 1.17 + const jsdIDebuggerService = Ci.jsdIDebuggerService; 1.18 + var jsd = DebuggerService.getService(jsdIDebuggerService); 1.19 + 1.20 + do_check_true(jsd.isOn); 1.21 + 1.22 + var n = 0; 1.23 + function f() { 1.24 + n++; 1.25 + } 1.26 + 1.27 + jsd.enumerateScripts({ enumerateScript: function(script) { 1.28 + script.setBreakpoint(0); 1.29 + } }); 1.30 + 1.31 + jsd.breakpointHook = function(frame, type, dummy) { 1.32 + var scope = frame.scope; 1.33 + var parent = scope.jsParent; // Probably does not need to be called 1.34 + var wrapped = scope.getWrappedValue(); 1.35 + // Do not try to print 'wrapped'; it may be an internal Call object 1.36 + // that will crash when you toString it. Different bug. 1.37 + do_check_eq(typeof(wrapped), "object"); 1.38 + return Ci.jsdIExecutionHook.RETURN_CONTINUE; 1.39 + }; 1.40 + 1.41 + f(); 1.42 + 1.43 + jsd.breakpointHook = null; 1.44 + jsd = null; 1.45 +}