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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // Do steps until we reach the global scope again. | 46 // Do steps until we reach the global scope again. |
47 if (true) { | 47 if (true) { |
48 exec_state.prepareStep(Debug.StepAction.StepInMin, 1); | 48 exec_state.prepareStep(Debug.StepAction.StepInMin, 1); |
49 } | 49 } |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 Debug.setListener(listener); | 53 Debug.setListener(listener); |
54 | 54 |
55 | 55 |
56 function test1() { | |
57 debugger; | |
58 with ({x:1}) { | |
59 x = 2; | |
60 } | |
61 } | |
62 test1(); | |
63 | |
64 | |
65 function test2() { | |
66 if (true) { | |
67 with ({}) { | |
68 debugger; | |
69 } | |
70 } else { | |
71 with ({}) { | |
72 return 10; | |
73 } | |
74 } | |
75 } | |
76 test2(); | |
77 | |
78 | |
79 function test3() { | |
80 if (true) { | |
81 debugger; | |
82 } else { | |
83 with ({}) { | |
84 return 10; | |
85 } | |
86 } | |
87 } | |
88 test3(); | |
89 | |
90 | |
91 function test4() { | |
92 debugger; | |
93 with ({x:1}) x = 1 | |
94 } | |
95 test4(); | |
96 | |
97 | |
98 function test5() { | |
99 debugger; | |
100 var dummy = 1; | |
101 with ({}) { | |
102 with ({}) { | |
103 dummy = 2; | |
104 } | |
105 } | |
106 dummy = 3; | |
107 } | |
108 test5(); | |
109 | |
110 | |
111 function test6() { | |
112 debugger; | |
113 try { | |
114 throw 'stuff'; | |
115 } catch (e) { | |
116 e = 1; | |
117 } | |
118 } | |
119 test6(); | |
120 | |
121 | |
122 function test7() { | |
123 debugger; | |
124 function foo() {} | |
125 } | |
126 test7(); | |
127 | |
128 | |
129 function test8() { | |
130 debugger; | |
131 (function foo() {})(); | |
132 } | |
133 test8(); | |
134 | |
135 | |
136 var q = 42; | |
137 var prefixes = [ "debugger; ", | |
138 "if (false) { try { throw 0; } catch(x) { return x; } }; debugg
er; " ]; | |
139 var bodies = [ "1", | |
140 "1 ", | |
141 "1;", | |
142 "1; ", | |
143 "q", | |
144 "q ", | |
145 "q;", | |
146 "q; ", | |
147 "try { throw 'stuff' } catch (e) { e = 1; }", | |
148 "try { throw 'stuff' } catch (e) { e = 1; } ", | |
149 "try { throw 'stuff' } catch (e) { e = 1; };", | |
150 "try { throw 'stuff' } catch (e) { e = 1; }; " ]; | |
151 var with_bodies = [ "with ({}) {}", | |
152 "with ({x:1}) x", | |
153 "with ({x:1}) x = 1", | |
154 "with ({x:1}) x ", | |
155 "with ({x:1}) x = 1 ", | |
156 "with ({x:1}) x;", | |
157 "with ({x:1}) x = 1;", | |
158 "with ({x:1}) x; ", | |
159 "with ({x:1}) x = 1; " ]; | |
160 | |
161 | |
162 function test9() { | |
163 debugger; | |
164 for (var i = 0; i < prefixes.length; ++i) { | |
165 var pre = prefixes[i]; | |
166 for (var j = 0; j < bodies.length; ++j) { | |
167 var body = bodies[j]; | |
168 eval(pre + body); | |
169 eval("'use strict'; " + pre + body); | |
170 } | |
171 for (var j = 0; j < with_bodies.length; ++j) { | |
172 var body = with_bodies[j]; | |
173 eval(pre + body); | |
174 } | |
175 } | |
176 } | |
177 test9(); | |
178 | |
179 | |
180 function test10() { | |
181 debugger; | |
182 with ({}) { | |
183 return 10; | |
184 } | |
185 } | |
186 test10(); | |
187 | |
188 | |
189 function test11() { | |
190 debugger; | |
191 try { | |
192 throw 'stuff'; | |
193 } catch (e) { | |
194 return 10; | |
195 } | |
196 } | |
197 test11(); | |
198 | |
199 | |
200 // Test global eval and function constructor. | |
201 for (var i = 0; i < prefixes.length; ++i) { | |
202 var pre = prefixes[i]; | |
203 for (var j = 0; j < bodies.length; ++j) { | |
204 var body = bodies[j]; | |
205 eval(pre + body); | |
206 eval("'use strict'; " + pre + body); | |
207 Function(pre + body)(); | |
208 } | |
209 for (var j = 0; j < with_bodies.length; ++j) { | |
210 var body = with_bodies[j]; | |
211 eval(pre + body); | |
212 Function(pre + body)(); | |
213 } | |
214 } | |
215 | |
216 | |
217 try { | |
218 with({}) { | |
219 debugger; | |
220 eval("{}$%:^"); | |
221 } | |
222 } catch(e) { | |
223 nop(); | |
224 } | |
225 | |
226 // Return from function constructed with Function constructor. | |
227 var anon = 12; | |
228 for (var i = 0; i < prefixes.length; ++i) { | |
229 var pre = prefixes[i]; | |
230 Function(pre + "return 42")(); | |
231 Function(pre + "return 42 ")(); | |
232 Function(pre + "return 42;")(); | |
233 Function(pre + "return 42; ")(); | |
234 Function(pre + "return anon")(); | |
235 Function(pre + "return anon ")(); | |
236 Function(pre + "return anon;")(); | |
237 Function(pre + "return anon; ")(); | |
238 } | |
239 | |
240 | |
241 function nop() {} | 56 function nop() {} |
242 | 57 |
243 | 58 |
244 function stress() { | 59 function stress() { |
245 debugger; | 60 debugger; |
246 | 61 |
247 L: with ({x:12}) { | 62 L: with ({x:12}) { |
248 break L; | 63 break L; |
249 } | 64 } |
250 | 65 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 } catch (e) { | 225 } catch (e) { |
411 with ({x: 'inner'}) { | 226 with ({x: 'inner'}) { |
412 return e; | 227 return e; |
413 } | 228 } |
414 } | 229 } |
415 } | 230 } |
416 stress4(); | 231 stress4(); |
417 | 232 |
418 } | 233 } |
419 stress(); | 234 stress(); |
420 | |
421 | |
422 // With block as the last(!) statement in global code. | |
423 with ({}) { debugger; } | |
OLD | NEW |