class-derived-default-constructor-1.js (833B)
1 const g = newGlobal({newCompartment: true}); 2 g.eval(` 3 class Base {} 4 class Derived extends Base {} 5 this.Derived = Derived; 6 `); 7 8 const dbg = new Debugger(g); 9 const gw = dbg.addDebuggee(g); 10 11 let calleeCount = 0; 12 13 dbg.onEnterFrame = frame => { 14 // Ignore any other callees. 15 if (frame.callee !== gw.makeDebuggeeValue(g.Derived)) { 16 return; 17 } 18 19 calleeCount++; 20 21 const names = frame.environment.names(); 22 23 // Set all variables to |null|. This mustn't affect the implicit rest-argument 24 // of the default derived class constructor, otherwise we'll crash when 25 // passing the rest-argument to the super spread-call. 26 frame.onStep = () => { 27 names.forEach(name => { 28 frame.environment.setVariable(name, null); 29 }); 30 }; 31 }; 32 33 new g.Derived(); 34 35 // |Derived| should be called at most once. 36 assertEq(calleeCount, 1);