js/src/jit-test/tests/debug/Object-script-lazy.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/Object-script-lazy.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +// Asking for the script of a Debugger.Object should work, even when lazy
     1.5 +// functions are involved.
     1.6 +
     1.7 +// Note that we never hand out the scripts of non-debuggee functions, and
     1.8 +// putting a compartment in debug mode automatically de-lazifies all its
     1.9 +// functions. (This ensures that findScripts works, too.)
    1.10 +//
    1.11 +// So here we create a reference to a non-debuggee function, verify that we
    1.12 +// can't access its interesting properties, make it a debuggee, and verify
    1.13 +// that everything becomes available.
    1.14 +
    1.15 +// Create functions f, g in a non-debuggee compartment.
    1.16 +var g1 = newGlobal();
    1.17 +g1.eval('function f() { return "from f"; }');
    1.18 +g1.eval('function g() { return "from g"; }');
    1.19 +
    1.20 +// Create a debuggee compartment with CCWs referring to f and g.
    1.21 +var g2 = newGlobal();
    1.22 +var dbg = new Debugger;
    1.23 +var g2w = dbg.addDebuggee(g2);
    1.24 +g2.f = g1.f;
    1.25 +g2.g = g1.g;
    1.26 +
    1.27 +// At this point, g1.f should still be a lazy function. Unwrapping a D.O
    1.28 +// referring to g2's CCW of f should yield a D.O referring to f directly.
    1.29 +// Asking for that second D.O's script should yield null, because it's not
    1.30 +// a debuggee.
    1.31 +var fDO = g2w.getOwnPropertyDescriptor('f').value;
    1.32 +assertEq(fDO.global, g2w);
    1.33 +assertEq(fDO.unwrap().global === g2w, false);
    1.34 +assertEq(fDO.unwrap().script, null);
    1.35 +
    1.36 +// Similarly for g1.g, and asking for its parameter names.
    1.37 +var gDO = g2w.getOwnPropertyDescriptor('g').value;
    1.38 +assertEq(gDO.global, g2w);
    1.39 +assertEq(gDO.unwrap().global === g2w, false);
    1.40 +assertEq(gDO.unwrap().parameterNames, undefined);
    1.41 +
    1.42 +// Add g1 as a debuggee, and verify that we can get everything.
    1.43 +dbg.addDebuggee(g1);
    1.44 +assertEq(fDO.unwrap().script instanceof Debugger.Script, true);
    1.45 +assertEq(gDO.unwrap().parameterNames instanceof Array, true);
    1.46 +

mercurial