resumption-03.js (940B)
1 // Returning and throwing objects. 2 3 load(libdir + "asserts.js"); 4 5 var g = newGlobal({newCompartment: true}); 6 g.debuggeeGlobal = this; 7 g.eval("(" + function () { 8 var how, what; 9 var dbg = new Debugger(debuggeeGlobal); 10 dbg.onDebuggerStatement = function (frame) { 11 if (frame.callee.name === "configure") { 12 how = frame.arguments[0]; 13 what = frame.arguments[1]; 14 } else { 15 var resume = {}; 16 resume[how] = what; 17 return resume; 18 } 19 }; 20 } + ")();"); 21 22 function configure(how, what) { debugger; } 23 function fire() { debugger; } 24 25 var d = new Date; 26 configure('return', d); 27 assertEq(fire(), d); 28 configure('return', Math); 29 assertEq(fire(), Math); 30 31 var x = new Error('oh no what are you doing'); 32 configure('throw', x); 33 assertThrowsValue(fire, x); 34 configure('throw', parseInt); 35 assertThrowsValue(fire, parseInt);