js/src/jit-test/tests/debug/Object-script-lazy.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 // Asking for the script of a Debugger.Object should work, even when lazy
     2 // functions are involved.
     4 // Note that we never hand out the scripts of non-debuggee functions, and
     5 // putting a compartment in debug mode automatically de-lazifies all its
     6 // functions. (This ensures that findScripts works, too.)
     7 //
     8 // So here we create a reference to a non-debuggee function, verify that we
     9 // can't access its interesting properties, make it a debuggee, and verify
    10 // that everything becomes available.
    12 // Create functions f, g in a non-debuggee compartment.
    13 var g1 = newGlobal();
    14 g1.eval('function f() { return "from f"; }');
    15 g1.eval('function g() { return "from g"; }');
    17 // Create a debuggee compartment with CCWs referring to f and g.
    18 var g2 = newGlobal();
    19 var dbg = new Debugger;
    20 var g2w = dbg.addDebuggee(g2);
    21 g2.f = g1.f;
    22 g2.g = g1.g;
    24 // At this point, g1.f should still be a lazy function. Unwrapping a D.O
    25 // referring to g2's CCW of f should yield a D.O referring to f directly.
    26 // Asking for that second D.O's script should yield null, because it's not
    27 // a debuggee.
    28 var fDO = g2w.getOwnPropertyDescriptor('f').value;
    29 assertEq(fDO.global, g2w);
    30 assertEq(fDO.unwrap().global === g2w, false);
    31 assertEq(fDO.unwrap().script, null);
    33 // Similarly for g1.g, and asking for its parameter names.
    34 var gDO = g2w.getOwnPropertyDescriptor('g').value;
    35 assertEq(gDO.global, g2w);
    36 assertEq(gDO.unwrap().global === g2w, false);
    37 assertEq(gDO.unwrap().parameterNames, undefined);
    39 // Add g1 as a debuggee, and verify that we can get everything.
    40 dbg.addDebuggee(g1);
    41 assertEq(fDO.unwrap().script instanceof Debugger.Script, true);
    42 assertEq(gDO.unwrap().parameterNames instanceof Array, true);

mercurial