| 1 |
// |jit-test| error: TestComplete |
| 2 |
// onPop fires when frames are terminated. |
| 3 |
|
| 4 |
var g = newGlobal({newCompartment: true}); |
| 5 |
var dbg = new Debugger(g); |
| 6 |
|
| 7 |
// We use Debugger.Frame.prototype.eval and ignore the outer 'eval' frame so we |
| 8 |
// can catch the termination. |
| 9 |
|
| 10 |
function test(type, provocation) { |
| 11 |
// Help people figure out which 'test' call failed. |
| 12 |
print("type: " + JSON.stringify(type)); |
| 13 |
print("provocation: " + JSON.stringify(provocation)); |
| 14 |
|
| 15 |
var log; |
| 16 |
dbg.onEnterFrame = function handleFirstFrame(f) { |
| 17 |
log += 'f'; |
| 18 |
dbg.onDebuggerStatement = function handleDebugger(f) { |
| 19 |
log += 'd'; |
| 20 |
return null; |
| 21 |
}; |
| 22 |
|
| 23 |
dbg.onEnterFrame = function handleSecondFrame(f) { |
| 24 |
log += 'e'; |
| 25 |
assertEq(f.type, 'eval'); |
| 26 |
|
| 27 |
dbg.onEnterFrame = function handleThirdFrame(f) { |
| 28 |
log += '('; |
| 29 |
assertEq(f.type, type); |
| 30 |
|
| 31 |
dbg.onEnterFrame = function handleExtraFrames(f) { |
| 32 |
// This should never be called. |
| 33 |
assertEq(false, true); |
| 34 |
}; |
| 35 |
|
| 36 |
f.onPop = function handlePop(c) { |
| 37 |
log += ')'; |
| 38 |
assertEq(c, null); |
| 39 |
}; |
| 40 |
}; |
| 41 |
}; |
| 42 |
|
| 43 |
assertEq(f.eval(provocation), null); |
| 44 |
}; |
| 45 |
|
| 46 |
log = ''; |
| 47 |
// This causes handleFirstFrame to be called. |
| 48 |
assertEq(typeof g.eval('eval'), 'function'); |
| 49 |
assertEq(log, 'fe(d)'); |
| 50 |
|
| 51 |
print(); |
| 52 |
} |
| 53 |
|
| 54 |
g.eval('function f() { debugger; return \'termination fail\'; }'); |
| 55 |
test('call', 'f();'); |
| 56 |
test('call', 'new f;'); |
| 57 |
test('eval', 'eval(\'debugger; \\\'termination fail\\\';\');'); |
| 58 |
test('global', 'evaluate(\'debugger; \\\'termination fail\\\';\');'); |
| 59 |
throw 'TestComplete'; |