michael@0: // Asking for the script of a Debugger.Object should work, even when lazy michael@0: // functions are involved. michael@0: michael@0: // Note that we never hand out the scripts of non-debuggee functions, and michael@0: // putting a compartment in debug mode automatically de-lazifies all its michael@0: // functions. (This ensures that findScripts works, too.) michael@0: // michael@0: // So here we create a reference to a non-debuggee function, verify that we michael@0: // can't access its interesting properties, make it a debuggee, and verify michael@0: // that everything becomes available. michael@0: michael@0: // Create functions f, g in a non-debuggee compartment. michael@0: var g1 = newGlobal(); michael@0: g1.eval('function f() { return "from f"; }'); michael@0: g1.eval('function g() { return "from g"; }'); michael@0: michael@0: // Create a debuggee compartment with CCWs referring to f and g. michael@0: var g2 = newGlobal(); michael@0: var dbg = new Debugger; michael@0: var g2w = dbg.addDebuggee(g2); michael@0: g2.f = g1.f; michael@0: g2.g = g1.g; michael@0: michael@0: // At this point, g1.f should still be a lazy function. Unwrapping a D.O michael@0: // referring to g2's CCW of f should yield a D.O referring to f directly. michael@0: // Asking for that second D.O's script should yield null, because it's not michael@0: // a debuggee. michael@0: var fDO = g2w.getOwnPropertyDescriptor('f').value; michael@0: assertEq(fDO.global, g2w); michael@0: assertEq(fDO.unwrap().global === g2w, false); michael@0: assertEq(fDO.unwrap().script, null); michael@0: michael@0: // Similarly for g1.g, and asking for its parameter names. michael@0: var gDO = g2w.getOwnPropertyDescriptor('g').value; michael@0: assertEq(gDO.global, g2w); michael@0: assertEq(gDO.unwrap().global === g2w, false); michael@0: assertEq(gDO.unwrap().parameterNames, undefined); michael@0: michael@0: // Add g1 as a debuggee, and verify that we can get everything. michael@0: dbg.addDebuggee(g1); michael@0: assertEq(fDO.unwrap().script instanceof Debugger.Script, true); michael@0: assertEq(gDO.unwrap().parameterNames instanceof Array, true); michael@0: