Script-source-01.js (714B)
1 /* 2 * Script.prototype.source should be an object. Moreover, it should be the 3 * same object for each child script within the same debugger. 4 */ 5 let g = newGlobal({newCompartment: true}); 6 let dbg = new Debugger(g); 7 8 let count = 0; 9 dbg.onNewScript = function (script) { 10 assertEq(typeof script.source, "object"); 11 function traverse(script) { 12 ++count; 13 script.getChildScripts().forEach(function (child) { 14 assertEq(child.source, script.source); 15 traverse(child); 16 }); 17 } 18 traverse(script); 19 } 20 21 g.eval("2 * 3"); 22 g.eval("function f() {}"); 23 g.eval("function f() { function g() {} }"); 24 g.eval("eval('2 * 3')"); 25 g.eval("new Function('2 * 3')"); 26 assertEq(count, 10);