js/src/jit-test/tests/debug/Frame-01.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Test .type and .generator fields of topmost stack frame passed to onDebuggerStatement.
michael@0 2
michael@0 3 var g = newGlobal();
michael@0 4 var dbg = Debugger(g);
michael@0 5 var expected, hits;
michael@0 6 dbg.onDebuggerStatement = function (f) {
michael@0 7 assertEq(Object.getPrototypeOf(f), Debugger.Frame.prototype);
michael@0 8 assertEq(f.type, expected.type);
michael@0 9 assertEq(f.generator, expected.generator);
michael@0 10 assertEq(f.constructing, expected.constructing);
michael@0 11 hits++;
michael@0 12 };
michael@0 13
michael@0 14 function test(code, expectobj, expectedHits) {
michael@0 15 expected = expectobj;
michael@0 16 hits = 0;
michael@0 17 g.evaluate(code);
michael@0 18 assertEq(hits, arguments.length < 3 ? 1 : expectedHits);
michael@0 19 }
michael@0 20
michael@0 21 test("debugger;", {type: "global", generator: false, constructing: false});
michael@0 22 test("(function () { debugger; })();", {type: "call", generator: false, constructing: false});
michael@0 23 test("new function() { debugger; };", {type: "call", generator: false, constructing: true});
michael@0 24 test("new function () { (function() { debugger; })(); }", {type: "call", generator: false, constructing: false});
michael@0 25 test("eval('debugger;');", {type: "eval", generator: false, constructing: false});
michael@0 26 test("this.eval('debugger;'); // indirect eval", {type: "eval", generator: false, constructing: false});
michael@0 27 test("(function () { eval('debugger;'); })();", {type: "eval", generator: false, constructing: false});
michael@0 28 test("new function () { eval('debugger'); }", {type: "eval", generator: false, constructing: false});
michael@0 29 test("function gen() { debugger; yield 1; debugger; }\n" +
michael@0 30 "for (var x in gen()) {}\n",
michael@0 31 {type: "call", generator: true, constructing: false}, 2);
michael@0 32 test("var iter = (function* stargen() { debugger; yield 1; debugger; })();\n" +
michael@0 33 "iter.next(); iter.next();",
michael@0 34 {type: "call", generator: true, constructing: false}, 2);

mercurial