js/jsd/test/test_jsval_retval.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial