js/src/jit-test/tests/debug/Frame-onPop-error.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/Frame-onPop-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 fires when frames are terminated.
     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 +            return null;
    1.24 +        };
    1.25 +
    1.26 +        dbg.onEnterFrame = function handleSecondFrame(f) {
    1.27 +            log += 'e';
    1.28 +            assertEq(f.type, 'eval');
    1.29 +
    1.30 +            dbg.onEnterFrame = function handleThirdFrame(f) {
    1.31 +                log += '(';
    1.32 +                assertEq(f.type, type);
    1.33 +
    1.34 +                dbg.onEnterFrame = function handleExtraFrames(f) {
    1.35 +                    // This should never be called.
    1.36 +                    assertEq(false, true);
    1.37 +                };
    1.38 +
    1.39 +                f.onPop = function handlePop(c) {
    1.40 +                    log += ')';
    1.41 +                    assertEq(c, 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; return \'termination fail\'; }');
    1.58 +test('call', 'f();');
    1.59 +test('call', 'new f;');
    1.60 +test('eval', 'eval(\'debugger; \\\'termination fail\\\';\');');
    1.61 +test('global', 'evaluate(\'debugger; \\\'termination fail\\\';\');');
    1.62 +throw 'TestComplete';

mercurial