OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 debug.ScopeType.Global], exec_state); | 411 debug.ScopeType.Global], exec_state); |
412 CheckScopeContent(with_object, 0, exec_state); | 412 CheckScopeContent(with_object, 0, exec_state); |
413 CheckScopeContent(with_object, 1, exec_state); | 413 CheckScopeContent(with_object, 1, exec_state); |
414 assertEquals(exec_state.frame().scope(0).scopeObject(), exec_state.frame().sco
pe(1).scopeObject()); | 414 assertEquals(exec_state.frame().scope(0).scopeObject(), exec_state.frame().sco
pe(1).scopeObject()); |
415 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); | 415 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); |
416 }; | 416 }; |
417 with_5(); | 417 with_5(); |
418 EndTest(); | 418 EndTest(); |
419 | 419 |
420 | 420 |
| 421 // Nested with blocks using existing object in global code. |
| 422 BeginTest("With 6"); |
| 423 listener_delegate = function(exec_state) { |
| 424 CheckScopeChain([debug.ScopeType.With, |
| 425 debug.ScopeType.With, |
| 426 debug.ScopeType.Global], exec_state); |
| 427 CheckScopeContent(with_object, 0, exec_state); |
| 428 CheckScopeContent(with_object, 1, exec_state); |
| 429 assertEquals(exec_state.frame().scope(0).scopeObject(), exec_state.frame().sco
pe(1).scopeObject()); |
| 430 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); |
| 431 }; |
| 432 |
| 433 var with_object = {c:3,d:4}; |
| 434 with(with_object) { |
| 435 with(with_object) { |
| 436 debugger; |
| 437 } |
| 438 } |
| 439 EndTest(); |
| 440 |
| 441 |
421 // Simple closure formed by returning an inner function referering the outer | 442 // Simple closure formed by returning an inner function referering the outer |
422 // functions arguments. | 443 // functions arguments. |
423 BeginTest("Closure 1"); | 444 BeginTest("Closure 1"); |
424 | 445 |
425 function closure_1(a) { | 446 function closure_1(a) { |
426 function f() { | 447 function f() { |
427 debugger; | 448 debugger; |
428 return a; | 449 return a; |
429 }; | 450 }; |
430 return f; | 451 return f; |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 CheckScopeChain([debug.ScopeType.With, | 785 CheckScopeChain([debug.ScopeType.With, |
765 debug.ScopeType.Local, | 786 debug.ScopeType.Local, |
766 debug.ScopeType.Closure, | 787 debug.ScopeType.Closure, |
767 debug.ScopeType.Closure, | 788 debug.ScopeType.Closure, |
768 debug.ScopeType.Global], exec_state); | 789 debug.ScopeType.Global], exec_state); |
769 } | 790 } |
770 closure_in_with_3(); | 791 closure_in_with_3(); |
771 EndTest(); | 792 EndTest(); |
772 | 793 |
773 | 794 |
| 795 BeginTest("Closure inside With 4"); |
| 796 listener_delegate = function(exec_state) { |
| 797 CheckScopeChain([debug.ScopeType.Local, |
| 798 debug.ScopeType.With, |
| 799 debug.ScopeType.Global], exec_state); |
| 800 CheckScopeContent({x: 2}, 0, exec_state); |
| 801 CheckScopeContent({x: 1}, 1, exec_state); |
| 802 }; |
| 803 |
| 804 with({x:1}) { |
| 805 (function(x) { |
| 806 debugger; |
| 807 })(2); |
| 808 } |
| 809 EndTest(); |
| 810 |
| 811 |
774 // Test global scope. | 812 // Test global scope. |
775 BeginTest("Global"); | 813 BeginTest("Global"); |
776 listener_delegate = function(exec_state) { | 814 listener_delegate = function(exec_state) { |
777 CheckScopeChain([debug.ScopeType.Global], exec_state); | 815 CheckScopeChain([debug.ScopeType.Global], exec_state); |
778 }; | 816 }; |
779 debugger; | 817 debugger; |
780 EndTest(); | 818 EndTest(); |
781 | 819 |
782 | 820 |
783 BeginTest("Catch block 1"); | 821 BeginTest("Catch block 1"); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 debug.ScopeType.Local, | 906 debug.ScopeType.Local, |
869 debug.ScopeType.Global], exec_state); | 907 debug.ScopeType.Global], exec_state); |
870 CheckScopeContent({n:10}, 0, exec_state); | 908 CheckScopeContent({n:10}, 0, exec_state); |
871 CheckScopeContent({e:'Exception'}, 1, exec_state); | 909 CheckScopeContent({e:'Exception'}, 1, exec_state); |
872 CheckScopeContent({y:98}, 2, exec_state); | 910 CheckScopeContent({y:98}, 2, exec_state); |
873 }; | 911 }; |
874 catch_block_4(); | 912 catch_block_4(); |
875 EndTest(); | 913 EndTest(); |
876 | 914 |
877 | 915 |
| 916 // Test catch in global scope. |
| 917 BeginTest("Catch block 5"); |
| 918 listener_delegate = function(exec_state) { |
| 919 CheckScopeChain([debug.ScopeType.Catch, |
| 920 debug.ScopeType.Global], exec_state); |
| 921 CheckScopeContent({e:'Exception'}, 0, exec_state); |
| 922 }; |
| 923 |
| 924 try { |
| 925 throw 'Exception'; |
| 926 } catch (e) { |
| 927 debugger; |
| 928 } |
| 929 |
| 930 EndTest(); |
| 931 |
| 932 |
| 933 // Closure inside catch in global code. |
| 934 BeginTest("Catch block 6"); |
| 935 listener_delegate = function(exec_state) { |
| 936 CheckScopeChain([debug.ScopeType.Local, |
| 937 debug.ScopeType.Catch, |
| 938 debug.ScopeType.Global], exec_state); |
| 939 CheckScopeContent({x: 2}, 0, exec_state); |
| 940 CheckScopeContent({e:'Exception'}, 1, exec_state); |
| 941 }; |
| 942 |
| 943 try { |
| 944 throw 'Exception'; |
| 945 } catch (e) { |
| 946 (function(x) { |
| 947 debugger; |
| 948 })(2); |
| 949 } |
| 950 EndTest(); |
| 951 |
| 952 |
878 assertEquals(begin_test_count, break_count, | 953 assertEquals(begin_test_count, break_count, |
879 'one or more tests did not enter the debugger'); | 954 'one or more tests did not enter the debugger'); |
880 assertEquals(begin_test_count, end_test_count, | 955 assertEquals(begin_test_count, end_test_count, |
881 'one or more tests did not have its result checked'); | 956 'one or more tests did not have its result checked'); |
OLD | NEW |