diff --git a/js/src/jit-test/tests/debug/Debugger-debuggees-19.js b/js/src/jit-test/tests/debug/Debugger-debuggees-19.js index b32920a7c18d..20d9f1599668 100644 --- a/js/src/jit-test/tests/debug/Debugger-debuggees-19.js +++ b/js/src/jit-test/tests/debug/Debugger-debuggees-19.js @@ -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(); diff --git a/js/src/jit-test/tests/debug/Environment-callee-01.js b/js/src/jit-test/tests/debug/Environment-callee-01.js index 31ee61386275..b3d84ec70a98 100644 --- a/js/src/jit-test/tests/debug/Environment-callee-01.js +++ b/js/src/jit-test/tests/debug/Environment-callee-01.js @@ -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)); diff --git a/js/src/jit-test/tests/debug/Environment-getVariable-05.js b/js/src/jit-test/tests/debug/Environment-getVariable-05.js index 500752467512..f4bd52144647 100644 --- a/js/src/jit-test/tests/debug/Environment-getVariable-05.js +++ b/js/src/jit-test/tests/debug/Environment-getVariable-05.js @@ -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'); diff --git a/js/src/jit-test/tests/debug/Environment-getVariable-06.js b/js/src/jit-test/tests/debug/Environment-getVariable-06.js index de9f0168aa97..096f77d8e3cd 100644 --- a/js/src/jit-test/tests/debug/Environment-getVariable-06.js +++ b/js/src/jit-test/tests/debug/Environment-getVariable-06.js @@ -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" + diff --git a/js/src/jit-test/tests/debug/Environment-getVariable-11.js b/js/src/jit-test/tests/debug/Environment-getVariable-11.js index 9bc9be1a082e..ac144407ebe8 100644 --- a/js/src/jit-test/tests/debug/Environment-getVariable-11.js +++ b/js/src/jit-test/tests/debug/Environment-getVariable-11.js @@ -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); diff --git a/js/src/jit-test/tests/debug/Environment-getVariable-12.js b/js/src/jit-test/tests/debug/Environment-getVariable-12.js index 0bbf4e3fdff9..b6852bb6fa06 100644 --- a/js/src/jit-test/tests/debug/Environment-getVariable-12.js +++ b/js/src/jit-test/tests/debug/Environment-getVariable-12.js @@ -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;" + diff --git a/js/src/jit-test/tests/debug/Environment-getVariable-WouldRun.js b/js/src/jit-test/tests/debug/Environment-getVariable-WouldRun.js index 457f2904cd8b..8d2457d12fab 100644 --- a/js/src/jit-test/tests/debug/Environment-getVariable-WouldRun.js +++ b/js/src/jit-test/tests/debug/Environment-getVariable-WouldRun.js @@ -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++; }; diff --git a/js/src/jit-test/tests/debug/Environment-identity-03.js b/js/src/jit-test/tests/debug/Environment-identity-03.js index 1087d5c6b6de..3f7e843c1878 100644 --- a/js/src/jit-test/tests/debug/Environment-identity-03.js +++ b/js/src/jit-test/tests/debug/Environment-identity-03.js @@ -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);"); diff --git a/js/src/jit-test/tests/debug/Environment-inspectable-01.js b/js/src/jit-test/tests/debug/Environment-inspectable-01.js index 4e80f6285a39..ee5897833d51 100644 --- a/js/src/jit-test/tests/debug/Environment-inspectable-01.js +++ b/js/src/jit-test/tests/debug/Environment-inspectable-01.js @@ -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); diff --git a/js/src/jit-test/tests/debug/Environment-nondebuggee.js b/js/src/jit-test/tests/debug/Environment-nondebuggee.js index 3d1951dcae35..72d4ae9909cf 100644 --- a/js/src/jit-test/tests/debug/Environment-nondebuggee.js +++ b/js/src/jit-test/tests/debug/Environment-nondebuggee.js @@ -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); diff --git a/js/src/jit-test/tests/debug/Environment-optimizedOut-01.js b/js/src/jit-test/tests/debug/Environment-optimizedOut-01.js index df7a6087e8e2..7701ebc073af 100644 --- a/js/src/jit-test/tests/debug/Environment-optimizedOut-01.js +++ b/js/src/jit-test/tests/debug/Environment-optimizedOut-01.js @@ -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"); diff --git a/js/src/jit-test/tests/debug/Environment-setVariable-01.js b/js/src/jit-test/tests/debug/Environment-setVariable-01.js index 007bd2dad1ae..610960241cc3 100644 --- a/js/src/jit-test/tests/debug/Environment-setVariable-01.js +++ b/js/src/jit-test/tests/debug/Environment-setVariable-01.js @@ -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); diff --git a/js/src/jit-test/tests/debug/Environment-setVariable-02.js b/js/src/jit-test/tests/debug/Environment-setVariable-02.js index 7e4e61906ee5..02494609e260 100644 --- a/js/src/jit-test/tests/debug/Environment-setVariable-02.js +++ b/js/src/jit-test/tests/debug/Environment-setVariable-02.js @@ -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); diff --git a/js/src/jit-test/tests/debug/Environment-type-01.js b/js/src/jit-test/tests/debug/Environment-type-01.js index 3fdd1e2dbae5..3085163c29f0 100644 --- a/js/src/jit-test/tests/debug/Environment-type-01.js +++ b/js/src/jit-test/tests/debug/Environment-type-01.js @@ -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'); diff --git a/js/src/jit-test/tests/debug/Frame-environment-02.js b/js/src/jit-test/tests/debug/Frame-environment-02.js index 9909be80aa9a..6d6101c59a47 100644 --- a/js/src/jit-test/tests/debug/Frame-environment-02.js +++ b/js/src/jit-test/tests/debug/Frame-environment-02.js @@ -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); diff --git a/js/src/jit-test/tests/debug/Memory-takeCensus-10.js b/js/src/jit-test/tests/debug/Memory-takeCensus-10.js index 79474da1ff14..aa811184deb2 100644 --- a/js/src/jit-test/tests/debug/Memory-takeCensus-10.js +++ b/js/src/jit-test/tests/debug/Memory-takeCensus-10.js @@ -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); diff --git a/js/src/jit-test/tests/debug/Object-getOwnPropertyDescriptor-03.js b/js/src/jit-test/tests/debug/Object-getOwnPropertyDescriptor-03.js index 3be271b927df..78f5d9efa2ae 100644 --- a/js/src/jit-test/tests/debug/Object-getOwnPropertyDescriptor-03.js +++ b/js/src/jit-test/tests/debug/Object-getOwnPropertyDescriptor-03.js @@ -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");