| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 140 } |
| 141 count++; | 141 count++; |
| 142 } | 142 } |
| 143 | 143 |
| 144 // 'arguments' and might be exposed in the local and closure scope. Just | 144 // 'arguments' and might be exposed in the local and closure scope. Just |
| 145 // ignore this. | 145 // ignore this. |
| 146 var scope_size = scope.scopeObject().properties().length; | 146 var scope_size = scope.scopeObject().properties().length; |
| 147 if (!scope.scopeObject().property('arguments').isUndefined()) { | 147 if (!scope.scopeObject().property('arguments').isUndefined()) { |
| 148 scope_size--; | 148 scope_size--; |
| 149 } | 149 } |
| 150 // Also ignore synthetic variable from catch block. | |
| 151 if (!scope.scopeObject().property('.catch-var').isUndefined()) { | |
| 152 scope_size--; | |
| 153 } | |
| 154 // Skip property with empty name. | 150 // Skip property with empty name. |
| 155 if (!scope.scopeObject().property('').isUndefined()) { | 151 if (!scope.scopeObject().property('').isUndefined()) { |
| 156 scope_size--; | 152 scope_size--; |
| 157 } | 153 } |
| 158 // Also ignore synthetic variable from block scopes. | |
| 159 if (!scope.scopeObject().property('.block').isUndefined()) { | |
| 160 scope_size--; | |
| 161 } | |
| 162 | 154 |
| 163 if (count != scope_size) { | 155 if (count != scope_size) { |
| 164 print('Names found in scope:'); | 156 print('Names found in scope:'); |
| 165 var names = scope.scopeObject().propertyNames(); | 157 var names = scope.scopeObject().propertyNames(); |
| 166 for (var i = 0; i < names.length; i++) { | 158 for (var i = 0; i < names.length; i++) { |
| 167 print(names[i]); | 159 print(names[i]); |
| 168 } | 160 } |
| 169 } | 161 } |
| 170 assertEquals(count, scope_size); | 162 assertEquals(count, scope_size); |
| 171 | 163 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 for (let x in {y:undefined}) { | 360 for (let x in {y:undefined}) { |
| 369 debugger; | 361 debugger; |
| 370 } | 362 } |
| 371 } | 363 } |
| 372 | 364 |
| 373 listener_delegate = function(exec_state) { | 365 listener_delegate = function(exec_state) { |
| 374 CheckScopeChain([debug.ScopeType.Block, | 366 CheckScopeChain([debug.ScopeType.Block, |
| 375 debug.ScopeType.Local, | 367 debug.ScopeType.Local, |
| 376 debug.ScopeType.Global], exec_state); | 368 debug.ScopeType.Global], exec_state); |
| 377 CheckScopeContent({x:'y'}, 0, exec_state); | 369 CheckScopeContent({x:'y'}, 0, exec_state); |
| 378 // The function scope contains a temporary iteration variable. | 370 // The function scope contains a temporary iteration variable, but it is |
| 379 CheckScopeContent({'.for.x':'y'}, 1, exec_state); | 371 // hidden to the debugger. |
| 372 CheckScopeContent({}, 1, exec_state); |
| 380 }; | 373 }; |
| 381 for_loop_1(); | 374 for_loop_1(); |
| 382 EndTest(); | 375 EndTest(); |
| 383 | 376 |
| 384 | 377 |
| 385 // For-in loop over the keys of an object with a block scoped let variable | 378 // For-in loop over the keys of an object with a block scoped let variable |
| 386 // shadowing the iteration variable. | 379 // shadowing the iteration variable. |
| 387 BeginTest("For loop 2"); | 380 BeginTest("For loop 2"); |
| 388 | 381 |
| 389 function for_loop_2() { | 382 function for_loop_2() { |
| 390 for (let x in {y:undefined}) { | 383 for (let x in {y:undefined}) { |
| 391 let x = 3; | 384 let x = 3; |
| 392 debugger; | 385 debugger; |
| 393 } | 386 } |
| 394 } | 387 } |
| 395 | 388 |
| 396 listener_delegate = function(exec_state) { | 389 listener_delegate = function(exec_state) { |
| 397 CheckScopeChain([debug.ScopeType.Block, | 390 CheckScopeChain([debug.ScopeType.Block, |
| 398 debug.ScopeType.Block, | 391 debug.ScopeType.Block, |
| 399 debug.ScopeType.Local, | 392 debug.ScopeType.Local, |
| 400 debug.ScopeType.Global], exec_state); | 393 debug.ScopeType.Global], exec_state); |
| 401 CheckScopeContent({x:3}, 0, exec_state); | 394 CheckScopeContent({x:3}, 0, exec_state); |
| 402 CheckScopeContent({x:'y'}, 1, exec_state); | 395 CheckScopeContent({x:'y'}, 1, exec_state); |
| 403 // The function scope contains a temporary iteration variable. | 396 // The function scope contains a temporary iteration variable, hidden to the |
| 404 CheckScopeContent({'.for.x':'y'}, 2, exec_state); | 397 // debugger. |
| 398 CheckScopeContent({}, 2, exec_state); |
| 405 }; | 399 }; |
| 406 for_loop_2(); | 400 for_loop_2(); |
| 407 EndTest(); | 401 EndTest(); |
| 408 | 402 |
| 409 | 403 |
| 410 // Simple for loop. | 404 // Simple for loop. |
| 411 BeginTest("For loop 3"); | 405 BeginTest("For loop 3"); |
| 412 | 406 |
| 413 function for_loop_3() { | 407 function for_loop_3() { |
| 414 for (let x = 3; x < 4; ++x) { | 408 for (let x = 3; x < 4; ++x) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 455 |
| 462 listener_delegate = function(exec_state) { | 456 listener_delegate = function(exec_state) { |
| 463 CheckScopeChain([debug.ScopeType.Block, | 457 CheckScopeChain([debug.ScopeType.Block, |
| 464 debug.ScopeType.Local, | 458 debug.ScopeType.Local, |
| 465 debug.ScopeType.Global], exec_state); | 459 debug.ScopeType.Global], exec_state); |
| 466 CheckScopeContent({x:3,y:5}, 0, exec_state); | 460 CheckScopeContent({x:3,y:5}, 0, exec_state); |
| 467 CheckScopeContent({}, 1, exec_state); | 461 CheckScopeContent({}, 1, exec_state); |
| 468 }; | 462 }; |
| 469 for_loop_5(); | 463 for_loop_5(); |
| 470 EndTest(); | 464 EndTest(); |
| OLD | NEW |