Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: test/mjsunit/modules-debug-scopes1.js

Issue 2445683002: [modules] Add partial support for debug-scopes. (Closed)
Patch Set: Fix handle bug. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/modules-debug-scopes2.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/modules-debug-scopes1.js
diff --git a/test/mjsunit/debug-scopes.js b/test/mjsunit/modules-debug-scopes1.js
similarity index 63%
copy from test/mjsunit/debug-scopes.js
copy to test/mjsunit/modules-debug-scopes1.js
index 0e822fce1c0e0249d0d3c8751f1757dc8b7b3875..02de75510e65f6f51fac6e33e838a9a690a10cae 100644
--- a/test/mjsunit/debug-scopes.js
+++ b/test/mjsunit/modules-debug-scopes1.js
@@ -1,35 +1,13 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived
-// from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+// MODULE
// Flags: --expose-debug-as debug --allow-natives-syntax
-// The functions used for testing backtraces. They are at the top to make the
-// testing of source line/column easier.
-// Get the Debug object exposed from the debug context global object.
+// These tests are copied from mjsunit/debug-scopes.js and adapted for modules.
+
+
var Debug = debug.Debug;
var test_name;
@@ -70,7 +48,7 @@ function BeginTest(name) {
// Check result of a test.
function EndTest() {
- assertTrue(listener_called, "listerner not called for " + test_name);
+ assertTrue(listener_called, "listener not called for " + test_name);
assertNull(exception, test_name + " / " + exception);
end_test_count++;
}
@@ -107,13 +85,6 @@ function CheckScopeChain(scopes, exec_state) {
assertTrue(scope.isScope());
assertEquals(scopes[i], scope.scopeType());
assertScopeMirrorEquals(all_scopes[i], scope);
-
- // Check the global object when hitting the global scope.
- if (scopes[i] == debug.ScopeType.Global) {
- // Objects don't have same class (one is "global", other is "Object",
- // so just check the properties directly.
- assertPropertiesEqual(this, scope.scopeObject().value());
- }
}
CheckFastAllScopes(scopes, exec_state);
@@ -224,7 +195,7 @@ function CheckScopeContent(minimum_content, number, exec_state) {
// Check that the scopes have positions as expected.
function CheckScopeChainPositions(positions, exec_state) {
var all_scopes = exec_state.frame().allScopes();
- assertEquals(positions.length, all_scopes.length, "FrameMirror.allScopes length");
+ assertTrue(positions.length <= all_scopes.length, "FrameMirror.allScopes length");
for (var i = 0; i < positions.length; i++) {
var scope = exec_state.frame().scope(i);
assertTrue(scope.isScope());
@@ -232,6 +203,7 @@ function CheckScopeChainPositions(positions, exec_state) {
if (!position)
continue;
+ print(`Checking position.start = ${position.start}, .end = ${position.end}`);
assertEquals(position.start, scope.details().startPosition())
assertEquals(position.end, scope.details().endPosition())
}
@@ -246,6 +218,7 @@ function local_1() {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({}, 0, exec_state);
@@ -263,6 +236,7 @@ function local_2(a) {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1}, 0, exec_state);
@@ -281,6 +255,7 @@ function local_3(a) {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1,x:3}, 0, exec_state);
@@ -300,6 +275,7 @@ function local_4(a, b) {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state);
@@ -318,6 +294,7 @@ function local_5() {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({}, 0, exec_state);
@@ -336,16 +313,16 @@ function local_6() {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
- CheckScopeContent({i:5}, 0, exec_state);
+ CheckScopeContent({}, 0, exec_state);
};
local_6();
EndTest();
-// Local scope with parameters, local variables and local variable introduced
-// using eval.
+// Local scope with parameters and local variables.
BeginTest("Local 7");
function local_7(a, b) {
@@ -358,172 +335,15 @@ function local_7(a, b) {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
- CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 0, exec_state);
+ CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state);
};
local_7(1, 2);
EndTest();
-// Single empty with block.
-BeginTest("With 1");
-
-function with_1() {
- with({}) {
- debugger;
- }
-}
-
-listener_delegate = function(exec_state) {
- CheckScopeChain([debug.ScopeType.With,
- debug.ScopeType.Local,
- debug.ScopeType.Script,
- debug.ScopeType.Global], exec_state);
- CheckScopeContent({}, 0, exec_state);
-};
-with_1();
-EndTest();
-
-
-// Nested empty with blocks.
-BeginTest("With 2");
-
-function with_2() {
- with({}) {
- with({}) {
- debugger;
- }
- }
-}
-
-listener_delegate = function(exec_state) {
- CheckScopeChain([debug.ScopeType.With,
- debug.ScopeType.With,
- debug.ScopeType.Local,
- debug.ScopeType.Script,
- debug.ScopeType.Global], exec_state);
- CheckScopeContent({}, 0, exec_state);
- CheckScopeContent({}, 1, exec_state);
-};
-with_2();
-EndTest();
-
-
-// With block using an in-place object literal.
-BeginTest("With 3");
-
-function with_3() {
- with({a:1,b:2}) {
- debugger;
- }
-}
-
-listener_delegate = function(exec_state) {
- CheckScopeChain([debug.ScopeType.With,
- debug.ScopeType.Local,
- debug.ScopeType.Script,
- debug.ScopeType.Global], exec_state);
- CheckScopeContent({a:1,b:2}, 0, exec_state);
-};
-with_3();
-EndTest();
-
-
-// Nested with blocks using in-place object literals.
-BeginTest("With 4");
-
-function with_4() {
- with({a:1,b:2}) {
- with({a:2,b:1}) {
- debugger;
- }
- }
-}
-
-listener_delegate = function(exec_state) {
- CheckScopeChain([debug.ScopeType.With,
- debug.ScopeType.With,
- debug.ScopeType.Local,
- debug.ScopeType.Script,
- debug.ScopeType.Global], exec_state);
- CheckScopeContent({a:2,b:1}, 0, exec_state);
- CheckScopeContent({a:1,b:2}, 1, exec_state);
-};
-with_4();
-EndTest();
-
-
-// Nested with blocks using existing object.
-BeginTest("With 5");
-
-var with_object = {c:3,d:4};
-function with_5() {
- with(with_object) {
- with(with_object) {
- debugger;
- }
- }
-}
-
-listener_delegate = function(exec_state) {
- CheckScopeChain([debug.ScopeType.With,
- debug.ScopeType.With,
- debug.ScopeType.Local,
- debug.ScopeType.Script,
- debug.ScopeType.Global], exec_state);
- CheckScopeContent(with_object, 0, exec_state);
- CheckScopeContent(with_object, 1, exec_state);
- assertEquals(exec_state.frame().scope(0).scopeObject(), exec_state.frame().scope(1).scopeObject());
- assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value());
-};
-with_5();
-EndTest();
-
-
-// Nested with blocks using existing object in global code.
-BeginTest("With 6");
-listener_delegate = function(exec_state) {
- CheckScopeChain([debug.ScopeType.With,
- debug.ScopeType.With,
- debug.ScopeType.Script,
- debug.ScopeType.Global], exec_state);
- CheckScopeContent(with_object, 0, exec_state);
- CheckScopeContent(with_object, 1, exec_state);
- assertEquals(exec_state.frame().scope(0).scopeObject(), exec_state.frame().scope(1).scopeObject());
- assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value());
-};
-
-var with_object = {c:3,d:4};
-with(with_object) {
- with(with_object) {
- debugger;
- }
-}
-EndTest();
-
-
-// With block in function that is marked for optimization while being executed.
-BeginTest("With 7");
-
-function with_7() {
- with({}) {
- %OptimizeFunctionOnNextCall(with_7);
- debugger;
- }
-}
-
-listener_delegate = function(exec_state) {
- CheckScopeChain([debug.ScopeType.With,
- debug.ScopeType.Local,
- debug.ScopeType.Script,
- debug.ScopeType.Global], exec_state);
- CheckScopeContent({}, 0, exec_state);
-};
-with_7();
-EndTest();
-
-
// Simple closure formed by returning an inner function referering the outer
// functions arguments.
BeginTest("Closure 1");
@@ -539,10 +359,11 @@ function closure_1(a) {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
debug.ScopeType.Closure,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1}, 1, exec_state);
- CheckScopeChainNames(["f", "closure_1", undefined, undefined], exec_state)
+ CheckScopeChainNames(["f", "closure_1", undefined, undefined, undefined], exec_state)
};
closure_1(1)();
EndTest();
@@ -566,10 +387,11 @@ function closure_2(a, b) {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
debug.ScopeType.Closure,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1,x:3}, 1, exec_state);
- CheckScopeChainNames(["f", "closure_2", undefined, undefined], exec_state)
+ CheckScopeChainNames(["f", "closure_2", undefined, undefined, undefined], exec_state)
};
closure_2(1, 2)();
EndTest();
@@ -594,10 +416,11 @@ function closure_3(a, b) {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
debug.ScopeType.Closure,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state);
- CheckScopeChainNames(["f", "closure_3", undefined, undefined], exec_state)
+ CheckScopeChainNames(["f", "closure_3", undefined, undefined, undefined], exec_state)
};
closure_3(1, 2)();
EndTest();
@@ -625,10 +448,11 @@ function closure_4(a, b) {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
debug.ScopeType.Closure,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state);
- CheckScopeChainNames(["f", "closure_4", undefined, undefined], exec_state)
+ CheckScopeChainNames(["f", "closure_4", undefined, undefined, undefined], exec_state)
};
closure_4(1, 2)();
EndTest();
@@ -655,10 +479,11 @@ function closure_5(a, b) {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
debug.ScopeType.Closure,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state);
- CheckScopeChainNames(["f", "closure_5", undefined, undefined], exec_state)
+ CheckScopeChainNames(["f", "closure_5", undefined, undefined, undefined], exec_state)
};
closure_5(1, 2)();
EndTest();
@@ -667,6 +492,7 @@ EndTest();
// Two closures. Due to optimizations only the parts actually used are provided
// through the debugger information.
BeginTest("Closure 6");
+let some_global;
function closure_6(a, b) {
function f(a, b) {
var x = 3;
@@ -686,11 +512,12 @@ listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
debug.ScopeType.Closure,
debug.ScopeType.Closure,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1}, 1, exec_state);
CheckScopeContent({f:function(){}}, 2, exec_state);
- CheckScopeChainNames([undefined, "f", "closure_6", undefined, undefined], exec_state)
+ CheckScopeChainNames([undefined, "f", "closure_6", undefined, undefined, undefined], exec_state)
};
closure_6(1, 2)();
EndTest();
@@ -722,12 +549,13 @@ listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
debug.ScopeType.Closure,
debug.ScopeType.Closure,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({}, 0, exec_state);
- CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state);
- CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 2, exec_state);
- CheckScopeChainNames([undefined, "f", "closure_7", undefined, undefined], exec_state)
+ CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state);
+ CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 2, exec_state);
+ CheckScopeChainNames([undefined, "f", "closure_7", undefined, undefined, undefined], exec_state)
};
closure_7(1, 2)();
EndTest();
@@ -743,188 +571,43 @@ function closure_8() {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({x: 2}, 0, exec_state);
- CheckScopeChainNames(["inner", undefined, undefined], exec_state)
+ CheckScopeChainNames(["inner", undefined, undefined, undefined], exec_state)
};
closure_8();
EndTest();
BeginTest("Closure 9");
-function closure_9() {
- eval("var y = 1;");
- eval("var z = 1;");
- (function inner(x) {
- y++;
- z++;
- debugger;
- })(2);
-}
+let closure_9 = Function(' \
+ eval("var y = 1;"); \
+ eval("var z = 1;"); \
+ (function inner(x) { \
+ y++; \
+ z++; \
+ debugger; \
+ })(2); \
+')
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
debug.ScopeType.Closure,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
- CheckScopeChainNames(["inner", "closure_9", undefined, undefined], exec_state)
+ CheckScopeChainNames(["inner", undefined, undefined, undefined], exec_state)
};
closure_9();
EndTest();
-// Test a mixture of scopes.
-BeginTest("The full monty");
-function the_full_monty(a, b) {
- var x = 3;
- var y = 4;
- eval('var i = 5');
- eval('var j = 6');
- function f(a, b) {
- var x = 9;
- var y = 10;
- eval('var i = 11');
- eval('var j = 12');
- with ({j:13}){
- return function() {
- var x = 14;
- with ({a:15}) {
- with ({b:16}) {
- debugger;
- some_global = a;
- return f;
- }
- }
- };
- }
- }
- return f(a, b);
-}
-
-listener_delegate = function(exec_state) {
- CheckScopeChain([debug.ScopeType.With,
- debug.ScopeType.With,
- debug.ScopeType.Local,
- debug.ScopeType.With,
- debug.ScopeType.Closure,
- debug.ScopeType.Closure,
- debug.ScopeType.Script,
- debug.ScopeType.Global], exec_state);
- CheckScopeContent({b:16}, 0, exec_state);
- CheckScopeContent({a:15}, 1, exec_state);
- CheckScopeContent({x:14}, 2, exec_state);
- CheckScopeContent({j:13}, 3, exec_state);
- CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state);
- CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, exec_state);
- CheckScopeChainNames([undefined, undefined, undefined, "f", "f", "the_full_monty", undefined, undefined], exec_state)
-};
-the_full_monty(1, 2)();
-EndTest();
-
-
-BeginTest("Closure inside With 1");
-function closure_in_with_1() {
- with({x:1}) {
- (function inner(x) {
- debugger;
- })(2);
- }
-}
-
-listener_delegate = function(exec_state) {
- CheckScopeChain([debug.ScopeType.Local,
- debug.ScopeType.With,
- debug.ScopeType.Script,
- debug.ScopeType.Global], exec_state);
- CheckScopeContent({x: 2}, 0, exec_state);
- CheckScopeContent({x: 1}, 1, exec_state);
-};
-closure_in_with_1();
-EndTest();
-
-
-BeginTest("Closure inside With 2");
-function closure_in_with_2() {
- with({x:1}) {
- (function inner(x) {
- with({x:3}) {
- debugger;
- }
- })(2);
- }
-}
-
-listener_delegate = function(exec_state) {
- CheckScopeChain([debug.ScopeType.With,
- debug.ScopeType.Local,
- debug.ScopeType.With,
- debug.ScopeType.Script,
- debug.ScopeType.Global], exec_state);
- CheckScopeContent({x: 3}, 0, exec_state);
- CheckScopeContent({x: 2}, 1, exec_state);
- CheckScopeContent({x: 1}, 2, exec_state);
- CheckScopeChainNames(["inner", "inner", "closure_in_with_2", undefined, undefined], exec_state)
-};
-closure_in_with_2();
-EndTest();
-
-
-BeginTest("Closure inside With 3");
-function createClosure(a) {
- var b = a + 1;
- return function closure() {
- var c = b;
- (function inner(x) {
- with({x:c}) {
- debugger;
- }
- })(2);
- };
-}
-
-function closure_in_with_3() {
- var f = createClosure(0);
- f();
-}
-
-listener_delegate = function(exec_state) {
- CheckScopeChain([debug.ScopeType.With,
- debug.ScopeType.Local,
- debug.ScopeType.Closure,
- debug.ScopeType.Closure,
- debug.ScopeType.Script,
- debug.ScopeType.Global], exec_state);
- CheckScopeChainNames(["inner", "inner", "closure", "createClosure", undefined, undefined], exec_state)
-}
-closure_in_with_3();
-EndTest();
-
-
-BeginTest("Closure inside With 4");
-listener_delegate = function(exec_state) {
- CheckScopeChain([debug.ScopeType.Local,
- debug.ScopeType.With,
- debug.ScopeType.Script,
- debug.ScopeType.Global], exec_state);
- CheckScopeContent({x: 2}, 0, exec_state);
- CheckScopeContent({x: 1}, 1, exec_state);
- CheckScopeChainNames([undefined, undefined, undefined, undefined], exec_state)
-};
-
-with({x:1}) {
- (function(x) {
- debugger;
- })(2);
-}
-EndTest();
-
-
// Test global scope.
BeginTest("Global");
listener_delegate = function(exec_state) {
- CheckScopeChain([debug.ScopeType.Script, debug.ScopeType.Global], exec_state);
- CheckScopeChainNames([undefined, undefined], exec_state)
+ CheckScopeChain([debug.ScopeType.Module, debug.ScopeType.Script, debug.ScopeType.Global], exec_state);
+ CheckScopeChainNames([undefined, undefined, undefined], exec_state)
};
debugger;
EndTest();
@@ -943,45 +626,18 @@ function catch_block_1() {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Catch,
debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({e:'Exception'}, 0, exec_state);
- CheckScopeChainNames(["catch_block_1", "catch_block_1", undefined, undefined], exec_state)
+ CheckScopeChainNames(["catch_block_1", "catch_block_1", undefined, undefined, undefined], exec_state)
};
catch_block_1();
EndTest();
-BeginTest("Catch block 2");
-function catch_block_2() {
- try {
- throw 'Exception';
- } catch (e) {
- with({n:10}) {
- debugger;
- }
- }
-};
-
-
-listener_delegate = function(exec_state) {
- CheckScopeChain([debug.ScopeType.With,
- debug.ScopeType.Catch,
- debug.ScopeType.Local,
- debug.ScopeType.Script,
- debug.ScopeType.Global], exec_state);
- CheckScopeContent({n:10}, 0, exec_state);
- CheckScopeContent({e:'Exception'}, 1, exec_state);
- CheckScopeChainNames(["catch_block_2", "catch_block_2", "catch_block_2", undefined, undefined], exec_state)
-};
-catch_block_2();
-EndTest();
-
-
BeginTest("Catch block 3");
function catch_block_3() {
- // Do eval to dynamically declare a local variable so that the context's
- // extension slot is initialized with JSContextExtensionObject.
eval("var y = 78;");
try {
throw 'Exception';
@@ -994,53 +650,26 @@ function catch_block_3() {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Catch,
debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({e:'Exception'}, 0, exec_state);
- CheckScopeContent({y:78}, 1, exec_state);
- CheckScopeChainNames(["catch_block_3", "catch_block_3", undefined, undefined], exec_state)
+ CheckScopeContent({}, 1, exec_state);
+ CheckScopeChainNames(["catch_block_3", "catch_block_3", undefined, undefined, undefined], exec_state)
};
catch_block_3();
EndTest();
-BeginTest("Catch block 4");
-function catch_block_4() {
- // Do eval to dynamically declare a local variable so that the context's
- // extension slot is initialized with JSContextExtensionObject.
- eval("var y = 98;");
- try {
- throw 'Exception';
- } catch (e) {
- with({n:10}) {
- debugger;
- }
- }
-};
-
-listener_delegate = function(exec_state) {
- CheckScopeChain([debug.ScopeType.With,
- debug.ScopeType.Catch,
- debug.ScopeType.Local,
- debug.ScopeType.Script,
- debug.ScopeType.Global], exec_state);
- CheckScopeContent({n:10}, 0, exec_state);
- CheckScopeContent({e:'Exception'}, 1, exec_state);
- CheckScopeContent({y:98}, 2, exec_state);
- CheckScopeChainNames(["catch_block_4", "catch_block_4", "catch_block_4", undefined, undefined], exec_state)
-};
-catch_block_4();
-EndTest();
-
-
// Test catch in global scope.
BeginTest("Catch block 5");
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Catch,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({e:'Exception'}, 0, exec_state);
- CheckScopeChainNames([undefined, undefined, undefined], exec_state)
+ CheckScopeChainNames([undefined, undefined, undefined, undefined], exec_state)
};
try {
@@ -1057,11 +686,12 @@ BeginTest("Catch block 6");
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
debug.ScopeType.Catch,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({x: 2}, 0, exec_state);
CheckScopeContent({e:'Exception'}, 1, exec_state);
- CheckScopeChainNames([undefined, undefined, undefined, undefined], exec_state)
+ CheckScopeChainNames([undefined, undefined, undefined, undefined, undefined], exec_state)
};
try {
@@ -1089,10 +719,11 @@ function catch_block_7() {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Catch,
debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({e:'Exception'}, 0, exec_state);
- CheckScopeChainNames(["catch_block_7", "catch_block_7", undefined, undefined], exec_state)
+ CheckScopeChainNames(["catch_block_7", "catch_block_7", undefined, undefined, undefined], exec_state)
};
catch_block_7();
EndTest();
@@ -1103,10 +734,11 @@ BeginTest("Classes and methods 1");
listener_delegate = function(exec_state) {
"use strict"
CheckScopeChain([debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({}, 1, exec_state);
- CheckScopeChainNames(["m", undefined, undefined], exec_state)
+ CheckScopeChainNames(["m", undefined, undefined, undefined], exec_state)
};
(function() {
@@ -1133,40 +765,12 @@ var code1 = "function f() { \n" +
"f(); \n";
listener_delegate = function(exec_state) {
- CheckScopeChainPositions([{start: 58, end: 118}, {start: 10, end: 162}, {}, {}], exec_state);
+ CheckScopeChainPositions([{start: 58, end: 118}, {start: 10, end: 162}], exec_state);
}
eval(code1);
EndTest();
-function catch_block_2() {
- try {
- throw 'Exception';
- } catch (e) {
- with({n:10}) {
- debugger;
- }
- }
-};
-
-BeginTest("Scope positions in catch and 'with' statement");
-var code2 = "function catch_block() { \n" +
- " try { \n" +
- " throw 'Exception'; \n" +
- " } catch (e) { \n" +
- " with({n : 10}) { \n" +
- " debugger; \n" +
- " } \n" +
- " } \n" +
- "} \n" +
- "catch_block(); \n";
-
-listener_delegate = function(exec_state) {
- CheckScopeChainPositions([{start: 131, end: 173}, {start: 94, end: 199}, {start: 20, end: 225}, {}, {}], exec_state);
-}
-eval(code2);
-EndTest();
-
BeginTest("Scope positions in for statement");
var code3 = "function for_statement() { \n" +
" for (let i = 0; i < 1; i++) { \n" +
@@ -1178,9 +782,10 @@ var code3 = "function for_statement() { \n" +
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Block,
debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
- CheckScopeChainPositions([{start: 52, end: 111}, {start: 22, end: 145}, {}, {}], exec_state);
+ CheckScopeChainPositions([{start: 52, end: 111}, {start: 22, end: 145}], exec_state);
}
eval(code3);
EndTest();
@@ -1198,9 +803,10 @@ listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Block,
debug.ScopeType.Block,
debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
- CheckScopeChainPositions([{start: 66, end: 147}, {start: 52, end: 147}, {start: 22, end: 181}, {}, {}], exec_state);
+ CheckScopeChainPositions([{start: 66, end: 147}, {start: 52, end: 147}, {start: 22, end: 181}], exec_state);
}
eval(code4);
EndTest();
@@ -1216,9 +822,10 @@ var code5 = "function for_each_statement() { \n" +
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Block,
debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
- CheckScopeChainPositions([{start: 55, end: 111}, {start: 27, end: 145}, {}, {}], exec_state);
+ CheckScopeChainPositions([{start: 55, end: 111}, {start: 27, end: 145}], exec_state);
}
eval(code5);
EndTest();
@@ -1236,9 +843,10 @@ listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Block,
debug.ScopeType.Block,
debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
- CheckScopeChainPositions([{start: 57, end: 147}, {start: 55, end: 147}, {start: 27, end: 181}, {}, {}], exec_state);
+ CheckScopeChainPositions([{start: 57, end: 147}, {start: 55, end: 147}, {start: 27, end: 181}], exec_state);
}
eval(code6);
EndTest();
@@ -1254,9 +862,10 @@ var code7 = "function for_each_statement() { \n" +
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
- CheckScopeChainPositions([{start: 27, end: 181}, {}, {}], exec_state);
+ CheckScopeChainPositions([{start: 27, end: 181}], exec_state);
}
eval(code7);
EndTest();
@@ -1274,9 +883,10 @@ var code8 = "function for_each_statement() { \n" +
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Block,
debug.ScopeType.Local,
+ debug.ScopeType.Module,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
- CheckScopeChainPositions([{start: 89, end: 183}, {start: 27, end: 217}, {}, {}], exec_state);
+ CheckScopeChainPositions([{start: 89, end: 183}, {start: 27, end: 217}], exec_state);
}
eval(code8);
EndTest();
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/modules-debug-scopes2.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698