michael@0: // Basic getChildScripts tests. michael@0: michael@0: var g = newGlobal(); michael@0: var dbg = new Debugger(g); michael@0: var log; michael@0: function note(s) { michael@0: assertEq(s instanceof Debugger.Script, true); michael@0: log += 'S'; michael@0: var c = s.getChildScripts(); michael@0: if (c.length > 0) { michael@0: log += '['; michael@0: for (var i = 0; i < c.length; i++) michael@0: note(c[i]); michael@0: log += ']'; michael@0: } michael@0: } michael@0: dbg.onDebuggerStatement = function (frame) { note(frame.script); }; michael@0: michael@0: function test(code, expected) { michael@0: log = ''; michael@0: g.eval(code); michael@0: assertEq(log, expected); michael@0: } michael@0: michael@0: test("debugger;", michael@0: "S"); michael@0: test("function f() {} debugger;", michael@0: "S[S]"); michael@0: test("function g() { function h() { function k() {} return k; } return h; } debugger;", michael@0: "S[S[S[S]]]"); michael@0: test("function q() {} function qq() {} debugger;", michael@0: "S[SS]"); michael@0: test("[0].map(function id(a) { return a; }); debugger;", michael@0: "S[S]"); michael@0: test("Function('return 2+2;')(); debugger;", michael@0: "S"); michael@0: test("var obj = {get x() { return 0; }, set x(v) {}}; debugger;", michael@0: "S[SS]"); michael@0: test("function r(n) { for (var i = 0; i < n; i++) yield i; } debugger;", michael@0: "S[S]"); michael@0: test("function* qux(n) { for (var i = 0; i < n; i++) yield i; } debugger;", michael@0: "S[S]"); michael@0: test("var it = (3 for (p in obj)); debugger;", michael@0: "S[S]");