mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1193583 - Teach Debugger tests that eval frames now always have a lexical environment. (r=jorendorff)
This commit is contained in:
parent
9228fad4d3
commit
b4e25ed468
@ -6,7 +6,7 @@ var dbg = new Debugger;
|
||||
var log;
|
||||
dbg.onEnterFrame = function (frame) {
|
||||
log += 'e';
|
||||
log += frame.environment.object.label;
|
||||
log += frame.environment.parent.object.label;
|
||||
};
|
||||
|
||||
var g1 = newGlobal();
|
||||
|
@ -19,7 +19,7 @@ function check(code, expectedType, expectedCallee) {
|
||||
assertEq(hits, 1);
|
||||
}
|
||||
|
||||
check('debugger;', 'object', null);
|
||||
check('debugger;', 'declarative', null);
|
||||
check('with({}) { debugger; };', 'with', null);
|
||||
check('let (x=1) { debugger; };', 'declarative', null);
|
||||
|
||||
@ -30,16 +30,13 @@ g.eval('function g() { h(); }');
|
||||
g.eval('function h() { debugger; }');
|
||||
check('g()', 'declarative', gw.makeDebuggeeValue(g.h));
|
||||
|
||||
// Strict direct eval gets its own environment.
|
||||
// All evals get a lexical scope.
|
||||
check('"use strict"; eval("debugger");', 'declarative', null);
|
||||
g.eval('function j() { "use strict"; eval("debugger;"); }');
|
||||
check('j()', 'declarative', null);
|
||||
|
||||
// Lenient direct eval shares eval's caller's environment,
|
||||
// although this is a great evil.
|
||||
check('eval("debugger");', 'object', null);
|
||||
g.eval('function k() { eval("debugger;"); }');
|
||||
check('k()', 'declarative', gw.makeDebuggeeValue(g.k));
|
||||
// All evals get a lexical scope.
|
||||
check('eval("debugger");', 'declarative', null);
|
||||
|
||||
g.eval('function m() { debugger; yield true; }');
|
||||
check('m().next();', 'declarative', gw.makeDebuggeeValue(g.m));
|
||||
|
@ -4,7 +4,7 @@ var g = newGlobal();
|
||||
var dbg = Debugger(g);
|
||||
var log = '';
|
||||
dbg.onDebuggerStatement = function (frame) {
|
||||
log += frame.environment.getVariable("x") + frame.environment.getVariable("y");
|
||||
log += frame.environment.parent.getVariable("x") + frame.environment.parent.getVariable("y");
|
||||
};
|
||||
g.eval("var x = 'a'; this.y = 'b'; debugger;");
|
||||
assertEq(log, 'ab');
|
||||
|
@ -4,7 +4,7 @@ var g = newGlobal();
|
||||
var dbg = Debugger(g);
|
||||
var log = '';
|
||||
dbg.onDebuggerStatement = function (frame) {
|
||||
log += frame.environment.getVariable("x") + frame.environment.getVariable("y");
|
||||
log += frame.environment.parent.getVariable("x") + frame.environment.parent.getVariable("y");
|
||||
};
|
||||
g.eval("Object.getPrototypeOf(this).x = 'a';\n" +
|
||||
"Object.prototype.y = 'b';\n" +
|
||||
|
@ -5,7 +5,7 @@ var dbg = new Debugger;
|
||||
var gw = dbg.addDebuggee(g);
|
||||
var hits = 0;
|
||||
dbg.onDebuggerStatement = function (frame) {
|
||||
var a = frame.environment.getVariable('Math');
|
||||
var a = frame.environment.parent.getVariable('Math');
|
||||
assertEq(a instanceof Debugger.Object, true);
|
||||
var b = gw.getOwnPropertyDescriptor('Math').value;
|
||||
assertEq(a, b);
|
||||
|
@ -5,7 +5,7 @@ var gw = dbg.addDebuggee(g);
|
||||
var hits = 0;
|
||||
dbg.onDebuggerStatement = function (frame) {
|
||||
hits++;
|
||||
assertEq(frame.environment.parent.getVariable('y'), true);
|
||||
assertEq(frame.environment.parent.parent.getVariable('y'), true);
|
||||
};
|
||||
|
||||
g.eval("var g;" +
|
||||
|
@ -8,7 +8,7 @@ var dbg = Debugger(g);
|
||||
var hits = 0;
|
||||
dbg.onDebuggerStatement = function (frame) {
|
||||
assertThrowsInstanceOf(function () {
|
||||
frame.environment.getVariable("x");
|
||||
frame.environment.parent.getVariable("x");
|
||||
}, Error);
|
||||
hits++;
|
||||
};
|
||||
|
@ -51,7 +51,7 @@ function test(sharedName, expectedHits, code) {
|
||||
// the optimization or with the debugger exposing it, but that's not what we
|
||||
// want to test here.)
|
||||
|
||||
test("q", 2, "var q = function (a) { h(); }; q(1); q(2);");
|
||||
test("q", 2, "let q = function (a) { h(); }; q(1); q(2);");
|
||||
test("a", 2, "q = function (a) { (function (b) { h(); a = b; })(2); h(); }; q(1);");
|
||||
test("a", 2, "q = function (a) { h(); return function (b) { h(); a = b; }; }; q(1)(2);");
|
||||
test("n", 3, "q = function (n) { for (var i = 0; i < n; i++) { let (j = i) { h(); } } }; q(3);");
|
||||
|
@ -45,7 +45,8 @@ function debuggerHandler(frame) {
|
||||
assertEq(ke.inspectable, true);
|
||||
assertEq(ke.getVariable('xk'), 'value of xk');
|
||||
assertEq(ee.inspectable, true);
|
||||
assertEq(ee.type, 'object');
|
||||
assertEq(ee.type, 'declarative');
|
||||
assertEq(ee.parent.type, 'object');
|
||||
|
||||
dbg.removeDebuggee(g2);
|
||||
|
||||
@ -54,7 +55,8 @@ function debuggerHandler(frame) {
|
||||
assertEq(ke.inspectable, false);
|
||||
assertThrowsInstanceOf(() => ke.getVariable('xk'), Error);
|
||||
assertEq(ee.inspectable, true);
|
||||
assertEq(ee.type, 'object');
|
||||
assertEq(ee.type, 'declarative');
|
||||
assertEq(ee.parent.type, 'object');
|
||||
|
||||
dbg.removeDebuggee(g1);
|
||||
|
||||
|
@ -35,6 +35,6 @@ assertEq(log, 'd');
|
||||
dbg.addDebuggee(g);
|
||||
g.eval('function f() { }');
|
||||
let env = gw.getOwnPropertyDescriptor('f').value.environment;
|
||||
assertEq(env.type, 'object');
|
||||
assertEq(env.type, 'declarative');
|
||||
dbg.removeDebuggee(g);
|
||||
check(env);
|
||||
|
@ -28,7 +28,7 @@ dbg.onEnterFrame = function (f) {
|
||||
assertEq(funenv.callee, f.older.callee);
|
||||
assertEq(funenv.names().indexOf("x") !== -1, true);
|
||||
|
||||
globalenv = funenv.parent;
|
||||
globalenv = funenv.parent.parent;
|
||||
assertEq(globalenv.optimizedOut, false);
|
||||
assertEq(globalenv.inspectable, true);
|
||||
assertEq(globalenv.type, "object");
|
||||
|
@ -3,7 +3,7 @@
|
||||
var g = newGlobal();
|
||||
var dbg = Debugger(g);
|
||||
dbg.onDebuggerStatement = function (frame) {
|
||||
frame.environment.setVariable("x", 2);
|
||||
frame.environment.parent.setVariable("x", 2);
|
||||
};
|
||||
g.eval("var x = 1; debugger;");
|
||||
assertEq(g.x, 2);
|
||||
|
@ -4,7 +4,7 @@ var g = newGlobal();
|
||||
var dbg = new Debugger;
|
||||
var gw = dbg.addDebuggee(g);
|
||||
dbg.onDebuggerStatement = function (frame) {
|
||||
frame.environment.setVariable("x", gw);
|
||||
frame.environment.parent.setVariable("x", gw);
|
||||
};
|
||||
g.eval("var x = 1; debugger;");
|
||||
assertEq(g.x, g);
|
||||
|
@ -9,7 +9,7 @@ function test(code, expected) {
|
||||
assertEq(actual, expected);
|
||||
}
|
||||
|
||||
test("h();", 'object');
|
||||
test("h();", 'declarative');
|
||||
test("(function (s) { eval(s); })('var v = h();')", 'declarative');
|
||||
test("(function (s) { h(); })();", 'declarative');
|
||||
test("{let x = 1, y = 2; h();}", 'declarative');
|
||||
@ -17,7 +17,7 @@ test("with({x: 1, y: 2}) h();", 'with');
|
||||
test("(function (s) { with ({x: 1, y: 2}) h(); })();", 'with');
|
||||
test("let (x = 1) { h(); }", 'declarative');
|
||||
test("for (let x = 0; x < 1; x++) h();", 'declarative');
|
||||
test("for (let x in h()) ;", 'object');
|
||||
test("for (let x in h()) ;", 'declarative');
|
||||
test("for (let x in {a:1}) h();", 'declarative');
|
||||
test("try { throw new Error; } catch (x) { h(x) }", 'declarative');
|
||||
test("'use strict'; eval('var z = 1; h();');", 'declarative');
|
||||
@ -33,5 +33,5 @@ test("for (var x in (0 for (m in h()))) ;", 'declarative');
|
||||
dbg.onDebuggerStatement = function (frame) {
|
||||
assertEq(frame.eval("h(), 2 + 2;").return, 4);
|
||||
}
|
||||
test("debugger;", 'object');
|
||||
test("debugger;", 'declarative');
|
||||
test("(function f() { debugger; })();", 'declarative');
|
||||
|
@ -4,7 +4,7 @@ var g = newGlobal();
|
||||
var dbg = new Debugger;
|
||||
var gw = dbg.addDebuggee(g);
|
||||
g.h = function () {
|
||||
var env = dbg.getNewestFrame().environment;
|
||||
var env = dbg.getNewestFrame().environment.parent;
|
||||
assertEq(env instanceof Debugger.Environment, true);
|
||||
assertEq(env.object, gw);
|
||||
assertEq(env.parent, null);
|
||||
|
@ -6,7 +6,7 @@ let dbg = new Debugger(g);
|
||||
let sizeOfAM = byteSize(allocationMarker());
|
||||
|
||||
// Allocate a single allocation marker, and check that we can find it.
|
||||
g.eval('let hold = allocationMarker();');
|
||||
g.eval('var hold = allocationMarker();');
|
||||
let census = dbg.memory.takeCensus({ breakdown: { by: 'objectClass' } });
|
||||
assertEq(census.AllocationMarker.count, 1);
|
||||
assertEq(census.AllocationMarker.bytes, sizeOfAM);
|
||||
|
@ -1,8 +1,8 @@
|
||||
// obj.getOwnPropertyDescriptor works on global objects.
|
||||
|
||||
var g = newGlobal();
|
||||
g.eval("var v; const k = 42;");
|
||||
this.eval("var v; const k = 42;");
|
||||
g.eval("var v;");
|
||||
this.eval("var v;");
|
||||
|
||||
var dbg = Debugger();
|
||||
var obj = dbg.addDebuggee(g);
|
||||
@ -20,4 +20,3 @@ function test(name) {
|
||||
|
||||
test("Infinity");
|
||||
test("v");
|
||||
test("k");
|
||||
|
Loading…
Reference in New Issue
Block a user