Frame-onPop-error-scope-unwind-01.js (710B)
1 // Tests that exception handling works with block scopes. 2 3 var g = newGlobal({newCompartment: true}); 4 var dbg = new Debugger(g); 5 var correct; 6 dbg.onEnterFrame = function (f) { 7 if (f.callee && f.callee.name == "f") { 8 f.onPop = function() { 9 // The scope at the point of onPop is at the point of popping (the 10 // noSuchFn call). 11 correct = (f.environment.getVariable("e") === 42 && 12 f.environment.getVariable("outer") === undefined); 13 }; 14 } 15 }; 16 g.eval("" + function f() { 17 var outer = 43; 18 try { 19 eval(""); 20 throw 42; 21 } catch (e) { 22 noSuchFn(e); 23 } 24 }); 25 26 27 try { 28 g.eval("f();"); 29 } catch (e) { 30 // The above is expected to throw. 31 } 32 33 assertEq(correct, true);