| 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 // Flags: --expose-debug-as debug --allow-natives-syntax --noanalyze-environment
-liveness | 28 // Flags: --noanalyze-environment-liveness |
| 29 // The functions used for testing backtraces. They are at the top to make the | 29 // The functions used for testing backtraces. They are at the top to make the |
| 30 // testing of source line/column easier. | 30 // testing of source line/column easier. |
| 31 | 31 |
| 32 // Get the Debug object exposed from the debug context global object. | |
| 33 var Debug = debug.Debug; | 32 var Debug = debug.Debug; |
| 34 | 33 |
| 35 var test_name; | 34 var test_name; |
| 36 var listener_delegate; | 35 var listener_delegate; |
| 37 var listener_called; | 36 var listener_called; |
| 38 var exception; | 37 var exception; |
| 39 var begin_test_count = 0; | 38 var begin_test_count = 0; |
| 40 var end_test_count = 0; | 39 var end_test_count = 0; |
| 41 var break_count = 0; | 40 var break_count = 0; |
| 41 var global_marker = 7; |
| 42 | 42 |
| 43 | 43 |
| 44 // Debug event listener which delegates. | 44 // Debug event listener which delegates. |
| 45 function listener(event, exec_state, event_data, data) { | 45 function listener(event, exec_state, event_data, data) { |
| 46 try { | 46 try { |
| 47 if (event == Debug.DebugEvent.Break) { | 47 if (event == Debug.DebugEvent.Break) { |
| 48 break_count++; | 48 break_count++; |
| 49 listener_called = true; | 49 listener_called = true; |
| 50 listener_delegate(exec_state); | 50 listener_delegate(exec_state); |
| 51 } | 51 } |
| 52 } catch (e) { | 52 } catch (e) { |
| 53 exception = e; | 53 exception = e; |
| 54 print(e, e.stack); |
| 54 } | 55 } |
| 55 } | 56 } |
| 56 | 57 |
| 57 // Add the debug event listener. | 58 // Add the debug event listener. |
| 58 Debug.setListener(listener); | 59 Debug.setListener(listener); |
| 59 | 60 |
| 60 | 61 |
| 61 // Initialize for a new test. | 62 // Initialize for a new test. |
| 62 function BeginTest(name) { | 63 function BeginTest(name) { |
| 63 test_name = name; | 64 test_name = name; |
| 64 listener_delegate = null; | 65 listener_delegate = null; |
| 65 listener_called = false; | 66 listener_called = false; |
| 66 exception = null; | 67 exception = null; |
| 67 begin_test_count++; | 68 begin_test_count++; |
| 68 } | 69 } |
| 69 | 70 |
| 70 | 71 |
| 71 // Check result of a test. | 72 // Check result of a test. |
| 72 function EndTest() { | 73 function EndTest() { |
| 73 assertTrue(listener_called, "listerner not called for " + test_name); | 74 assertTrue(listener_called, "listener not called for " + test_name); |
| 74 assertNull(exception, test_name + " / " + exception); | 75 assertNull(exception, test_name + " / " + exception); |
| 75 end_test_count++; | 76 end_test_count++; |
| 76 } | 77 } |
| 77 | 78 |
| 78 | 79 |
| 79 // Check that two scope are the same. | 80 // Check that two scope are the same. |
| 80 function assertScopeMirrorEquals(scope1, scope2) { | 81 function assertScopeMirrorEquals(scope1, scope2) { |
| 81 assertEquals(scope1.scopeType(), scope2.scopeType()); | 82 assertEquals(scope1.scopeType(), scope2.scopeType()); |
| 82 assertEquals(scope1.frameIndex(), scope2.frameIndex()); | 83 assertEquals(scope1.frameIndex(), scope2.frameIndex()); |
| 83 assertEquals(scope1.scopeIndex(), scope2.scopeIndex()); | 84 assertEquals(scope1.scopeIndex(), scope2.scopeIndex()); |
| 84 assertPropertiesEqual(scope1.scopeObject().value(), scope2.scopeObject().value
()); | 85 assertPropertiesEqual(scope1.scopeObject().value(), scope2.scopeObject().value
()); |
| 85 } | 86 } |
| 86 | 87 |
| 87 function CheckFastAllScopes(scopes, exec_state) | 88 function CheckFastAllScopes(scopes, exec_state) |
| 88 { | 89 { |
| 89 var fast_all_scopes = exec_state.frame().allScopes(true); | 90 var fast_all_scopes = exec_state.frame().allScopes(true); |
| 90 var length = fast_all_scopes.length; | 91 var length = fast_all_scopes.length; |
| 91 assertTrue(scopes.length >= length); | 92 assertTrue(scopes.length >= length); |
| 92 for (var i = 0; i < scopes.length && i < length; i++) { | 93 for (var i = 0; i < scopes.length && i < length; i++) { |
| 93 var scope = fast_all_scopes[length - i - 1]; | 94 var scope = fast_all_scopes[length - i - 1]; |
| 94 assertTrue(scope.isScope()); | |
| 95 assertEquals(scopes[scopes.length - i - 1], scope.scopeType()); | 95 assertEquals(scopes[scopes.length - i - 1], scope.scopeType()); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 | 99 |
| 100 // Check that the scope chain contains the expected types of scopes. | 100 // Check that the scope chain contains the expected types of scopes. |
| 101 function CheckScopeChain(scopes, exec_state) { | 101 function CheckScopeChain(scopes, exec_state) { |
| 102 var all_scopes = exec_state.frame().allScopes(); | 102 var all_scopes = exec_state.frame().allScopes(); |
| 103 assertEquals(scopes.length, exec_state.frame().scopeCount()); | 103 assertEquals(scopes.length, exec_state.frame().scopeCount()); |
| 104 assertEquals(scopes.length, all_scopes.length, "FrameMirror.allScopes length")
; | 104 assertEquals(scopes.length, all_scopes.length, "FrameMirror.allScopes length")
; |
| 105 for (var i = 0; i < scopes.length; i++) { | 105 for (var i = 0; i < scopes.length; i++) { |
| 106 var scope = exec_state.frame().scope(i); | 106 var scope = exec_state.frame().scope(i); |
| 107 assertTrue(scope.isScope()); | |
| 108 assertEquals(scopes[i], scope.scopeType()); | 107 assertEquals(scopes[i], scope.scopeType()); |
| 109 assertScopeMirrorEquals(all_scopes[i], scope); | 108 assertScopeMirrorEquals(all_scopes[i], scope); |
| 110 | 109 |
| 111 // Check the global object when hitting the global scope. | 110 // Check the global object when hitting the global scope. |
| 112 if (scopes[i] == debug.ScopeType.Global) { | 111 if (scopes[i] == debug.ScopeType.Global) { |
| 113 // Objects don't have same class (one is "global", other is "Object", | 112 // Just check the marker of the global object. |
| 114 // so just check the properties directly. | 113 assertEquals(scope.scopeObject().value().global_marker, global_marker); |
| 115 assertPropertiesEqual(this, scope.scopeObject().value()); | |
| 116 } | 114 } |
| 117 } | 115 } |
| 118 CheckFastAllScopes(scopes, exec_state); | 116 CheckFastAllScopes(scopes, exec_state); |
| 119 } | 117 } |
| 120 | 118 |
| 121 | 119 |
| 122 // Check that the scope chain contains the expected names of scopes. | 120 // Check that the scope chain contains the expected names of scopes. |
| 123 function CheckScopeChainNames(names, exec_state) { | 121 function CheckScopeChainNames(names, exec_state) { |
| 124 var all_scopes = exec_state.frame().allScopes(); | 122 var all_scopes = exec_state.frame().allScopes(); |
| 125 assertEquals(names.length, all_scopes.length, "FrameMirror.allScopes length"); | 123 assertEquals(names.length, all_scopes.length, "FrameMirror.allScopes length"); |
| 126 for (var i = 0; i < names.length; i++) { | 124 for (var i = 0; i < names.length; i++) { |
| 127 var scope = exec_state.frame().scope(i); | 125 var scope = exec_state.frame().scope(i); |
| 128 assertTrue(scope.isScope()); | |
| 129 assertEquals(names[i], scope.details().name()) | 126 assertEquals(names[i], scope.details().name()) |
| 130 } | 127 } |
| 131 } | 128 } |
| 132 | 129 |
| 133 | 130 |
| 134 // Check that the scope contains at least minimum_content. For functions just | 131 // Check that the scope contains at least minimum_content. For functions just |
| 135 // check that there is a function. | 132 // check that there is a function. |
| 136 function CheckScopeContent(minimum_content, number, exec_state) { | 133 function CheckScopeContent(minimum_content, number, exec_state) { |
| 137 var scope = exec_state.frame().scope(number); | 134 var scope = exec_state.frame().scope(number); |
| 138 var minimum_count = 0; | 135 var minimum_count = 0; |
| 139 for (var p in minimum_content) { | 136 for (var p in minimum_content) { |
| 140 var property_mirror = scope.scopeObject().property(p); | 137 var property_mirror = scope.scopeObject().property(p); |
| 141 assertFalse(property_mirror.isUndefined(), | 138 assertFalse(property_mirror.isUndefined(), |
| 142 'property ' + p + ' not found in scope'); | 139 'property ' + p + ' not found in scope'); |
| 143 if (typeof(minimum_content[p]) === 'function') { | 140 assertEquals(minimum_content[p], property_mirror.value().value(), |
| 144 assertTrue(property_mirror.value().isFunction()); | 141 'property ' + p + ' has unexpected value'); |
| 145 } else { | |
| 146 assertEquals(minimum_content[p], property_mirror.value().value(), | |
| 147 'property ' + p + ' has unexpected value'); | |
| 148 } | |
| 149 minimum_count++; | 142 minimum_count++; |
| 150 } | 143 } |
| 151 | 144 |
| 152 // 'arguments' and might be exposed in the local and closure scope. Just | 145 // 'arguments' and might be exposed in the local and closure scope. Just |
| 153 // ignore this. | 146 // ignore this. |
| 154 var scope_size = scope.scopeObject().properties().length; | 147 var scope_size = scope.scopeObject().properties().length; |
| 155 if (!scope.scopeObject().property('arguments').isUndefined()) { | 148 if (!scope.scopeObject().property('arguments').isUndefined()) { |
| 156 scope_size--; | 149 scope_size--; |
| 157 } | 150 } |
| 158 // Ditto for 'this'. | 151 // Ditto for 'this'. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 171 } | 164 } |
| 172 assertTrue(scope_size >= minimum_count); | 165 assertTrue(scope_size >= minimum_count); |
| 173 } | 166 } |
| 174 | 167 |
| 175 // Check that the scopes have positions as expected. | 168 // Check that the scopes have positions as expected. |
| 176 function CheckScopeChainPositions(positions, exec_state) { | 169 function CheckScopeChainPositions(positions, exec_state) { |
| 177 var all_scopes = exec_state.frame().allScopes(); | 170 var all_scopes = exec_state.frame().allScopes(); |
| 178 assertEquals(positions.length, all_scopes.length, "FrameMirror.allScopes lengt
h"); | 171 assertEquals(positions.length, all_scopes.length, "FrameMirror.allScopes lengt
h"); |
| 179 for (var i = 0; i < positions.length; i++) { | 172 for (var i = 0; i < positions.length; i++) { |
| 180 var scope = exec_state.frame().scope(i); | 173 var scope = exec_state.frame().scope(i); |
| 181 assertTrue(scope.isScope()); | |
| 182 var position = positions[i]; | 174 var position = positions[i]; |
| 183 if (!position) | 175 if (!position) |
| 184 continue; | 176 continue; |
| 185 | 177 |
| 186 assertEquals(position.start, scope.details().startPosition()) | 178 assertEquals(position.start, scope.details().startPosition()) |
| 187 assertEquals(position.end, scope.details().endPosition()) | 179 assertEquals(position.end, scope.details().endPosition()) |
| 188 } | 180 } |
| 189 } | 181 } |
| 190 | 182 |
| 191 // Simple empty local scope. | 183 // Simple empty local scope. |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 } | 410 } |
| 419 | 411 |
| 420 listener_delegate = function(exec_state) { | 412 listener_delegate = function(exec_state) { |
| 421 CheckScopeChain([debug.ScopeType.With, | 413 CheckScopeChain([debug.ScopeType.With, |
| 422 debug.ScopeType.With, | 414 debug.ScopeType.With, |
| 423 debug.ScopeType.Local, | 415 debug.ScopeType.Local, |
| 424 debug.ScopeType.Script, | 416 debug.ScopeType.Script, |
| 425 debug.ScopeType.Global], exec_state); | 417 debug.ScopeType.Global], exec_state); |
| 426 CheckScopeContent(with_object, 0, exec_state); | 418 CheckScopeContent(with_object, 0, exec_state); |
| 427 CheckScopeContent(with_object, 1, exec_state); | 419 CheckScopeContent(with_object, 1, exec_state); |
| 428 assertEquals(exec_state.frame().scope(0).scopeObject(), | 420 assertEquals(exec_state.frame().scope(0).scopeObject().value(), |
| 429 exec_state.frame().scope(1).scopeObject()); | 421 exec_state.frame().scope(1).scopeObject().value()); |
| 430 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); | 422 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); |
| 431 }; | 423 }; |
| 432 with_5(); | 424 with_5(); |
| 433 EndTest(); | 425 EndTest(); |
| 434 | 426 |
| 435 | 427 |
| 436 // Nested with blocks using existing object in global code. | 428 // Nested with blocks using existing object in global code. |
| 437 BeginTest("With 6"); | 429 BeginTest("With 6"); |
| 438 listener_delegate = function(exec_state) { | 430 listener_delegate = function(exec_state) { |
| 439 CheckScopeChain([debug.ScopeType.With, | 431 CheckScopeChain([debug.ScopeType.With, |
| 440 debug.ScopeType.With, | 432 debug.ScopeType.With, |
| 441 debug.ScopeType.Script, | 433 debug.ScopeType.Script, |
| 442 debug.ScopeType.Global], exec_state); | 434 debug.ScopeType.Global], exec_state); |
| 443 CheckScopeContent(with_object, 0, exec_state); | 435 CheckScopeContent(with_object, 0, exec_state); |
| 444 CheckScopeContent(with_object, 1, exec_state); | 436 CheckScopeContent(with_object, 1, exec_state); |
| 445 assertEquals(exec_state.frame().scope(0).scopeObject(), | 437 assertEquals(exec_state.frame().scope(0).scopeObject().value(), |
| 446 exec_state.frame().scope(1).scopeObject()); | 438 exec_state.frame().scope(1).scopeObject().value()); |
| 447 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); | 439 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); |
| 448 }; | 440 }; |
| 449 | 441 |
| 450 var with_object = {c:3,d:4}; | 442 var with_object = {c:3,d:4}; |
| 451 with(with_object) { | 443 with(with_object) { |
| 452 with(with_object) { | 444 with(with_object) { |
| 453 debugger; | 445 debugger; |
| 454 } | 446 } |
| 455 } | 447 } |
| 456 EndTest(); | 448 EndTest(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 } | 565 } |
| 574 }; | 566 }; |
| 575 return f; | 567 return f; |
| 576 } | 568 } |
| 577 | 569 |
| 578 listener_delegate = function(exec_state) { | 570 listener_delegate = function(exec_state) { |
| 579 CheckScopeChain([debug.ScopeType.Local, | 571 CheckScopeChain([debug.ScopeType.Local, |
| 580 debug.ScopeType.Closure, | 572 debug.ScopeType.Closure, |
| 581 debug.ScopeType.Script, | 573 debug.ScopeType.Script, |
| 582 debug.ScopeType.Global], exec_state); | 574 debug.ScopeType.Global], exec_state); |
| 583 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); | 575 CheckScopeContent({a:1,b:2,x:3,y:4,f:undefined}, 1, exec_state); |
| 584 CheckScopeChainNames(["f", "closure_4", undefined, undefined], exec_state); | 576 CheckScopeChainNames(["f", "closure_4", undefined, undefined], exec_state); |
| 585 }; | 577 }; |
| 586 closure_4(1, 2)(); | 578 closure_4(1, 2)(); |
| 587 EndTest(); | 579 EndTest(); |
| 588 | 580 |
| 589 | 581 |
| 590 | 582 |
| 591 // Simple closure formed by returning an inner function referering the outer | 583 // Simple closure formed by returning an inner function referering the outer |
| 592 // functions arguments. In the presence of eval all arguments and locals | 584 // functions arguments. In the presence of eval all arguments and locals |
| 593 // (including the inner function itself) from the outer function becomes part of | 585 // (including the inner function itself) from the outer function becomes part of |
| 594 // the debugger infformation on the closure. | 586 // the debugger infformation on the closure. |
| 595 BeginTest("Closure 5"); | 587 BeginTest("Closure 5"); |
| 596 | 588 |
| 597 function closure_5(a, b) { | 589 function closure_5(a, b) { |
| 598 var x = 3; | 590 var x = 3; |
| 599 var y = 4; | 591 var y = 4; |
| 600 function f() { | 592 function f() { |
| 601 eval(''); | 593 eval(''); |
| 602 debugger; | 594 debugger; |
| 603 return 1; | 595 return 1; |
| 604 }; | 596 }; |
| 605 return f; | 597 return f; |
| 606 } | 598 } |
| 607 | 599 |
| 608 listener_delegate = function(exec_state) { | 600 listener_delegate = function(exec_state) { |
| 609 CheckScopeChain([debug.ScopeType.Local, | 601 CheckScopeChain([debug.ScopeType.Local, |
| 610 debug.ScopeType.Closure, | 602 debug.ScopeType.Closure, |
| 611 debug.ScopeType.Script, | 603 debug.ScopeType.Script, |
| 612 debug.ScopeType.Global], exec_state); | 604 debug.ScopeType.Global], exec_state); |
| 613 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); | 605 CheckScopeContent({a:1,b:2,x:3,y:4,f:undefined}, 1, exec_state); |
| 614 CheckScopeChainNames(["f", "closure_5", undefined, undefined], exec_state) | 606 CheckScopeChainNames(["f", "closure_5", undefined, undefined], exec_state) |
| 615 }; | 607 }; |
| 616 closure_5(1, 2)(); | 608 closure_5(1, 2)(); |
| 617 EndTest(); | 609 EndTest(); |
| 618 | 610 |
| 619 | 611 |
| 620 // Two closures. Due to optimizations only the parts actually used are provided | 612 // Two closures. Due to optimizations only the parts actually used are provided |
| 621 // through the debugger information. | 613 // through the debugger information. |
| 622 BeginTest("Closure 6"); | 614 BeginTest("Closure 6"); |
| 623 function closure_6(a, b) { | 615 function closure_6(a, b) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 635 return f(a, b); | 627 return f(a, b); |
| 636 } | 628 } |
| 637 | 629 |
| 638 listener_delegate = function(exec_state) { | 630 listener_delegate = function(exec_state) { |
| 639 CheckScopeChain([debug.ScopeType.Local, | 631 CheckScopeChain([debug.ScopeType.Local, |
| 640 debug.ScopeType.Closure, | 632 debug.ScopeType.Closure, |
| 641 debug.ScopeType.Closure, | 633 debug.ScopeType.Closure, |
| 642 debug.ScopeType.Script, | 634 debug.ScopeType.Script, |
| 643 debug.ScopeType.Global], exec_state); | 635 debug.ScopeType.Global], exec_state); |
| 644 CheckScopeContent({a:1}, 1, exec_state); | 636 CheckScopeContent({a:1}, 1, exec_state); |
| 645 CheckScopeContent({f:function(){}}, 2, exec_state); | 637 CheckScopeContent({f:undefined}, 2, exec_state); |
| 646 CheckScopeChainNames([undefined, "f", "closure_6", undefined, undefined], | 638 CheckScopeChainNames([undefined, "f", "closure_6", undefined, undefined], |
| 647 exec_state); | 639 exec_state); |
| 648 }; | 640 }; |
| 649 closure_6(1, 2)(); | 641 closure_6(1, 2)(); |
| 650 EndTest(); | 642 EndTest(); |
| 651 | 643 |
| 652 | 644 |
| 653 // Two closures. In the presence of eval all information is provided as the | 645 // Two closures. In the presence of eval all information is provided as the |
| 654 // compiler cannot determine which parts are used. | 646 // compiler cannot determine which parts are used. |
| 655 BeginTest("Closure 7"); | 647 BeginTest("Closure 7"); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 673 } | 665 } |
| 674 | 666 |
| 675 listener_delegate = function(exec_state) { | 667 listener_delegate = function(exec_state) { |
| 676 CheckScopeChain([debug.ScopeType.Local, | 668 CheckScopeChain([debug.ScopeType.Local, |
| 677 debug.ScopeType.Closure, | 669 debug.ScopeType.Closure, |
| 678 debug.ScopeType.Closure, | 670 debug.ScopeType.Closure, |
| 679 debug.ScopeType.Script, | 671 debug.ScopeType.Script, |
| 680 debug.ScopeType.Global], exec_state); | 672 debug.ScopeType.Global], exec_state); |
| 681 CheckScopeContent({}, 0, exec_state); | 673 CheckScopeContent({}, 0, exec_state); |
| 682 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state); | 674 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state); |
| 683 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 2, exec_state); | 675 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:undefined}, 2, exec_state); |
| 684 CheckScopeChainNames([undefined, "f", "closure_7", undefined, undefined], | 676 CheckScopeChainNames([undefined, "f", "closure_7", undefined, undefined], |
| 685 exec_state); | 677 exec_state); |
| 686 }; | 678 }; |
| 687 closure_7(1, 2)(); | 679 closure_7(1, 2)(); |
| 688 EndTest(); | 680 EndTest(); |
| 689 | 681 |
| 690 | 682 |
| 691 // Closure that may be optimized out. | 683 // Closure that may be optimized out. |
| 692 BeginTest("Closure 8"); | 684 BeginTest("Closure 8"); |
| 693 function closure_8() { | 685 function closure_8() { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 debug.ScopeType.With, | 757 debug.ScopeType.With, |
| 766 debug.ScopeType.Closure, | 758 debug.ScopeType.Closure, |
| 767 debug.ScopeType.Closure, | 759 debug.ScopeType.Closure, |
| 768 debug.ScopeType.Script, | 760 debug.ScopeType.Script, |
| 769 debug.ScopeType.Global], exec_state); | 761 debug.ScopeType.Global], exec_state); |
| 770 CheckScopeContent({b:16}, 0, exec_state); | 762 CheckScopeContent({b:16}, 0, exec_state); |
| 771 CheckScopeContent({a:15}, 1, exec_state); | 763 CheckScopeContent({a:15}, 1, exec_state); |
| 772 CheckScopeContent({x:14}, 2, exec_state); | 764 CheckScopeContent({x:14}, 2, exec_state); |
| 773 CheckScopeContent({j:13}, 3, exec_state); | 765 CheckScopeContent({j:13}, 3, exec_state); |
| 774 CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state); | 766 CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state); |
| 775 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, exec_state); | 767 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:undefined}, 5, exec_state); |
| 776 CheckScopeChainNames([undefined, undefined, undefined, "f", "f", | 768 CheckScopeChainNames([undefined, undefined, undefined, "f", "f", |
| 777 "the_full_monty", undefined, undefined], exec_state); | 769 "the_full_monty", undefined, undefined], exec_state); |
| 778 }; | 770 }; |
| 779 the_full_monty(1, 2)(); | 771 the_full_monty(1, 2)(); |
| 780 EndTest(); | 772 EndTest(); |
| 781 | 773 |
| 782 | 774 |
| 783 BeginTest("Closure inside With 1"); | 775 BeginTest("Closure inside With 1"); |
| 784 function closure_in_with_1() { | 776 function closure_in_with_1() { |
| 785 with({x:1}) { | 777 with({x:1}) { |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 CheckScopeChainPositions( | 1251 CheckScopeChainPositions( |
| 1260 [{start: 89, end: 183}, {start: 27, end: 217}, {}, {}], exec_state); | 1252 [{start: 89, end: 183}, {start: 27, end: 217}, {}, {}], exec_state); |
| 1261 } | 1253 } |
| 1262 eval(code8); | 1254 eval(code8); |
| 1263 EndTest(); | 1255 EndTest(); |
| 1264 | 1256 |
| 1265 assertEquals(begin_test_count, break_count, | 1257 assertEquals(begin_test_count, break_count, |
| 1266 'one or more tests did not enter the debugger'); | 1258 'one or more tests did not enter the debugger'); |
| 1267 assertEquals(begin_test_count, end_test_count, | 1259 assertEquals(begin_test_count, end_test_count, |
| 1268 'one or more tests did not have its result checked'); | 1260 'one or more tests did not have its result checked'); |
| OLD | NEW |