Script-prologue-offsets.js (1525B)
1 let g = newGlobal({newCompartment: true}); 2 let dbg = new Debugger(g); 3 let count = 0; 4 dbg.onEnterFrame = function(frame) { 5 if (frame.type === "eval") { 6 return; 7 } 8 9 // This test assumes the hello1 and hello2 functions have prologue bytecode. 10 assertEq(frame.script.mainOffset > 0, true); 11 12 // Prologue bytecode ops are never marked as break/step points. 13 let prologueData = frame.script.getOffsetMetadata(0); 14 assertEq(prologueData.isBreakpoint, false); 15 assertEq(prologueData.isStepStart, false); 16 17 // Prologue ops are also never marked as entry points. 18 let location = frame.script.getOffsetLocation(0); 19 assertEq(location.isEntryPoint, false); 20 if (count == 0) { 21 // hello1 22 assertEq(location.lineNumber, 3); 23 assertEq(location.columnNumber, 5); 24 } else { 25 // hello2 26 assertEq(location.lineNumber, 5); 27 assertEq(location.columnNumber, 18); 28 } 29 30 // getPossibleBreakpointOffsets shouldn't return prologue offsets. 31 for (let offset of frame.script.getPossibleBreakpointOffsets()) { 32 assertEq(offset >= frame.script.mainOffset, true); 33 } 34 35 count++; 36 }; 37 g.eval(` // 1 38 function hello1(name) { // 2 39 return [].some((r) => r === name); // 3 40 } // 4 41 function hello2(name, x=1) { // 5 42 return [].some((r) => r === name); // 6 43 } // 7 44 hello1("world"); // 8 45 hello2("world"); // 9 46 `); 47 48 assertEq(count, 2);