js/jsd/test/test_jsval_retval.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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
    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);
    17     do_check_true(jsd.isOn);
    19     var n = 0;
    20     function f() {
    21         n++;
    22     }
    24     jsd.enumerateScripts({ enumerateScript: function(script) {
    25         script.setBreakpoint(0);
    26     } });
    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     };
    38     f();
    40     jsd.breakpointHook = null;
    41     jsd = null;
    42 }

mercurial