Frame-onPop-error-scope-unwind-02.js (791B)
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 // Surround with a loop to insert a loop trynote. 19 for (;;) { 20 try { 21 eval(""); 22 throw 42; 23 } catch (e) { 24 noSuchFn(e); 25 } 26 } 27 }); 28 29 30 try { 31 g.eval("f();"); 32 } catch (e) { 33 // The above is expected to throw. 34 } 35 36 assertEq(correct, true);