Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 } else { | 216 } else { |
| 217 assertTrue(response.body.object.ref >= 0); | 217 assertTrue(response.body.object.ref >= 0); |
| 218 } | 218 } |
| 219 var found = false; | 219 var found = false; |
| 220 for (var i = 0; i < response.refs.length && !found; i++) { | 220 for (var i = 0; i < response.refs.length && !found; i++) { |
| 221 found = response.refs[i].handle == response.body.object.ref; | 221 found = response.refs[i].handle == response.body.object.ref; |
| 222 } | 222 } |
| 223 assertTrue(found, "Scope object " + response.body.object.ref + " not found"); | 223 assertTrue(found, "Scope object " + response.body.object.ref + " not found"); |
| 224 } | 224 } |
| 225 | 225 |
| 226 // Check that the scopes have positions as expected. | |
| 227 function CheckScopeChainPositions(positions, exec_state) { | |
| 228 var all_scopes = exec_state.frame().allScopes(); | |
| 229 assertEquals(positions.length, all_scopes.length, "FrameMirror.allScopes lengt h"); | |
| 230 for (var i = 0; i < positions.length; i++) { | |
| 231 var scope = exec_state.frame().scope(i); | |
| 232 assertTrue(scope.isScope()); | |
| 233 var position = positions[i]; | |
| 234 if (!position) | |
| 235 continue; | |
| 236 | |
| 237 assertEquals(position.start, scope.details().startPosition()) | |
| 238 assertEquals(position.end, scope.details().endPosition()) | |
| 239 } | |
| 240 } | |
| 226 | 241 |
| 227 // Simple empty local scope. | 242 // Simple empty local scope. |
| 228 BeginTest("Local 1"); | 243 BeginTest("Local 1"); |
| 229 | 244 |
| 230 function local_1() { | 245 function local_1() { |
| 231 debugger; | 246 debugger; |
| 232 } | 247 } |
| 233 | 248 |
| 234 listener_delegate = function(exec_state) { | 249 listener_delegate = function(exec_state) { |
| 235 CheckScopeChain([debug.ScopeType.Local, | 250 CheckScopeChain([debug.ScopeType.Local, |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1102 class C1 { | 1117 class C1 { |
| 1103 m() { | 1118 m() { |
| 1104 debugger; | 1119 debugger; |
| 1105 } | 1120 } |
| 1106 } | 1121 } |
| 1107 new C1().m(); | 1122 new C1().m(); |
| 1108 })(); | 1123 })(); |
| 1109 | 1124 |
| 1110 EndTest(); | 1125 EndTest(); |
| 1111 | 1126 |
| 1127 BeginTest("Scope positions"); | |
| 1128 var code1 = "function f() { \n" + | |
| 1129 " var a = 1; \n" + | |
| 1130 " function b() { \n" + | |
| 1131 " debugger; \n" + | |
| 1132 " return a + 1; \n" + | |
| 1133 " } \n" + | |
| 1134 " b(); \n" + | |
| 1135 "} \n" + | |
| 1136 "f(); \n"; | |
| 1137 | |
| 1138 listener_delegate = function(exec_state) { | |
| 1139 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.
| |
| 1140 } | |
| 1141 eval(code1); | |
| 1142 EndTest(); | |
| 1143 | |
| 1144 | |
| 1145 function catch_block_2() { | |
| 1146 try { | |
| 1147 throw 'Exception'; | |
| 1148 } catch (e) { | |
| 1149 with({n:10}) { | |
| 1150 debugger; | |
| 1151 } | |
| 1152 } | |
| 1153 }; | |
| 1154 | |
| 1155 BeginTest("Scope positions in catch and 'with' statement"); | |
| 1156 var code2 = "function catch_block() { \n" + | |
| 1157 " try { \n" + | |
| 1158 " throw 'Exception'; \n" + | |
| 1159 " } catch (e) { \n" + | |
| 1160 " with({n : 10}) { \n" + | |
| 1161 " debugger; \n" + | |
| 1162 " } \n" + | |
| 1163 " } \n" + | |
| 1164 "} \n" + | |
| 1165 "catch_block(); \n"; | |
| 1166 | |
| 1167 listener_delegate = function(exec_state) { | |
| 1168 CheckScopeChainPositions([{start: 131, end: 173}, {start: 94, end: 199}, {star t: 20, end: 225}, {}, {}], exec_state); | |
| 1169 } | |
| 1170 eval(code2); | |
| 1171 EndTest(); | |
| 1172 | |
| 1173 BeginTest("Scope positions in for statement"); | |
| 1174 var code3 = "function for_statement() { \n" + | |
| 1175 " for (let i = 0; i < 1; i++) { \n" + | |
| 1176 " debugger; \n" + | |
| 1177 " } \n" + | |
| 1178 "} \n" + | |
| 1179 "for_statement(); \n"; | |
| 1180 | |
| 1181 listener_delegate = function(exec_state) { | |
| 1182 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
| |
| 1183 } | |
| 1184 eval(code3); | |
| 1185 EndTest(); | |
| 1112 | 1186 |
| 1113 assertEquals(begin_test_count, break_count, | 1187 assertEquals(begin_test_count, break_count, |
| 1114 'one or more tests did not enter the debugger'); | 1188 'one or more tests did not enter the debugger'); |
| 1115 assertEquals(begin_test_count, end_test_count, | 1189 assertEquals(begin_test_count, end_test_count, |
| 1116 'one or more tests did not have its result checked'); | 1190 'one or more tests did not have its result checked'); |
| OLD | NEW |