Frame-onPop-source-location.js (1869B)
1 // Ensure onPop hook for the final return/yield uses the correct source location 2 // (closing '}' of the function body). 3 4 var g = newGlobal({newCompartment: true}); 5 var dbg = new Debugger(g); 6 dbg.onEnterFrame = frame => { 7 if (frame.type === "global") { 8 return; 9 } 10 frame.onPop = c => { 11 if (c.yield !== true) { 12 const data = frame.script.getOffsetMetadata(frame.offset); 13 g.log.push(`pop(${data.lineNumber}:${data.columnNumber})`); 14 } 15 }; 16 }; 17 g.evaluate(` // line 1 18 this.log = []; // 2 19 function A() { // 3 20 log.push("A"); // 4 21 if (log === null) { // 5 22 throw "fail"; // 6 23 } // 7 24 } // 8 25 function* B() { // 9 26 log.push("B"); // 10 27 if (log === null) { // 11 28 throw "fail"; // 12 29 } // 13 30 } // 14 31 async function C() { // 15 32 log.push("C"); // 16 33 if (log === null) { // 17 34 throw "fail"; // 18 35 } // 19 36 } // 20 37 let D = async () => { // 21 38 log.push("D"); // 22 39 if (log === null) { // 23 40 throw "fail"; // 24 41 } // 25 42 }; // 26 43 class E extends class {} { // 27 44 constructor() { // 28 45 log.push("E"); // 29 46 super(); // 30 47 if (log === null) { // 31 48 throw "fail"; // 32 49 } // 33 50 } // 34 51 } // 35 52 A(); 53 for (let x of B()) {} 54 C(); 55 D(); 56 new E(); 57 `); 58 assertEq(g.log.join(","), "A,pop(8:1),B,pop(14:1),C,pop(20:1),D,pop(26:1),E,pop(27:17),pop(34:5)");