Chromium Code Reviews| Index: test/mjsunit/debug-scopes.js |
| diff --git a/test/mjsunit/debug-scopes.js b/test/mjsunit/debug-scopes.js |
| index 8cde95194a9057b4549f54939452fcca504bf00c..705cea27f81f712fe366eb9f0545b039321695cd 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,65 @@ 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); |
|
Yang
2016/02/25 21:25:17
whitespace before comma is weird
sergeyv
2016/02/26 00:29:29
Done.
|
| +} |
| +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) { |
| + CheckScopeChainPositions([{start: 52, end: 111}, {start: 42, end: 111}, {start: 22, end: 145}, {}, {}], exec_state); |
|
sergeyv
2016/02/25 20:45:55
I don't quite get why do we have 5 scopes instead
Yang
2016/02/25 21:25:17
not sure. can you also add scope type to the check
sergeyv
2016/02/26 00:29:29
Added scope type. We have two block-statement here
|
| +} |
| +eval(code3); |
| +EndTest(); |
| assertEquals(begin_test_count, break_count, |
| 'one or more tests did not enter the debugger'); |