summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/debug-scopes.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/mjsunit/debug-scopes.js')
-rw-r--r--deps/v8/test/mjsunit/debug-scopes.js104
1 files changed, 91 insertions, 13 deletions
diff --git a/deps/v8/test/mjsunit/debug-scopes.js b/deps/v8/test/mjsunit/debug-scopes.js
index 8cde95194a..3659d4e129 100644
--- a/deps/v8/test/mjsunit/debug-scopes.js
+++ b/deps/v8/test/mjsunit/debug-scopes.js
@@ -152,7 +152,7 @@ function CheckScopeChainNames(names, exec_state) {
for (var i = 0; i < names.length; i++) {
var scope = exec_state.frame().scope(i);
assertTrue(scope.isScope());
- assertEquals(scope.details().name(), names[i])
+ assertEquals(names[i], scope.details().name())
}
}
@@ -223,6 +223,21 @@ function CheckScopeContent(content, number, exec_state) {
assertTrue(found, "Scope object " + response.body.object.ref + " not found");
}
+// 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");
+ for (var i = 0; i < positions.length; i++) {
+ var scope = exec_state.frame().scope(i);
+ assertTrue(scope.isScope());
+ var position = positions[i];
+ if (!position)
+ continue;
+
+ assertEquals(position.start, scope.details().startPosition())
+ assertEquals(position.end, scope.details().endPosition())
+ }
+}
// Simple empty local scope.
BeginTest("Local 1");
@@ -529,7 +544,7 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1}, 1, exec_state);
- CheckScopeChainNames([undefined, "closure_1", undefined, undefined], exec_state)
+ CheckScopeChainNames(["f", "closure_1", undefined, undefined], exec_state)
};
closure_1(1)();
EndTest();
@@ -556,7 +571,7 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1,x:3}, 1, exec_state);
- CheckScopeChainNames([undefined, "closure_2", undefined, undefined], exec_state)
+ CheckScopeChainNames(["f", "closure_2", undefined, undefined], exec_state)
};
closure_2(1, 2)();
EndTest();
@@ -584,7 +599,7 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state);
- CheckScopeChainNames([undefined, "closure_3", undefined, undefined], exec_state)
+ CheckScopeChainNames(["f", "closure_3", undefined, undefined], exec_state)
};
closure_3(1, 2)();
EndTest();
@@ -615,7 +630,7 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state);
- CheckScopeChainNames([undefined, "closure_4", undefined, undefined], exec_state)
+ CheckScopeChainNames(["f", "closure_4", undefined, undefined], exec_state)
};
closure_4(1, 2)();
EndTest();
@@ -733,7 +748,7 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({x: 2}, 0, exec_state);
- CheckScopeChainNames([undefined, undefined, undefined], exec_state)
+ CheckScopeChainNames(["inner", undefined, undefined], exec_state)
};
closure_8();
EndTest();
@@ -755,7 +770,7 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Closure,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
- CheckScopeChainNames([undefined, "closure_9", undefined, undefined], exec_state)
+ CheckScopeChainNames(["inner", "closure_9", undefined, undefined], exec_state)
};
closure_9();
EndTest();
@@ -822,10 +837,10 @@ function closure_in_with_1() {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Local,
debug.ScopeType.With,
- debug.ScopeType.Closure,
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();
@@ -846,13 +861,12 @@ listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.With,
debug.ScopeType.Local,
debug.ScopeType.With,
- debug.ScopeType.Closure,
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", "closure_in_with_2", undefined, undefined], exec_state)
+ CheckScopeChainNames(["inner", "inner", "closure_in_with_2", undefined, undefined], exec_state)
};
closure_in_with_2();
EndTest();
@@ -934,7 +948,7 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({e:'Exception'}, 0, exec_state);
- CheckScopeChainNames(["catch_block_1", undefined, undefined, undefined], exec_state)
+ CheckScopeChainNames(["catch_block_1", "catch_block_1", undefined, undefined], exec_state)
};
catch_block_1();
EndTest();
@@ -1080,7 +1094,7 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({e:'Exception'}, 0, exec_state);
- CheckScopeChainNames(["catch_block_7", undefined, undefined, undefined], exec_state)
+ CheckScopeChainNames(["catch_block_7", "catch_block_7", undefined, undefined], exec_state)
};
catch_block_7();
EndTest();
@@ -1094,7 +1108,7 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({}, 1, exec_state);
- CheckScopeChainNames([undefined, undefined, undefined], exec_state)
+ CheckScopeChainNames(["m", undefined, undefined], exec_state)
};
(function() {
@@ -1109,6 +1123,70 @@ listener_delegate = function(exec_state) {
EndTest();
+BeginTest("Scope positions");
+var code1 = "function f() { \n" +
+ " var a = 1; \n" +
+ " function b() { \n" +
+ " debugger; \n" +
+ " return a + 1; \n" +
+ " } \n" +
+ " b(); \n" +
+ "} \n" +
+ "f(); \n";
+
+listener_delegate = function(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" +
+ " debugger; \n" +
+ " } \n" +
+ "} \n" +
+ "for_statement(); \n";
+
+listener_delegate = function(exec_state) {
+ CheckScopeChain([debug.ScopeType.Block,
+ debug.ScopeType.Block,
+ debug.ScopeType.Local,
+ debug.ScopeType.Script,
+ debug.ScopeType.Global], exec_state);
+ CheckScopeChainPositions([{start: 52, end: 111}, {start: 42, end: 111}, {start: 22, end: 145}, {}, {}], exec_state);
+}
+eval(code3);
+EndTest();
assertEquals(begin_test_count, break_count,
'one or more tests did not enter the debugger');