| 1 |
// Test behavior of isInCatchScope on frame from loop iterator |
| 2 |
|
| 3 |
load(libdir + "asserts.js"); |
| 4 |
|
| 5 |
var g = newGlobal({newCompartment: true}); |
| 6 |
var dbg = Debugger(g); |
| 7 |
var hit = false; |
| 8 |
dbg.onExceptionUnwind = function (frame, exc) { |
| 9 |
// onExceptionUnwind is called multiple times as the stack is unwound. |
| 10 |
// Only check the first hit. |
| 11 |
assertEq(frame instanceof Debugger.Frame, true); |
| 12 |
assertEq(exc, 16); |
| 13 |
if (!hit) { |
| 14 |
hit = true; |
| 15 |
{ |
| 16 |
assertEq(frame.type, "call"); |
| 17 |
assertEq(frame.callee.name, "foo"); |
| 18 |
assertEq(frame.older.type, "call"); |
| 19 |
const { lineNumber, columnNumber } = frame.script.getOffsetMetadata(frame.offset); |
| 20 |
assertEq(lineNumber, 3); |
| 21 |
assertEq(columnNumber, 5); |
| 22 |
|
| 23 |
const isInCatchScope = frame.script.isInCatchScope(frame.offset); |
| 24 |
assertEq(isInCatchScope, false); |
| 25 |
} |
| 26 |
|
| 27 |
{ |
| 28 |
const { older } = frame; |
| 29 |
assertEq(older.type, "call"); |
| 30 |
assertEq(older.callee.name, "f"); |
| 31 |
assertEq(older.type, "call"); |
| 32 |
const { lineNumber, columnNumber } = older.script.getOffsetMetadata(older.offset); |
| 33 |
assertEq(lineNumber, 7); |
| 34 |
assertEq(columnNumber, 5); |
| 35 |
|
| 36 |
const isInCatchScope = older.script.isInCatchScope(older.offset); |
| 37 |
assertEq(isInCatchScope, false); |
| 38 |
} |
| 39 |
} |
| 40 |
}; |
| 41 |
|
| 42 |
g.eval( |
| 43 |
`function f() { |
| 44 |
function foo() { |
| 45 |
throw 16; // <= first frame on exception is here |
| 46 |
} |
| 47 |
|
| 48 |
for (const _ of [1]) { |
| 49 |
foo(); // <= second frame, "older" is here |
| 50 |
} |
| 51 |
} |
| 52 |
`); |
| 53 |
assertThrowsValue(function () { g.eval("f();"); }, 16); |
| 54 |
assertEq(hit, true); |