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

Unified Diff: test/mjsunit/debug-scopes.js

Issue 1653083002: Devtools: expose scopes source location to debugger (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments Created 4 years, 10 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/debug/mirrors.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/debug-scopes.js
diff --git a/test/mjsunit/debug-scopes.js b/test/mjsunit/debug-scopes.js
index 8cde95194a9057b4549f54939452fcca504bf00c..6ddd6a223ccef9ed81b046350860a7a0c4906ddf 100644
--- a/test/mjsunit/debug-scopes.js
+++ b/test/mjsunit/debug-scopes.js
@@ -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");
@@ -1109,6 +1124,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');
« no previous file with comments | « src/debug/mirrors.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698