js/src/jit-test/tests/debug/Script-getChildScripts-01.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.

michael@0 1 // Basic getChildScripts tests.
michael@0 2
michael@0 3 var g = newGlobal();
michael@0 4 var dbg = new Debugger(g);
michael@0 5 var log;
michael@0 6 function note(s) {
michael@0 7 assertEq(s instanceof Debugger.Script, true);
michael@0 8 log += 'S';
michael@0 9 var c = s.getChildScripts();
michael@0 10 if (c.length > 0) {
michael@0 11 log += '[';
michael@0 12 for (var i = 0; i < c.length; i++)
michael@0 13 note(c[i]);
michael@0 14 log += ']';
michael@0 15 }
michael@0 16 }
michael@0 17 dbg.onDebuggerStatement = function (frame) { note(frame.script); };
michael@0 18
michael@0 19 function test(code, expected) {
michael@0 20 log = '';
michael@0 21 g.eval(code);
michael@0 22 assertEq(log, expected);
michael@0 23 }
michael@0 24
michael@0 25 test("debugger;",
michael@0 26 "S");
michael@0 27 test("function f() {} debugger;",
michael@0 28 "S[S]");
michael@0 29 test("function g() { function h() { function k() {} return k; } return h; } debugger;",
michael@0 30 "S[S[S[S]]]");
michael@0 31 test("function q() {} function qq() {} debugger;",
michael@0 32 "S[SS]");
michael@0 33 test("[0].map(function id(a) { return a; }); debugger;",
michael@0 34 "S[S]");
michael@0 35 test("Function('return 2+2;')(); debugger;",
michael@0 36 "S");
michael@0 37 test("var obj = {get x() { return 0; }, set x(v) {}}; debugger;",
michael@0 38 "S[SS]");
michael@0 39 test("function r(n) { for (var i = 0; i < n; i++) yield i; } debugger;",
michael@0 40 "S[S]");
michael@0 41 test("function* qux(n) { for (var i = 0; i < n; i++) yield i; } debugger;",
michael@0 42 "S[S]");
michael@0 43 test("var it = (3 for (p in obj)); debugger;",
michael@0 44 "S[S]");

mercurial