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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 } | 145 } |
146 | 146 |
147 | 147 |
148 // Check that the scope chain contains the expected names of scopes. | 148 // Check that the scope chain contains the expected names of scopes. |
149 function CheckScopeChainNames(names, exec_state) { | 149 function CheckScopeChainNames(names, exec_state) { |
150 var all_scopes = exec_state.frame().allScopes(); | 150 var all_scopes = exec_state.frame().allScopes(); |
151 assertEquals(names.length, all_scopes.length, "FrameMirror.allScopes length"); | 151 assertEquals(names.length, all_scopes.length, "FrameMirror.allScopes length"); |
152 for (var i = 0; i < names.length; i++) { | 152 for (var i = 0; i < names.length; i++) { |
153 var scope = exec_state.frame().scope(i); | 153 var scope = exec_state.frame().scope(i); |
154 assertTrue(scope.isScope()); | 154 assertTrue(scope.isScope()); |
155 assertEquals(scope.details().name(), names[i]) | 155 assertEquals(names[i], scope.details().name()) |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 | 159 |
160 // 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 |
161 // that there is a function. | 161 // that there is a function. |
162 function CheckScopeContent(content, number, exec_state) { | 162 function CheckScopeContent(content, number, exec_state) { |
163 var scope = exec_state.frame().scope(number); | 163 var scope = exec_state.frame().scope(number); |
164 var count = 0; | 164 var count = 0; |
165 for (var p in content) { | 165 for (var p in content) { |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
830 with({x:1}) { | 830 with({x:1}) { |
831 (function inner(x) { | 831 (function inner(x) { |
832 debugger; | 832 debugger; |
833 })(2); | 833 })(2); |
834 } | 834 } |
835 } | 835 } |
836 | 836 |
837 listener_delegate = function(exec_state) { | 837 listener_delegate = function(exec_state) { |
838 CheckScopeChain([debug.ScopeType.Local, | 838 CheckScopeChain([debug.ScopeType.Local, |
839 debug.ScopeType.With, | 839 debug.ScopeType.With, |
840 debug.ScopeType.Closure, | |
adamk
2016/03/14 22:22:11
My understanding is that we simply don't need this
| |
841 debug.ScopeType.Script, | 840 debug.ScopeType.Script, |
842 debug.ScopeType.Global], exec_state); | 841 debug.ScopeType.Global], exec_state); |
843 CheckScopeContent({x: 2}, 0, exec_state); | 842 CheckScopeContent({x: 2}, 0, exec_state); |
843 CheckScopeContent({x: 1}, 1, exec_state); | |
844 }; | 844 }; |
845 closure_in_with_1(); | 845 closure_in_with_1(); |
846 EndTest(); | 846 EndTest(); |
847 | 847 |
848 | 848 |
849 BeginTest("Closure inside With 2"); | 849 BeginTest("Closure inside With 2"); |
850 function closure_in_with_2() { | 850 function closure_in_with_2() { |
851 with({x:1}) { | 851 with({x:1}) { |
852 (function inner(x) { | 852 (function inner(x) { |
853 with({x:3}) { | 853 with({x:3}) { |
854 debugger; | 854 debugger; |
855 } | 855 } |
856 })(2); | 856 })(2); |
857 } | 857 } |
858 } | 858 } |
859 | 859 |
860 listener_delegate = function(exec_state) { | 860 listener_delegate = function(exec_state) { |
861 CheckScopeChain([debug.ScopeType.With, | 861 CheckScopeChain([debug.ScopeType.With, |
862 debug.ScopeType.Local, | 862 debug.ScopeType.Local, |
863 debug.ScopeType.With, | 863 debug.ScopeType.With, |
864 debug.ScopeType.Closure, | |
adamk
2016/03/14 22:22:11
Same here.
| |
865 debug.ScopeType.Script, | 864 debug.ScopeType.Script, |
866 debug.ScopeType.Global], exec_state); | 865 debug.ScopeType.Global], exec_state); |
867 CheckScopeContent({x: 3}, 0, exec_state); | 866 CheckScopeContent({x: 3}, 0, exec_state); |
868 CheckScopeContent({x: 2}, 1, exec_state); | 867 CheckScopeContent({x: 2}, 1, exec_state); |
869 CheckScopeContent({x: 1}, 2, exec_state); | 868 CheckScopeContent({x: 1}, 2, exec_state); |
870 CheckScopeChainNames(["inner", "inner", "closure_in_with_2", "closure_in_with_ 2", undefined, undefined], exec_state) | 869 CheckScopeChainNames(["inner", undefined, "closure_in_with_2", undefined, unde fined], exec_state) |
adamk
2016/03/14 22:22:11
This is the main bit I don't understand: why did w
Yang
2016/03/15 06:53:48
This seems to be a bug.
In ScopeIterator::Materia
adamk
2016/03/15 17:45:46
Thanks for the pointer, just moving the code down
| |
871 }; | 870 }; |
872 closure_in_with_2(); | 871 closure_in_with_2(); |
873 EndTest(); | 872 EndTest(); |
874 | 873 |
875 | 874 |
876 BeginTest("Closure inside With 3"); | 875 BeginTest("Closure inside With 3"); |
877 function createClosure(a) { | 876 function createClosure(a) { |
878 var b = a + 1; | 877 var b = a + 1; |
879 return function closure() { | 878 return function closure() { |
880 var c = b; | 879 var c = b; |
(...skipping 10 matching lines...) Expand all Loading... | |
891 f(); | 890 f(); |
892 } | 891 } |
893 | 892 |
894 listener_delegate = function(exec_state) { | 893 listener_delegate = function(exec_state) { |
895 CheckScopeChain([debug.ScopeType.With, | 894 CheckScopeChain([debug.ScopeType.With, |
896 debug.ScopeType.Local, | 895 debug.ScopeType.Local, |
897 debug.ScopeType.Closure, | 896 debug.ScopeType.Closure, |
898 debug.ScopeType.Closure, | 897 debug.ScopeType.Closure, |
899 debug.ScopeType.Script, | 898 debug.ScopeType.Script, |
900 debug.ScopeType.Global], exec_state); | 899 debug.ScopeType.Global], exec_state); |
901 CheckScopeChainNames(["inner", "inner", "closure", "createClosure", undefined, undefined], exec_state) | 900 CheckScopeChainNames(["inner", undefined, "closure", "createClosure", undefine d, undefined], exec_state) |
902 } | 901 } |
903 closure_in_with_3(); | 902 closure_in_with_3(); |
904 EndTest(); | 903 EndTest(); |
905 | 904 |
906 | 905 |
907 BeginTest("Closure inside With 4"); | 906 BeginTest("Closure inside With 4"); |
908 listener_delegate = function(exec_state) { | 907 listener_delegate = function(exec_state) { |
909 CheckScopeChain([debug.ScopeType.Local, | 908 CheckScopeChain([debug.ScopeType.Local, |
910 debug.ScopeType.With, | 909 debug.ScopeType.With, |
911 debug.ScopeType.Script, | 910 debug.ScopeType.Script, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
968 | 967 |
969 | 968 |
970 listener_delegate = function(exec_state) { | 969 listener_delegate = function(exec_state) { |
971 CheckScopeChain([debug.ScopeType.With, | 970 CheckScopeChain([debug.ScopeType.With, |
972 debug.ScopeType.Catch, | 971 debug.ScopeType.Catch, |
973 debug.ScopeType.Local, | 972 debug.ScopeType.Local, |
974 debug.ScopeType.Script, | 973 debug.ScopeType.Script, |
975 debug.ScopeType.Global], exec_state); | 974 debug.ScopeType.Global], exec_state); |
976 CheckScopeContent({n:10}, 0, exec_state); | 975 CheckScopeContent({n:10}, 0, exec_state); |
977 CheckScopeContent({e:'Exception'}, 1, exec_state); | 976 CheckScopeContent({e:'Exception'}, 1, exec_state); |
978 CheckScopeChainNames(["catch_block_2", "catch_block_2", "catch_block_2", undef ined, undefined], exec_state) | 977 CheckScopeChainNames(["catch_block_2", "catch_block_2", undefined, undefined, undefined], exec_state) |
979 }; | 978 }; |
980 catch_block_2(); | 979 catch_block_2(); |
981 EndTest(); | 980 EndTest(); |
982 | 981 |
983 | 982 |
984 BeginTest("Catch block 3"); | 983 BeginTest("Catch block 3"); |
985 function catch_block_3() { | 984 function catch_block_3() { |
986 // Do eval to dynamically declare a local variable so that the context's | 985 // Do eval to dynamically declare a local variable so that the context's |
987 // extension slot is initialized with JSContextExtensionObject. | 986 // extension slot is initialized with JSContextExtensionObject. |
988 eval("var y = 78;"); | 987 eval("var y = 78;"); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1186 debug.ScopeType.Global], exec_state); | 1185 debug.ScopeType.Global], exec_state); |
1187 CheckScopeChainPositions([{start: 52, end: 111}, {start: 42, end: 111}, {start : 22, end: 145}, {}, {}], exec_state); | 1186 CheckScopeChainPositions([{start: 52, end: 111}, {start: 42, end: 111}, {start : 22, end: 145}, {}, {}], exec_state); |
1188 } | 1187 } |
1189 eval(code3); | 1188 eval(code3); |
1190 EndTest(); | 1189 EndTest(); |
1191 | 1190 |
1192 assertEquals(begin_test_count, break_count, | 1191 assertEquals(begin_test_count, break_count, |
1193 'one or more tests did not enter the debugger'); | 1192 'one or more tests did not enter the debugger'); |
1194 assertEquals(begin_test_count, end_test_count, | 1193 assertEquals(begin_test_count, end_test_count, |
1195 'one or more tests did not have its result checked'); | 1194 'one or more tests did not have its result checked'); |
OLD | NEW |