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