1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/debug/Frame-onPop-throw-error.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,59 @@ 1.4 +// |jit-test| error: TestComplete 1.5 +// onPop can change a throw into a termination. 1.6 + 1.7 +var g = newGlobal(); 1.8 +var dbg = new Debugger(g); 1.9 + 1.10 +// We use Debugger.Frame.prototype.eval and ignore the outer 'eval' frame so we 1.11 +// can catch the termination. 1.12 + 1.13 +function test(type, provocation) { 1.14 + // Help people figure out which 'test' call failed. 1.15 + print("type: " + uneval(type)); 1.16 + print("provocation: " + uneval(provocation)); 1.17 + 1.18 + var log; 1.19 + dbg.onEnterFrame = function handleFirstFrame(f) { 1.20 + log += 'f'; 1.21 + dbg.onDebuggerStatement = function handleDebugger(f) { 1.22 + log += 'd'; 1.23 + }; 1.24 + 1.25 + dbg.onEnterFrame = function handleSecondFrame(f) { 1.26 + log += 'e'; 1.27 + assertEq(f.type, 'eval'); 1.28 + 1.29 + dbg.onEnterFrame = function handleThirdFrame(f) { 1.30 + log += '('; 1.31 + assertEq(f.type, type); 1.32 + 1.33 + dbg.onEnterFrame = function handleExtraFrames(f) { 1.34 + // This should never be called. 1.35 + assertEq(false, true); 1.36 + }; 1.37 + 1.38 + f.onPop = function handlePop(c) { 1.39 + log += ')'; 1.40 + assertEq(c.throw, 'mud'); 1.41 + return null; 1.42 + }; 1.43 + }; 1.44 + }; 1.45 + 1.46 + assertEq(f.eval(provocation), null); 1.47 + }; 1.48 + 1.49 + log = ''; 1.50 + // This causes handleFirstFrame to be called. 1.51 + assertEq(typeof g.eval('eval'), 'function'); 1.52 + assertEq(log, 'fe(d)'); 1.53 + 1.54 + print(); 1.55 +} 1.56 + 1.57 +g.eval('function f() { debugger; throw \'mud\'; }'); 1.58 +test('call', 'f();'); 1.59 +test('call', 'new f;'); 1.60 +test('eval', 'eval(\'debugger; throw \\\'mud\\\';\');'); 1.61 +test('global', 'evaluate(\'debugger; throw \\\'mud\\\';\');'); 1.62 +throw 'TestComplete';