| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 138 } |
| 139 var found = false; | 139 var found = false; |
| 140 for (var j = 0; j < response.refs.length && !found; j++) { | 140 for (var j = 0; j < response.refs.length && !found; j++) { |
| 141 found = response.refs[j].handle == response.body.scopes[i].object.ref; | 141 found = response.refs[j].handle == response.body.scopes[i].object.ref; |
| 142 } | 142 } |
| 143 assertTrue(found, "Scope object " + response.body.scopes[i].object.ref + " n
ot found"); | 143 assertTrue(found, "Scope object " + response.body.scopes[i].object.ref + " n
ot found"); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 | 147 |
| 148 // Check that the scope chain contains the expected names of scopes. |
| 149 function CheckScopeChainNames(names, exec_state) { |
| 150 var all_scopes = exec_state.frame().allScopes(); |
| 151 assertEquals(names.length, all_scopes.length, "FrameMirror.allScopes length"); |
| 152 for (var i = 0; i < names.length; i++) { |
| 153 var scope = exec_state.frame().scope(i); |
| 154 assertTrue(scope.isScope()); |
| 155 assertEquals(scope.details().name(), names[i]) |
| 156 } |
| 157 } |
| 158 |
| 159 |
| 148 // Check that the content of the scope is as expected. For functions just check | 160 // Check that the content of the scope is as expected. For functions just check |
| 149 // that there is a function. | 161 // that there is a function. |
| 150 function CheckScopeContent(content, number, exec_state) { | 162 function CheckScopeContent(content, number, exec_state) { |
| 151 var scope = exec_state.frame().scope(number); | 163 var scope = exec_state.frame().scope(number); |
| 152 var count = 0; | 164 var count = 0; |
| 153 for (var p in content) { | 165 for (var p in content) { |
| 154 var property_mirror = scope.scopeObject().property(p); | 166 var property_mirror = scope.scopeObject().property(p); |
| 155 assertFalse(property_mirror.isUndefined(), 'property ' + p + ' not found in
scope'); | 167 assertFalse(property_mirror.isUndefined(), 'property ' + p + ' not found in
scope'); |
| 156 if (typeof(content[p]) === 'function') { | 168 if (typeof(content[p]) === 'function') { |
| 157 assertTrue(property_mirror.value().isFunction()); | 169 assertTrue(property_mirror.value().isFunction()); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 }; | 522 }; |
| 511 return f; | 523 return f; |
| 512 } | 524 } |
| 513 | 525 |
| 514 listener_delegate = function(exec_state) { | 526 listener_delegate = function(exec_state) { |
| 515 CheckScopeChain([debug.ScopeType.Local, | 527 CheckScopeChain([debug.ScopeType.Local, |
| 516 debug.ScopeType.Closure, | 528 debug.ScopeType.Closure, |
| 517 debug.ScopeType.Script, | 529 debug.ScopeType.Script, |
| 518 debug.ScopeType.Global], exec_state); | 530 debug.ScopeType.Global], exec_state); |
| 519 CheckScopeContent({a:1}, 1, exec_state); | 531 CheckScopeContent({a:1}, 1, exec_state); |
| 532 CheckScopeChainNames([undefined, "closure_1", undefined, undefined], exec_stat
e) |
| 520 }; | 533 }; |
| 521 closure_1(1)(); | 534 closure_1(1)(); |
| 522 EndTest(); | 535 EndTest(); |
| 523 | 536 |
| 524 | 537 |
| 525 // Simple closure formed by returning an inner function referering the outer | 538 // Simple closure formed by returning an inner function referering the outer |
| 526 // functions arguments. Due to VM optimizations parts of the actual closure is | 539 // functions arguments. Due to VM optimizations parts of the actual closure is |
| 527 // missing from the debugger information. | 540 // missing from the debugger information. |
| 528 BeginTest("Closure 2"); | 541 BeginTest("Closure 2"); |
| 529 | 542 |
| 530 function closure_2(a, b) { | 543 function closure_2(a, b) { |
| 531 var x = a + 2; | 544 var x = a + 2; |
| 532 var y = b + 2; | 545 var y = b + 2; |
| 533 function f() { | 546 function f() { |
| 534 debugger; | 547 debugger; |
| 535 return a + x; | 548 return a + x; |
| 536 }; | 549 }; |
| 537 return f; | 550 return f; |
| 538 } | 551 } |
| 539 | 552 |
| 540 listener_delegate = function(exec_state) { | 553 listener_delegate = function(exec_state) { |
| 541 CheckScopeChain([debug.ScopeType.Local, | 554 CheckScopeChain([debug.ScopeType.Local, |
| 542 debug.ScopeType.Closure, | 555 debug.ScopeType.Closure, |
| 543 debug.ScopeType.Script, | 556 debug.ScopeType.Script, |
| 544 debug.ScopeType.Global], exec_state); | 557 debug.ScopeType.Global], exec_state); |
| 545 CheckScopeContent({a:1,x:3}, 1, exec_state); | 558 CheckScopeContent({a:1,x:3}, 1, exec_state); |
| 559 CheckScopeChainNames([undefined, "closure_2", undefined, undefined], exec_stat
e) |
| 546 }; | 560 }; |
| 547 closure_2(1, 2)(); | 561 closure_2(1, 2)(); |
| 548 EndTest(); | 562 EndTest(); |
| 549 | 563 |
| 550 | 564 |
| 551 // Simple closure formed by returning an inner function referering the outer | 565 // Simple closure formed by returning an inner function referering the outer |
| 552 // functions arguments. Using all arguments and locals from the outer function | 566 // functions arguments. Using all arguments and locals from the outer function |
| 553 // in the inner function makes these part of the debugger information on the | 567 // in the inner function makes these part of the debugger information on the |
| 554 // closure. | 568 // closure. |
| 555 BeginTest("Closure 3"); | 569 BeginTest("Closure 3"); |
| 556 | 570 |
| 557 function closure_3(a, b) { | 571 function closure_3(a, b) { |
| 558 var x = a + 2; | 572 var x = a + 2; |
| 559 var y = b + 2; | 573 var y = b + 2; |
| 560 function f() { | 574 function f() { |
| 561 debugger; | 575 debugger; |
| 562 return a + b + x + y; | 576 return a + b + x + y; |
| 563 }; | 577 }; |
| 564 return f; | 578 return f; |
| 565 } | 579 } |
| 566 | 580 |
| 567 listener_delegate = function(exec_state) { | 581 listener_delegate = function(exec_state) { |
| 568 CheckScopeChain([debug.ScopeType.Local, | 582 CheckScopeChain([debug.ScopeType.Local, |
| 569 debug.ScopeType.Closure, | 583 debug.ScopeType.Closure, |
| 570 debug.ScopeType.Script, | 584 debug.ScopeType.Script, |
| 571 debug.ScopeType.Global], exec_state); | 585 debug.ScopeType.Global], exec_state); |
| 572 CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state); | 586 CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state); |
| 587 CheckScopeChainNames([undefined, "closure_3", undefined, undefined], exec_stat
e) |
| 573 }; | 588 }; |
| 574 closure_3(1, 2)(); | 589 closure_3(1, 2)(); |
| 575 EndTest(); | 590 EndTest(); |
| 576 | 591 |
| 577 | 592 |
| 578 | 593 |
| 579 // Simple closure formed by returning an inner function referering the outer | 594 // Simple closure formed by returning an inner function referering the outer |
| 580 // functions arguments. Using all arguments and locals from the outer function | 595 // functions arguments. Using all arguments and locals from the outer function |
| 581 // in the inner function makes these part of the debugger information on the | 596 // in the inner function makes these part of the debugger information on the |
| 582 // closure. Use the inner function as well... | 597 // closure. Use the inner function as well... |
| (...skipping 10 matching lines...) Expand all Loading... |
| 593 }; | 608 }; |
| 594 return f; | 609 return f; |
| 595 } | 610 } |
| 596 | 611 |
| 597 listener_delegate = function(exec_state) { | 612 listener_delegate = function(exec_state) { |
| 598 CheckScopeChain([debug.ScopeType.Local, | 613 CheckScopeChain([debug.ScopeType.Local, |
| 599 debug.ScopeType.Closure, | 614 debug.ScopeType.Closure, |
| 600 debug.ScopeType.Script, | 615 debug.ScopeType.Script, |
| 601 debug.ScopeType.Global], exec_state); | 616 debug.ScopeType.Global], exec_state); |
| 602 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); | 617 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); |
| 618 CheckScopeChainNames([undefined, "closure_4", undefined, undefined], exec_stat
e) |
| 603 }; | 619 }; |
| 604 closure_4(1, 2)(); | 620 closure_4(1, 2)(); |
| 605 EndTest(); | 621 EndTest(); |
| 606 | 622 |
| 607 | 623 |
| 608 | 624 |
| 609 // Simple closure formed by returning an inner function referering the outer | 625 // Simple closure formed by returning an inner function referering the outer |
| 610 // functions arguments. In the presence of eval all arguments and locals | 626 // functions arguments. In the presence of eval all arguments and locals |
| 611 // (including the inner function itself) from the outer function becomes part of | 627 // (including the inner function itself) from the outer function becomes part of |
| 612 // the debugger infformation on the closure. | 628 // the debugger infformation on the closure. |
| 613 BeginTest("Closure 5"); | 629 BeginTest("Closure 5"); |
| 614 | 630 |
| 615 function closure_5(a, b) { | 631 function closure_5(a, b) { |
| 616 var x = 3; | 632 var x = 3; |
| 617 var y = 4; | 633 var y = 4; |
| 618 function f() { | 634 function f() { |
| 619 eval(''); | 635 eval(''); |
| 620 debugger; | 636 debugger; |
| 621 return 1; | 637 return 1; |
| 622 }; | 638 }; |
| 623 return f; | 639 return f; |
| 624 } | 640 } |
| 625 | 641 |
| 626 listener_delegate = function(exec_state) { | 642 listener_delegate = function(exec_state) { |
| 627 CheckScopeChain([debug.ScopeType.Local, | 643 CheckScopeChain([debug.ScopeType.Local, |
| 628 debug.ScopeType.Closure, | 644 debug.ScopeType.Closure, |
| 629 debug.ScopeType.Script, | 645 debug.ScopeType.Script, |
| 630 debug.ScopeType.Global], exec_state); | 646 debug.ScopeType.Global], exec_state); |
| 631 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); | 647 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); |
| 648 CheckScopeChainNames(["f", "closure_5", undefined, undefined], exec_state) |
| 632 }; | 649 }; |
| 633 closure_5(1, 2)(); | 650 closure_5(1, 2)(); |
| 634 EndTest(); | 651 EndTest(); |
| 635 | 652 |
| 636 | 653 |
| 637 // Two closures. Due to optimizations only the parts actually used are provided | 654 // Two closures. Due to optimizations only the parts actually used are provided |
| 638 // through the debugger information. | 655 // through the debugger information. |
| 639 BeginTest("Closure 6"); | 656 BeginTest("Closure 6"); |
| 640 function closure_6(a, b) { | 657 function closure_6(a, b) { |
| 641 function f(a, b) { | 658 function f(a, b) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 653 } | 670 } |
| 654 | 671 |
| 655 listener_delegate = function(exec_state) { | 672 listener_delegate = function(exec_state) { |
| 656 CheckScopeChain([debug.ScopeType.Local, | 673 CheckScopeChain([debug.ScopeType.Local, |
| 657 debug.ScopeType.Closure, | 674 debug.ScopeType.Closure, |
| 658 debug.ScopeType.Closure, | 675 debug.ScopeType.Closure, |
| 659 debug.ScopeType.Script, | 676 debug.ScopeType.Script, |
| 660 debug.ScopeType.Global], exec_state); | 677 debug.ScopeType.Global], exec_state); |
| 661 CheckScopeContent({a:1}, 1, exec_state); | 678 CheckScopeContent({a:1}, 1, exec_state); |
| 662 CheckScopeContent({f:function(){}}, 2, exec_state); | 679 CheckScopeContent({f:function(){}}, 2, exec_state); |
| 680 CheckScopeChainNames([undefined, "f", "closure_6", undefined, undefined], exec
_state) |
| 663 }; | 681 }; |
| 664 closure_6(1, 2)(); | 682 closure_6(1, 2)(); |
| 665 EndTest(); | 683 EndTest(); |
| 666 | 684 |
| 667 | 685 |
| 668 // Two closures. In the presence of eval all information is provided as the | 686 // Two closures. In the presence of eval all information is provided as the |
| 669 // compiler cannot determine which parts are used. | 687 // compiler cannot determine which parts are used. |
| 670 BeginTest("Closure 7"); | 688 BeginTest("Closure 7"); |
| 671 function closure_7(a, b) { | 689 function closure_7(a, b) { |
| 672 var x = 3; | 690 var x = 3; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 689 | 707 |
| 690 listener_delegate = function(exec_state) { | 708 listener_delegate = function(exec_state) { |
| 691 CheckScopeChain([debug.ScopeType.Local, | 709 CheckScopeChain([debug.ScopeType.Local, |
| 692 debug.ScopeType.Closure, | 710 debug.ScopeType.Closure, |
| 693 debug.ScopeType.Closure, | 711 debug.ScopeType.Closure, |
| 694 debug.ScopeType.Script, | 712 debug.ScopeType.Script, |
| 695 debug.ScopeType.Global], exec_state); | 713 debug.ScopeType.Global], exec_state); |
| 696 CheckScopeContent({}, 0, exec_state); | 714 CheckScopeContent({}, 0, exec_state); |
| 697 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state); | 715 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state); |
| 698 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 2, exec_state); | 716 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 2, exec_state); |
| 717 CheckScopeChainNames([undefined, "f", "closure_7", undefined, undefined], exec
_state) |
| 699 }; | 718 }; |
| 700 closure_7(1, 2)(); | 719 closure_7(1, 2)(); |
| 701 EndTest(); | 720 EndTest(); |
| 702 | 721 |
| 703 | 722 |
| 704 // Closure that may be optimized out. | 723 // Closure that may be optimized out. |
| 705 BeginTest("Closure 8"); | 724 BeginTest("Closure 8"); |
| 706 function closure_8() { | 725 function closure_8() { |
| 707 (function inner(x) { | 726 (function inner(x) { |
| 708 debugger; | 727 debugger; |
| 709 })(2); | 728 })(2); |
| 710 } | 729 } |
| 711 | 730 |
| 712 listener_delegate = function(exec_state) { | 731 listener_delegate = function(exec_state) { |
| 713 CheckScopeChain([debug.ScopeType.Local, | 732 CheckScopeChain([debug.ScopeType.Local, |
| 714 debug.ScopeType.Script, | 733 debug.ScopeType.Script, |
| 715 debug.ScopeType.Global], exec_state); | 734 debug.ScopeType.Global], exec_state); |
| 716 CheckScopeContent({x: 2}, 0, exec_state); | 735 CheckScopeContent({x: 2}, 0, exec_state); |
| 736 CheckScopeChainNames([undefined, undefined, undefined], exec_state) |
| 717 }; | 737 }; |
| 718 closure_8(); | 738 closure_8(); |
| 719 EndTest(); | 739 EndTest(); |
| 720 | 740 |
| 721 | 741 |
| 722 BeginTest("Closure 9"); | 742 BeginTest("Closure 9"); |
| 723 function closure_9() { | 743 function closure_9() { |
| 724 eval("var y = 1;"); | 744 eval("var y = 1;"); |
| 725 eval("var z = 1;"); | 745 eval("var z = 1;"); |
| 726 (function inner(x) { | 746 (function inner(x) { |
| 727 y++; | 747 y++; |
| 728 z++; | 748 z++; |
| 729 debugger; | 749 debugger; |
| 730 })(2); | 750 })(2); |
| 731 } | 751 } |
| 732 | 752 |
| 733 listener_delegate = function(exec_state) { | 753 listener_delegate = function(exec_state) { |
| 734 CheckScopeChain([debug.ScopeType.Local, | 754 CheckScopeChain([debug.ScopeType.Local, |
| 735 debug.ScopeType.Closure, | 755 debug.ScopeType.Closure, |
| 736 debug.ScopeType.Script, | 756 debug.ScopeType.Script, |
| 737 debug.ScopeType.Global], exec_state); | 757 debug.ScopeType.Global], exec_state); |
| 758 CheckScopeChainNames([undefined, "closure_9", undefined, undefined], exec_stat
e) |
| 738 }; | 759 }; |
| 739 closure_9(); | 760 closure_9(); |
| 740 EndTest(); | 761 EndTest(); |
| 741 | 762 |
| 742 | 763 |
| 743 // Test a mixture of scopes. | 764 // Test a mixture of scopes. |
| 744 BeginTest("The full monty"); | 765 BeginTest("The full monty"); |
| 745 function the_full_monty(a, b) { | 766 function the_full_monty(a, b) { |
| 746 var x = 3; | 767 var x = 3; |
| 747 var y = 4; | 768 var y = 4; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 776 debug.ScopeType.Closure, | 797 debug.ScopeType.Closure, |
| 777 debug.ScopeType.Closure, | 798 debug.ScopeType.Closure, |
| 778 debug.ScopeType.Script, | 799 debug.ScopeType.Script, |
| 779 debug.ScopeType.Global], exec_state); | 800 debug.ScopeType.Global], exec_state); |
| 780 CheckScopeContent({b:16}, 0, exec_state); | 801 CheckScopeContent({b:16}, 0, exec_state); |
| 781 CheckScopeContent({a:15}, 1, exec_state); | 802 CheckScopeContent({a:15}, 1, exec_state); |
| 782 CheckScopeContent({x:14}, 2, exec_state); | 803 CheckScopeContent({x:14}, 2, exec_state); |
| 783 CheckScopeContent({j:13}, 3, exec_state); | 804 CheckScopeContent({j:13}, 3, exec_state); |
| 784 CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state); | 805 CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state); |
| 785 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, exec_state); | 806 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, exec_state); |
| 807 CheckScopeChainNames([undefined, undefined, undefined, "f", "f", "the_full_mon
ty", undefined, undefined], exec_state) |
| 786 }; | 808 }; |
| 787 the_full_monty(1, 2)(); | 809 the_full_monty(1, 2)(); |
| 788 EndTest(); | 810 EndTest(); |
| 789 | 811 |
| 790 | 812 |
| 791 BeginTest("Closure inside With 1"); | 813 BeginTest("Closure inside With 1"); |
| 792 function closure_in_with_1() { | 814 function closure_in_with_1() { |
| 793 with({x:1}) { | 815 with({x:1}) { |
| 794 (function inner(x) { | 816 (function inner(x) { |
| 795 debugger; | 817 debugger; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 823 listener_delegate = function(exec_state) { | 845 listener_delegate = function(exec_state) { |
| 824 CheckScopeChain([debug.ScopeType.With, | 846 CheckScopeChain([debug.ScopeType.With, |
| 825 debug.ScopeType.Local, | 847 debug.ScopeType.Local, |
| 826 debug.ScopeType.With, | 848 debug.ScopeType.With, |
| 827 debug.ScopeType.Closure, | 849 debug.ScopeType.Closure, |
| 828 debug.ScopeType.Script, | 850 debug.ScopeType.Script, |
| 829 debug.ScopeType.Global], exec_state); | 851 debug.ScopeType.Global], exec_state); |
| 830 CheckScopeContent({x: 3}, 0, exec_state); | 852 CheckScopeContent({x: 3}, 0, exec_state); |
| 831 CheckScopeContent({x: 2}, 1, exec_state); | 853 CheckScopeContent({x: 2}, 1, exec_state); |
| 832 CheckScopeContent({x: 1}, 2, exec_state); | 854 CheckScopeContent({x: 1}, 2, exec_state); |
| 855 CheckScopeChainNames(["inner", "inner", "closure_in_with_2", "closure_in_with_
2", undefined, undefined], exec_state) |
| 833 }; | 856 }; |
| 834 closure_in_with_2(); | 857 closure_in_with_2(); |
| 835 EndTest(); | 858 EndTest(); |
| 836 | 859 |
| 837 | 860 |
| 838 BeginTest("Closure inside With 3"); | 861 BeginTest("Closure inside With 3"); |
| 839 function createClosure(a) { | 862 function createClosure(a) { |
| 840 var b = a + 1; | 863 var b = a + 1; |
| 841 return function closure() { | 864 return function closure() { |
| 842 var c = b; | 865 var c = b; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 853 f(); | 876 f(); |
| 854 } | 877 } |
| 855 | 878 |
| 856 listener_delegate = function(exec_state) { | 879 listener_delegate = function(exec_state) { |
| 857 CheckScopeChain([debug.ScopeType.With, | 880 CheckScopeChain([debug.ScopeType.With, |
| 858 debug.ScopeType.Local, | 881 debug.ScopeType.Local, |
| 859 debug.ScopeType.Closure, | 882 debug.ScopeType.Closure, |
| 860 debug.ScopeType.Closure, | 883 debug.ScopeType.Closure, |
| 861 debug.ScopeType.Script, | 884 debug.ScopeType.Script, |
| 862 debug.ScopeType.Global], exec_state); | 885 debug.ScopeType.Global], exec_state); |
| 886 CheckScopeChainNames(["inner", "inner", "closure", "createClosure", undefined,
undefined], exec_state) |
| 863 } | 887 } |
| 864 closure_in_with_3(); | 888 closure_in_with_3(); |
| 865 EndTest(); | 889 EndTest(); |
| 866 | 890 |
| 867 | 891 |
| 868 BeginTest("Closure inside With 4"); | 892 BeginTest("Closure inside With 4"); |
| 869 listener_delegate = function(exec_state) { | 893 listener_delegate = function(exec_state) { |
| 870 CheckScopeChain([debug.ScopeType.Local, | 894 CheckScopeChain([debug.ScopeType.Local, |
| 871 debug.ScopeType.With, | 895 debug.ScopeType.With, |
| 872 debug.ScopeType.Script, | 896 debug.ScopeType.Script, |
| 873 debug.ScopeType.Global], exec_state); | 897 debug.ScopeType.Global], exec_state); |
| 874 CheckScopeContent({x: 2}, 0, exec_state); | 898 CheckScopeContent({x: 2}, 0, exec_state); |
| 875 CheckScopeContent({x: 1}, 1, exec_state); | 899 CheckScopeContent({x: 1}, 1, exec_state); |
| 900 CheckScopeChainNames([undefined, undefined, undefined, undefined], exec_state) |
| 876 }; | 901 }; |
| 877 | 902 |
| 878 with({x:1}) { | 903 with({x:1}) { |
| 879 (function(x) { | 904 (function(x) { |
| 880 debugger; | 905 debugger; |
| 881 })(2); | 906 })(2); |
| 882 } | 907 } |
| 883 EndTest(); | 908 EndTest(); |
| 884 | 909 |
| 885 | 910 |
| 886 // Test global scope. | 911 // Test global scope. |
| 887 BeginTest("Global"); | 912 BeginTest("Global"); |
| 888 listener_delegate = function(exec_state) { | 913 listener_delegate = function(exec_state) { |
| 889 CheckScopeChain([debug.ScopeType.Script, debug.ScopeType.Global], exec_state); | 914 CheckScopeChain([debug.ScopeType.Script, debug.ScopeType.Global], exec_state); |
| 915 CheckScopeChainNames([undefined, undefined], exec_state) |
| 890 }; | 916 }; |
| 891 debugger; | 917 debugger; |
| 892 EndTest(); | 918 EndTest(); |
| 893 | 919 |
| 894 | 920 |
| 895 BeginTest("Catch block 1"); | 921 BeginTest("Catch block 1"); |
| 896 function catch_block_1() { | 922 function catch_block_1() { |
| 897 try { | 923 try { |
| 898 throw 'Exception'; | 924 throw 'Exception'; |
| 899 } catch (e) { | 925 } catch (e) { |
| 900 debugger; | 926 debugger; |
| 901 } | 927 } |
| 902 }; | 928 }; |
| 903 | 929 |
| 904 | 930 |
| 905 listener_delegate = function(exec_state) { | 931 listener_delegate = function(exec_state) { |
| 906 CheckScopeChain([debug.ScopeType.Catch, | 932 CheckScopeChain([debug.ScopeType.Catch, |
| 907 debug.ScopeType.Local, | 933 debug.ScopeType.Local, |
| 908 debug.ScopeType.Script, | 934 debug.ScopeType.Script, |
| 909 debug.ScopeType.Global], exec_state); | 935 debug.ScopeType.Global], exec_state); |
| 910 CheckScopeContent({e:'Exception'}, 0, exec_state); | 936 CheckScopeContent({e:'Exception'}, 0, exec_state); |
| 937 CheckScopeChainNames(["catch_block_1", undefined, undefined, undefined], exec_
state) |
| 911 }; | 938 }; |
| 912 catch_block_1(); | 939 catch_block_1(); |
| 913 EndTest(); | 940 EndTest(); |
| 914 | 941 |
| 915 | 942 |
| 916 BeginTest("Catch block 2"); | 943 BeginTest("Catch block 2"); |
| 917 function catch_block_2() { | 944 function catch_block_2() { |
| 918 try { | 945 try { |
| 919 throw 'Exception'; | 946 throw 'Exception'; |
| 920 } catch (e) { | 947 } catch (e) { |
| 921 with({n:10}) { | 948 with({n:10}) { |
| 922 debugger; | 949 debugger; |
| 923 } | 950 } |
| 924 } | 951 } |
| 925 }; | 952 }; |
| 926 | 953 |
| 927 | 954 |
| 928 listener_delegate = function(exec_state) { | 955 listener_delegate = function(exec_state) { |
| 929 CheckScopeChain([debug.ScopeType.With, | 956 CheckScopeChain([debug.ScopeType.With, |
| 930 debug.ScopeType.Catch, | 957 debug.ScopeType.Catch, |
| 931 debug.ScopeType.Local, | 958 debug.ScopeType.Local, |
| 932 debug.ScopeType.Script, | 959 debug.ScopeType.Script, |
| 933 debug.ScopeType.Global], exec_state); | 960 debug.ScopeType.Global], exec_state); |
| 934 CheckScopeContent({n:10}, 0, exec_state); | 961 CheckScopeContent({n:10}, 0, exec_state); |
| 935 CheckScopeContent({e:'Exception'}, 1, exec_state); | 962 CheckScopeContent({e:'Exception'}, 1, exec_state); |
| 963 CheckScopeChainNames(["catch_block_2", "catch_block_2", "catch_block_2", undef
ined, undefined], exec_state) |
| 936 }; | 964 }; |
| 937 catch_block_2(); | 965 catch_block_2(); |
| 938 EndTest(); | 966 EndTest(); |
| 939 | 967 |
| 940 | 968 |
| 941 BeginTest("Catch block 3"); | 969 BeginTest("Catch block 3"); |
| 942 function catch_block_3() { | 970 function catch_block_3() { |
| 943 // Do eval to dynamically declare a local variable so that the context's | 971 // Do eval to dynamically declare a local variable so that the context's |
| 944 // extension slot is initialized with JSContextExtensionObject. | 972 // extension slot is initialized with JSContextExtensionObject. |
| 945 eval("var y = 78;"); | 973 eval("var y = 78;"); |
| 946 try { | 974 try { |
| 947 throw 'Exception'; | 975 throw 'Exception'; |
| 948 } catch (e) { | 976 } catch (e) { |
| 949 debugger; | 977 debugger; |
| 950 } | 978 } |
| 951 }; | 979 }; |
| 952 | 980 |
| 953 | 981 |
| 954 listener_delegate = function(exec_state) { | 982 listener_delegate = function(exec_state) { |
| 955 CheckScopeChain([debug.ScopeType.Catch, | 983 CheckScopeChain([debug.ScopeType.Catch, |
| 956 debug.ScopeType.Local, | 984 debug.ScopeType.Local, |
| 957 debug.ScopeType.Script, | 985 debug.ScopeType.Script, |
| 958 debug.ScopeType.Global], exec_state); | 986 debug.ScopeType.Global], exec_state); |
| 959 CheckScopeContent({e:'Exception'}, 0, exec_state); | 987 CheckScopeContent({e:'Exception'}, 0, exec_state); |
| 960 CheckScopeContent({y:78}, 1, exec_state); | 988 CheckScopeContent({y:78}, 1, exec_state); |
| 989 CheckScopeChainNames(["catch_block_3", "catch_block_3", undefined, undefined],
exec_state) |
| 961 }; | 990 }; |
| 962 catch_block_3(); | 991 catch_block_3(); |
| 963 EndTest(); | 992 EndTest(); |
| 964 | 993 |
| 965 | 994 |
| 966 BeginTest("Catch block 4"); | 995 BeginTest("Catch block 4"); |
| 967 function catch_block_4() { | 996 function catch_block_4() { |
| 968 // Do eval to dynamically declare a local variable so that the context's | 997 // Do eval to dynamically declare a local variable so that the context's |
| 969 // extension slot is initialized with JSContextExtensionObject. | 998 // extension slot is initialized with JSContextExtensionObject. |
| 970 eval("var y = 98;"); | 999 eval("var y = 98;"); |
| 971 try { | 1000 try { |
| 972 throw 'Exception'; | 1001 throw 'Exception'; |
| 973 } catch (e) { | 1002 } catch (e) { |
| 974 with({n:10}) { | 1003 with({n:10}) { |
| 975 debugger; | 1004 debugger; |
| 976 } | 1005 } |
| 977 } | 1006 } |
| 978 }; | 1007 }; |
| 979 | 1008 |
| 980 listener_delegate = function(exec_state) { | 1009 listener_delegate = function(exec_state) { |
| 981 CheckScopeChain([debug.ScopeType.With, | 1010 CheckScopeChain([debug.ScopeType.With, |
| 982 debug.ScopeType.Catch, | 1011 debug.ScopeType.Catch, |
| 983 debug.ScopeType.Local, | 1012 debug.ScopeType.Local, |
| 984 debug.ScopeType.Script, | 1013 debug.ScopeType.Script, |
| 985 debug.ScopeType.Global], exec_state); | 1014 debug.ScopeType.Global], exec_state); |
| 986 CheckScopeContent({n:10}, 0, exec_state); | 1015 CheckScopeContent({n:10}, 0, exec_state); |
| 987 CheckScopeContent({e:'Exception'}, 1, exec_state); | 1016 CheckScopeContent({e:'Exception'}, 1, exec_state); |
| 988 CheckScopeContent({y:98}, 2, exec_state); | 1017 CheckScopeContent({y:98}, 2, exec_state); |
| 1018 CheckScopeChainNames(["catch_block_4", "catch_block_4", "catch_block_4", undef
ined, undefined], exec_state) |
| 989 }; | 1019 }; |
| 990 catch_block_4(); | 1020 catch_block_4(); |
| 991 EndTest(); | 1021 EndTest(); |
| 992 | 1022 |
| 993 | 1023 |
| 994 // Test catch in global scope. | 1024 // Test catch in global scope. |
| 995 BeginTest("Catch block 5"); | 1025 BeginTest("Catch block 5"); |
| 996 listener_delegate = function(exec_state) { | 1026 listener_delegate = function(exec_state) { |
| 997 CheckScopeChain([debug.ScopeType.Catch, | 1027 CheckScopeChain([debug.ScopeType.Catch, |
| 998 debug.ScopeType.Script, | 1028 debug.ScopeType.Script, |
| 999 debug.ScopeType.Global], exec_state); | 1029 debug.ScopeType.Global], exec_state); |
| 1000 CheckScopeContent({e:'Exception'}, 0, exec_state); | 1030 CheckScopeContent({e:'Exception'}, 0, exec_state); |
| 1031 CheckScopeChainNames([undefined, undefined, undefined], exec_state) |
| 1001 }; | 1032 }; |
| 1002 | 1033 |
| 1003 try { | 1034 try { |
| 1004 throw 'Exception'; | 1035 throw 'Exception'; |
| 1005 } catch (e) { | 1036 } catch (e) { |
| 1006 debugger; | 1037 debugger; |
| 1007 } | 1038 } |
| 1008 | 1039 |
| 1009 EndTest(); | 1040 EndTest(); |
| 1010 | 1041 |
| 1011 | 1042 |
| 1012 // Closure inside catch in global code. | 1043 // Closure inside catch in global code. |
| 1013 BeginTest("Catch block 6"); | 1044 BeginTest("Catch block 6"); |
| 1014 listener_delegate = function(exec_state) { | 1045 listener_delegate = function(exec_state) { |
| 1015 CheckScopeChain([debug.ScopeType.Local, | 1046 CheckScopeChain([debug.ScopeType.Local, |
| 1016 debug.ScopeType.Catch, | 1047 debug.ScopeType.Catch, |
| 1017 debug.ScopeType.Script, | 1048 debug.ScopeType.Script, |
| 1018 debug.ScopeType.Global], exec_state); | 1049 debug.ScopeType.Global], exec_state); |
| 1019 CheckScopeContent({x: 2}, 0, exec_state); | 1050 CheckScopeContent({x: 2}, 0, exec_state); |
| 1020 CheckScopeContent({e:'Exception'}, 1, exec_state); | 1051 CheckScopeContent({e:'Exception'}, 1, exec_state); |
| 1052 CheckScopeChainNames([undefined, undefined, undefined, undefined], exec_state) |
| 1021 }; | 1053 }; |
| 1022 | 1054 |
| 1023 try { | 1055 try { |
| 1024 throw 'Exception'; | 1056 throw 'Exception'; |
| 1025 } catch (e) { | 1057 } catch (e) { |
| 1026 (function(x) { | 1058 (function(x) { |
| 1027 debugger; | 1059 debugger; |
| 1028 })(2); | 1060 })(2); |
| 1029 } | 1061 } |
| 1030 EndTest(); | 1062 EndTest(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1041 } | 1073 } |
| 1042 }; | 1074 }; |
| 1043 | 1075 |
| 1044 | 1076 |
| 1045 listener_delegate = function(exec_state) { | 1077 listener_delegate = function(exec_state) { |
| 1046 CheckScopeChain([debug.ScopeType.Catch, | 1078 CheckScopeChain([debug.ScopeType.Catch, |
| 1047 debug.ScopeType.Local, | 1079 debug.ScopeType.Local, |
| 1048 debug.ScopeType.Script, | 1080 debug.ScopeType.Script, |
| 1049 debug.ScopeType.Global], exec_state); | 1081 debug.ScopeType.Global], exec_state); |
| 1050 CheckScopeContent({e:'Exception'}, 0, exec_state); | 1082 CheckScopeContent({e:'Exception'}, 0, exec_state); |
| 1083 CheckScopeChainNames(["catch_block_7", undefined, undefined, undefined], exec_
state) |
| 1051 }; | 1084 }; |
| 1052 catch_block_7(); | 1085 catch_block_7(); |
| 1053 EndTest(); | 1086 EndTest(); |
| 1054 | 1087 |
| 1055 | 1088 |
| 1056 BeginTest("Classes and methods 1"); | 1089 BeginTest("Classes and methods 1"); |
| 1057 | 1090 |
| 1058 listener_delegate = function(exec_state) { | 1091 listener_delegate = function(exec_state) { |
| 1059 "use strict" | 1092 "use strict" |
| 1060 CheckScopeChain([debug.ScopeType.Local, | 1093 CheckScopeChain([debug.ScopeType.Local, |
| 1061 debug.ScopeType.Script, | 1094 debug.ScopeType.Script, |
| 1062 debug.ScopeType.Global], exec_state); | 1095 debug.ScopeType.Global], exec_state); |
| 1063 CheckScopeContent({}, 1, exec_state); | 1096 CheckScopeContent({}, 1, exec_state); |
| 1097 CheckScopeChainNames([undefined, undefined, undefined], exec_state) |
| 1064 }; | 1098 }; |
| 1065 | 1099 |
| 1066 (function() { | 1100 (function() { |
| 1067 "use strict"; | 1101 "use strict"; |
| 1068 class C1 { | 1102 class C1 { |
| 1069 m() { | 1103 m() { |
| 1070 debugger; | 1104 debugger; |
| 1071 } | 1105 } |
| 1072 } | 1106 } |
| 1073 new C1().m(); | 1107 new C1().m(); |
| 1074 })(); | 1108 })(); |
| 1075 | 1109 |
| 1076 EndTest(); | 1110 EndTest(); |
| 1077 | 1111 |
| 1078 | 1112 |
| 1079 assertEquals(begin_test_count, break_count, | 1113 assertEquals(begin_test_count, break_count, |
| 1080 'one or more tests did not enter the debugger'); | 1114 'one or more tests did not enter the debugger'); |
| 1081 assertEquals(begin_test_count, end_test_count, | 1115 assertEquals(begin_test_count, end_test_count, |
| 1082 'one or more tests did not have its result checked'); | 1116 'one or more tests did not have its result checked'); |
| OLD | NEW |