Frame-onPop-throw-return.js (1297B)
1 // |jit-test| error: TestComplete 2 // onPop can change a throw into a normal return. 3 4 var g = newGlobal({newCompartment: true}); 5 var dbg = new Debugger(g); 6 7 function test(type, provocation) { 8 var log; 9 var wasConstructing; 10 11 // Help people figure out which 'test' call failed. 12 print("type: " + JSON.stringify(type)); 13 print("provocation: " + JSON.stringify(provocation)); 14 15 dbg.onDebuggerStatement = function handleDebuggerStatement(f) { 16 log += 'd'; 17 }; 18 19 dbg.onEnterFrame = function handleEnterFrame(f) { 20 log += '('; 21 assertEq(f.type, type); 22 wasConstructing = f.constructing; 23 f.onPop = function handlePop(c) { 24 log += ')'; 25 assertEq(c.throw, 'mud'); 26 return { return: 'favor' }; 27 }; 28 }; 29 30 log = ''; 31 var result = provocation(); 32 if (wasConstructing) 33 assertEq(typeof result, "object"); 34 else 35 assertEq(result, 'favor'); 36 assertEq(log, "(d)"); 37 38 print(); 39 } 40 41 g.eval("function f() { debugger; throw 'mud'; }"); 42 test("call", g.f); 43 test("call", function () { return new g.f; }); 44 test("eval", function () { return g.eval("debugger; throw \'mud\';"); }); 45 test("global", function () { return g.evaluate("debugger; throw \'mud\';"); }); 46 throw 'TestComplete';