Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: test/mjsunit/modules-debug-scopes1.js

Issue 2568083002: [inspector] add scope type for modules. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // MODULE
6 // Flags: --expose-debug-as debug --allow-natives-syntax --noanalyze-environment -liveness
7
8 // These tests are copied from mjsunit/debug-scopes.js and adapted for modules.
9
10
11 var Debug = debug.Debug;
12
13 var test_name;
14 var listener_delegate;
15 var listener_called;
16 var exception;
17 var begin_test_count = 0;
18 var end_test_count = 0;
19 var break_count = 0;
20
21
22 // Debug event listener which delegates.
23 function listener(event, exec_state, event_data, data) {
24 try {
25 if (event == Debug.DebugEvent.Break) {
26 break_count++;
27 listener_called = true;
28 listener_delegate(exec_state);
29 }
30 } catch (e) {
31 exception = e;
32 }
33 }
34
35 // Add the debug event listener.
36 Debug.setListener(listener);
37
38
39 // Initialize for a new test.
40 function BeginTest(name) {
41 test_name = name;
42 listener_delegate = null;
43 listener_called = false;
44 exception = null;
45 begin_test_count++;
46 }
47
48
49 // Check result of a test.
50 function EndTest() {
51 assertTrue(listener_called, "listener not called for " + test_name);
52 assertNull(exception, test_name + " / " + exception);
53 end_test_count++;
54 }
55
56
57 // Check that two scope are the same.
58 function assertScopeMirrorEquals(scope1, scope2) {
59 assertEquals(scope1.scopeType(), scope2.scopeType());
60 assertEquals(scope1.frameIndex(), scope2.frameIndex());
61 assertEquals(scope1.scopeIndex(), scope2.scopeIndex());
62 assertPropertiesEqual(scope1.scopeObject().value(),
63 scope2.scopeObject().value());
64 }
65
66 function CheckFastAllScopes(scopes, exec_state)
67 {
68 var fast_all_scopes = exec_state.frame().allScopes(true);
69 var length = fast_all_scopes.length;
70 assertTrue(scopes.length >= length);
71 for (var i = 0; i < scopes.length && i < length; i++) {
72 var scope = fast_all_scopes[length - i - 1];
73 assertTrue(scope.isScope());
74 assertEquals(scopes[scopes.length - i - 1], scope.scopeType());
75 }
76 }
77
78
79 // Check that the scope chain contains the expected types of scopes.
80 function CheckScopeChain(scopes, exec_state) {
81 var all_scopes = exec_state.frame().allScopes();
82 assertEquals(scopes.length, exec_state.frame().scopeCount());
83 assertEquals(scopes.length, all_scopes.length,
84 "FrameMirror.allScopes length");
85 for (var i = 0; i < scopes.length; i++) {
86 var scope = exec_state.frame().scope(i);
87 assertTrue(scope.isScope());
88 assertEquals(scopes[i], scope.scopeType());
89 assertScopeMirrorEquals(all_scopes[i], scope);
90 }
91 CheckFastAllScopes(scopes, exec_state);
92 }
93
94
95 // Check that the scope chain contains the expected names of scopes.
96 function CheckScopeChainNames(names, exec_state) {
97 var all_scopes = exec_state.frame().allScopes();
98 assertEquals(names.length, all_scopes.length, "FrameMirror.allScopes length");
99 for (var i = 0; i < names.length; i++) {
100 var scope = exec_state.frame().scope(i);
101 assertTrue(scope.isScope());
102 assertEquals(names[i], scope.details().name())
103 }
104 }
105
106
107 // Check that the scope contains at least minimum_content. For functions just
108 // check that there is a function.
109 function CheckScopeContent(minimum_content, number, exec_state) {
110 var scope = exec_state.frame().scope(number);
111 var minimum_count = 0;
112 for (var p in minimum_content) {
113 var property_mirror = scope.scopeObject().property(p);
114 assertFalse(property_mirror.isUndefined(),
115 'property ' + p + ' not found in scope');
116 if (typeof(minimum_content[p]) === 'function') {
117 assertTrue(property_mirror.value().isFunction());
118 } else {
119 assertEquals(minimum_content[p], property_mirror.value().value(),
120 'property ' + p + ' has unexpected value');
121 }
122 minimum_count++;
123 }
124
125 // 'arguments' and might be exposed in the local and closure scope. Just
126 // ignore this.
127 var scope_size = scope.scopeObject().properties().length;
128 if (!scope.scopeObject().property('arguments').isUndefined()) {
129 scope_size--;
130 }
131 // Ditto for 'this'.
132 if (!scope.scopeObject().property('this').isUndefined()) {
133 scope_size--;
134 }
135 // Temporary variables introduced by the parser have not been materialized.
136 assertTrue(scope.scopeObject().property('').isUndefined());
137
138 if (scope_size < minimum_count) {
139 print('Names found in scope:');
140 var names = scope.scopeObject().propertyNames();
141 for (var i = 0; i < names.length; i++) {
142 print(names[i]);
143 }
144 }
145 assertTrue(scope_size >= minimum_count);
146 }
147
148 // Check that the scopes have positions as expected.
149 function CheckScopeChainPositions(positions, exec_state) {
150 var all_scopes = exec_state.frame().allScopes();
151 assertTrue(positions.length <= all_scopes.length,
152 "FrameMirror.allScopes length");
153 for (var i = 0; i < positions.length; i++) {
154 var scope = exec_state.frame().scope(i);
155 assertTrue(scope.isScope());
156 var position = positions[i];
157 if (!position)
158 continue;
159
160 print(
161 `Checking position.start = ${position.start}, .end = ${position.end}`);
162 assertEquals(position.start, scope.details().startPosition())
163 assertEquals(position.end, scope.details().endPosition())
164 }
165 }
166
167 // Simple empty local scope.
168 BeginTest("Local 1");
169
170 function local_1() {
171 debugger;
172 }
173
174 listener_delegate = function(exec_state) {
175 CheckScopeChain([debug.ScopeType.Local,
176 debug.ScopeType.Module,
177 debug.ScopeType.Script,
178 debug.ScopeType.Global], exec_state);
179 CheckScopeContent({}, 0, exec_state);
180 };
181 local_1();
182 EndTest();
183
184
185 // Local scope with a parameter.
186 BeginTest("Local 2");
187
188 function local_2(a) {
189 debugger;
190 }
191
192 listener_delegate = function(exec_state) {
193 CheckScopeChain([debug.ScopeType.Local,
194 debug.ScopeType.Module,
195 debug.ScopeType.Script,
196 debug.ScopeType.Global], exec_state);
197 CheckScopeContent({a:1}, 0, exec_state);
198 };
199 local_2(1);
200 EndTest();
201
202
203 // Local scope with a parameter and a local variable.
204 BeginTest("Local 3");
205
206 function local_3(a) {
207 var x = 3;
208 debugger;
209 }
210
211 listener_delegate = function(exec_state) {
212 CheckScopeChain([debug.ScopeType.Local,
213 debug.ScopeType.Module,
214 debug.ScopeType.Script,
215 debug.ScopeType.Global], exec_state);
216 CheckScopeContent({a:1,x:3}, 0, exec_state);
217 };
218 local_3(1);
219 EndTest();
220
221
222 // Local scope with parameters and local variables.
223 BeginTest("Local 4");
224
225 function local_4(a, b) {
226 var x = 3;
227 var y = 4;
228 debugger;
229 }
230
231 listener_delegate = function(exec_state) {
232 CheckScopeChain([debug.ScopeType.Local,
233 debug.ScopeType.Module,
234 debug.ScopeType.Script,
235 debug.ScopeType.Global], exec_state);
236 CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state);
237 };
238 local_4(1, 2);
239 EndTest();
240
241
242 // Empty local scope with use of eval.
243 BeginTest("Local 5");
244
245 function local_5() {
246 eval('');
247 debugger;
248 }
249
250 listener_delegate = function(exec_state) {
251 CheckScopeChain([debug.ScopeType.Local,
252 debug.ScopeType.Module,
253 debug.ScopeType.Script,
254 debug.ScopeType.Global], exec_state);
255 CheckScopeContent({}, 0, exec_state);
256 };
257 local_5();
258 EndTest();
259
260
261 // Local introducing local variable using eval.
262 BeginTest("Local 6");
263
264 function local_6() {
265 eval('var i = 5');
266 debugger;
267 }
268
269 listener_delegate = function(exec_state) {
270 CheckScopeChain([debug.ScopeType.Local,
271 debug.ScopeType.Module,
272 debug.ScopeType.Script,
273 debug.ScopeType.Global], exec_state);
274 CheckScopeContent({}, 0, exec_state);
275 };
276 local_6();
277 EndTest();
278
279
280 // Local scope with parameters and local variables.
281 BeginTest("Local 7");
282
283 function local_7(a, b) {
284 var x = 3;
285 var y = 4;
286 eval('var i = 5');
287 eval('var j = 6');
288 debugger;
289 }
290
291 listener_delegate = function(exec_state) {
292 CheckScopeChain([debug.ScopeType.Local,
293 debug.ScopeType.Module,
294 debug.ScopeType.Script,
295 debug.ScopeType.Global], exec_state);
296 CheckScopeContent({a:1,b:2,x:3,y:4}, 0, exec_state);
297 };
298 local_7(1, 2);
299 EndTest();
300
301
302 // Simple closure formed by returning an inner function referering the outer
303 // functions arguments.
304 BeginTest("Closure 1");
305
306 function closure_1(a) {
307 function f() {
308 debugger;
309 return a;
310 };
311 return f;
312 }
313
314 listener_delegate = function(exec_state) {
315 CheckScopeChain([debug.ScopeType.Local,
316 debug.ScopeType.Closure,
317 debug.ScopeType.Module,
318 debug.ScopeType.Script,
319 debug.ScopeType.Global], exec_state);
320 CheckScopeContent({a:1}, 1, exec_state);
321 CheckScopeChainNames(["f", "closure_1", undefined, undefined, undefined], exec _state)
322 };
323 closure_1(1)();
324 EndTest();
325
326
327 // Simple closure formed by returning an inner function referering the outer
328 // functions arguments. Due to VM optimizations parts of the actual closure is
329 // missing from the debugger information.
330 BeginTest("Closure 2");
331
332 function closure_2(a, b) {
333 var x = a + 2;
334 var y = b + 2;
335 function f() {
336 debugger;
337 return a + x;
338 };
339 return f;
340 }
341
342 listener_delegate = function(exec_state) {
343 CheckScopeChain([debug.ScopeType.Local,
344 debug.ScopeType.Closure,
345 debug.ScopeType.Module,
346 debug.ScopeType.Script,
347 debug.ScopeType.Global], exec_state);
348 CheckScopeContent({a:1,x:3}, 1, exec_state);
349 CheckScopeChainNames(["f", "closure_2", undefined, undefined, undefined],
350 exec_state)
351 };
352 closure_2(1, 2)();
353 EndTest();
354
355
356 // Simple closure formed by returning an inner function referering the outer
357 // functions arguments. Using all arguments and locals from the outer function
358 // in the inner function makes these part of the debugger information on the
359 // closure.
360 BeginTest("Closure 3");
361
362 function closure_3(a, b) {
363 var x = a + 2;
364 var y = b + 2;
365 function f() {
366 debugger;
367 return a + b + x + y;
368 };
369 return f;
370 }
371
372 listener_delegate = function(exec_state) {
373 CheckScopeChain([debug.ScopeType.Local,
374 debug.ScopeType.Closure,
375 debug.ScopeType.Module,
376 debug.ScopeType.Script,
377 debug.ScopeType.Global], exec_state);
378 CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state);
379 CheckScopeChainNames(["f", "closure_3", undefined, undefined, undefined],
380 exec_state)
381 };
382 closure_3(1, 2)();
383 EndTest();
384
385
386
387 // Simple closure formed by returning an inner function referering the outer
388 // functions arguments. Using all arguments and locals from the outer function
389 // in the inner function makes these part of the debugger information on the
390 // closure. Use the inner function as well...
391 BeginTest("Closure 4");
392
393 function closure_4(a, b) {
394 var x = a + 2;
395 var y = b + 2;
396 function f() {
397 debugger;
398 if (f) {
399 return a + b + x + y;
400 }
401 };
402 return f;
403 }
404
405 listener_delegate = function(exec_state) {
406 CheckScopeChain([debug.ScopeType.Local,
407 debug.ScopeType.Closure,
408 debug.ScopeType.Module,
409 debug.ScopeType.Script,
410 debug.ScopeType.Global], exec_state);
411 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state);
412 CheckScopeChainNames(["f", "closure_4", undefined, undefined, undefined],
413 exec_state)
414 };
415 closure_4(1, 2)();
416 EndTest();
417
418
419
420 // Simple closure formed by returning an inner function referering the outer
421 // functions arguments. In the presence of eval all arguments and locals
422 // (including the inner function itself) from the outer function becomes part of
423 // the debugger infformation on the closure.
424 BeginTest("Closure 5");
425
426 function closure_5(a, b) {
427 var x = 3;
428 var y = 4;
429 function f() {
430 eval('');
431 debugger;
432 return 1;
433 };
434 return f;
435 }
436
437 listener_delegate = function(exec_state) {
438 CheckScopeChain([debug.ScopeType.Local,
439 debug.ScopeType.Closure,
440 debug.ScopeType.Module,
441 debug.ScopeType.Script,
442 debug.ScopeType.Global], exec_state);
443 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state);
444 CheckScopeChainNames(["f", "closure_5", undefined, undefined, undefined],
445 exec_state)
446 };
447 closure_5(1, 2)();
448 EndTest();
449
450
451 // Two closures. Due to optimizations only the parts actually used are provided
452 // through the debugger information.
453 BeginTest("Closure 6");
454 let some_global;
455 function closure_6(a, b) {
456 function f(a, b) {
457 var x = 3;
458 var y = 4;
459 return function() {
460 var x = 3;
461 var y = 4;
462 debugger;
463 some_global = a;
464 return f;
465 };
466 }
467 return f(a, b);
468 }
469
470 listener_delegate = function(exec_state) {
471 CheckScopeChain([debug.ScopeType.Local,
472 debug.ScopeType.Closure,
473 debug.ScopeType.Closure,
474 debug.ScopeType.Module,
475 debug.ScopeType.Script,
476 debug.ScopeType.Global], exec_state);
477 CheckScopeContent({a:1}, 1, exec_state);
478 CheckScopeContent({f:function(){}}, 2, exec_state);
479 CheckScopeChainNames(
480 [undefined, "f", "closure_6", undefined, undefined, undefined],
481 exec_state);
482 };
483 closure_6(1, 2)();
484 EndTest();
485
486
487 // Two closures. In the presence of eval all information is provided as the
488 // compiler cannot determine which parts are used.
489 BeginTest("Closure 7");
490 function closure_7(a, b) {
491 var x = 3;
492 var y = 4;
493 eval('var i = 5');
494 eval('var j = 6');
495 function f(a, b) {
496 var x = 3;
497 var y = 4;
498 eval('var i = 5');
499 eval('var j = 6');
500 return function() {
501 debugger;
502 some_global = a;
503 return f;
504 };
505 }
506 return f(a, b);
507 }
508
509 listener_delegate = function(exec_state) {
510 CheckScopeChain([debug.ScopeType.Local,
511 debug.ScopeType.Closure,
512 debug.ScopeType.Closure,
513 debug.ScopeType.Module,
514 debug.ScopeType.Script,
515 debug.ScopeType.Global], exec_state);
516 CheckScopeContent({}, 0, exec_state);
517 CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state);
518 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 2, exec_state);
519 CheckScopeChainNames(
520 [undefined, "f", "closure_7", undefined, undefined, undefined],
521 exec_state);
522 };
523 closure_7(1, 2)();
524 EndTest();
525
526
527 // Closure that may be optimized out.
528 BeginTest("Closure 8");
529 function closure_8() {
530 (function inner(x) {
531 debugger;
532 })(2);
533 }
534
535 listener_delegate = function(exec_state) {
536 CheckScopeChain([debug.ScopeType.Local,
537 debug.ScopeType.Module,
538 debug.ScopeType.Script,
539 debug.ScopeType.Global], exec_state);
540 CheckScopeContent({x: 2}, 0, exec_state);
541 CheckScopeChainNames(["inner", undefined, undefined, undefined], exec_state);
542 };
543 closure_8();
544 EndTest();
545
546
547 BeginTest("Closure 9");
548 let closure_9 = Function(' \
549 eval("var y = 1;"); \
550 eval("var z = 1;"); \
551 (function inner(x) { \
552 y++; \
553 z++; \
554 debugger; \
555 })(2); \
556 ')
557
558 listener_delegate = function(exec_state) {
559 CheckScopeChain([debug.ScopeType.Local,
560 debug.ScopeType.Closure,
561 debug.ScopeType.Script,
562 debug.ScopeType.Global], exec_state);
563 CheckScopeChainNames(["inner", undefined, undefined, undefined], exec_state);
564 };
565 closure_9();
566 EndTest();
567
568
569 // Test global scope.
570 BeginTest("Global");
571 listener_delegate = function(exec_state) {
572 CheckScopeChain(
573 [debug.ScopeType.Module, debug.ScopeType.Script, debug.ScopeType.Global],
574 exec_state);
575 CheckScopeChainNames([undefined, undefined, undefined], exec_state);
576 };
577 debugger;
578 EndTest();
579
580
581 BeginTest("Catch block 1");
582 function catch_block_1() {
583 try {
584 throw 'Exception';
585 } catch (e) {
586 debugger;
587 }
588 };
589
590
591 listener_delegate = function(exec_state) {
592 CheckScopeChain([debug.ScopeType.Catch,
593 debug.ScopeType.Local,
594 debug.ScopeType.Module,
595 debug.ScopeType.Script,
596 debug.ScopeType.Global], exec_state);
597 CheckScopeContent({e:'Exception'}, 0, exec_state);
598 CheckScopeChainNames(
599 ["catch_block_1", "catch_block_1", undefined, undefined, undefined],
600 exec_state);
601 };
602 catch_block_1();
603 EndTest();
604
605
606 BeginTest("Catch block 3");
607 function catch_block_3() {
608 eval("var y = 78;");
609 try {
610 throw 'Exception';
611 } catch (e) {
612 debugger;
613 }
614 };
615
616
617 listener_delegate = function(exec_state) {
618 CheckScopeChain([debug.ScopeType.Catch,
619 debug.ScopeType.Local,
620 debug.ScopeType.Module,
621 debug.ScopeType.Script,
622 debug.ScopeType.Global], exec_state);
623 CheckScopeContent({e:'Exception'}, 0, exec_state);
624 CheckScopeContent({}, 1, exec_state);
625 CheckScopeChainNames(
626 ["catch_block_3", "catch_block_3", undefined, undefined, undefined],
627 exec_state);
628 };
629 catch_block_3();
630 EndTest();
631
632
633 // Test catch in global scope.
634 BeginTest("Catch block 5");
635 listener_delegate = function(exec_state) {
636 CheckScopeChain([debug.ScopeType.Catch,
637 debug.ScopeType.Module,
638 debug.ScopeType.Script,
639 debug.ScopeType.Global], exec_state);
640 CheckScopeContent({e:'Exception'}, 0, exec_state);
641 CheckScopeChainNames([undefined, undefined, undefined, undefined],
642 exec_state);
643 };
644
645 try {
646 throw 'Exception';
647 } catch (e) {
648 debugger;
649 }
650
651 EndTest();
652
653
654 // Closure inside catch in global code.
655 BeginTest("Catch block 6");
656 listener_delegate = function(exec_state) {
657 CheckScopeChain([debug.ScopeType.Local,
658 debug.ScopeType.Catch,
659 debug.ScopeType.Module,
660 debug.ScopeType.Script,
661 debug.ScopeType.Global], exec_state);
662 CheckScopeContent({x: 2}, 0, exec_state);
663 CheckScopeContent({e:'Exception'}, 1, exec_state);
664 CheckScopeChainNames([undefined, undefined, undefined, undefined, undefined],
665 exec_state);
666 };
667
668 try {
669 throw 'Exception';
670 } catch (e) {
671 (function(x) {
672 debugger;
673 })(2);
674 }
675 EndTest();
676
677
678 // Catch block in function that is marked for optimization while being executed.
679 BeginTest("Catch block 7");
680 function catch_block_7() {
681 %OptimizeFunctionOnNextCall(catch_block_7);
682 try {
683 throw 'Exception';
684 } catch (e) {
685 debugger;
686 }
687 };
688
689
690 listener_delegate = function(exec_state) {
691 CheckScopeChain([debug.ScopeType.Catch,
692 debug.ScopeType.Local,
693 debug.ScopeType.Module,
694 debug.ScopeType.Script,
695 debug.ScopeType.Global], exec_state);
696 CheckScopeContent({e:'Exception'}, 0, exec_state);
697 CheckScopeChainNames(
698 ["catch_block_7", "catch_block_7", undefined, undefined, undefined],
699 exec_state);
700 };
701 catch_block_7();
702 EndTest();
703
704
705 BeginTest("Classes and methods 1");
706
707 listener_delegate = function(exec_state) {
708 "use strict"
709 CheckScopeChain([debug.ScopeType.Local,
710 debug.ScopeType.Module,
711 debug.ScopeType.Script,
712 debug.ScopeType.Global], exec_state);
713 CheckScopeContent({}, 1, exec_state);
714 CheckScopeChainNames(["m", undefined, undefined, undefined], exec_state);
715 };
716
717 (function() {
718 "use strict";
719 class C1 {
720 m() {
721 debugger;
722 }
723 }
724 new C1().m();
725 })();
726
727 EndTest();
728
729 BeginTest("Scope positions");
730 var code1 = "function f() { \n" +
731 " var a = 1; \n" +
732 " function b() { \n" +
733 " debugger; \n" +
734 " return a + 1; \n" +
735 " } \n" +
736 " b(); \n" +
737 "} \n" +
738 "f(); \n";
739
740 listener_delegate = function(exec_state) {
741 CheckScopeChainPositions([{start: 58, end: 118}, {start: 10, end: 162}],
742 exec_state);
743 }
744 eval(code1);
745 EndTest();
746
747
748 BeginTest("Scope positions in for statement");
749 var code3 = "function for_statement() { \n" +
750 " for (let i = 0; i < 1; i++) { \n" +
751 " debugger; \n" +
752 " } \n" +
753 "} \n" +
754 "for_statement(); \n";
755
756 listener_delegate = function(exec_state) {
757 CheckScopeChain([debug.ScopeType.Block,
758 debug.ScopeType.Local,
759 debug.ScopeType.Module,
760 debug.ScopeType.Script,
761 debug.ScopeType.Global], exec_state);
762 CheckScopeChainPositions([{start: 52, end: 111}, {start: 22, end: 145}],
763 exec_state);
764 }
765 eval(code3);
766 EndTest();
767
768 BeginTest("Scope positions in for statement with lexical block");
769 var code4 = "function for_statement() { \n" +
770 " for (let i = 0; i < 1; i++) { \n" +
771 " let j; \n" +
772 " debugger; \n" +
773 " } \n" +
774 "} \n" +
775 "for_statement(); \n";
776
777 listener_delegate = function(exec_state) {
778 CheckScopeChain([debug.ScopeType.Block,
779 debug.ScopeType.Block,
780 debug.ScopeType.Local,
781 debug.ScopeType.Module,
782 debug.ScopeType.Script,
783 debug.ScopeType.Global], exec_state);
784 CheckScopeChainPositions([{start: 66, end: 147},
785 {start: 52, end: 147},
786 {start: 22, end: 181}], exec_state);
787 }
788 eval(code4);
789 EndTest();
790
791 BeginTest("Scope positions in lexical for each statement");
792 var code5 = "function for_each_statement() { \n" +
793 " for (let i of [0]) { \n" +
794 " debugger; \n" +
795 " } \n" +
796 "} \n" +
797 "for_each_statement(); \n";
798
799 listener_delegate = function(exec_state) {
800 CheckScopeChain([debug.ScopeType.Block,
801 debug.ScopeType.Local,
802 debug.ScopeType.Module,
803 debug.ScopeType.Script,
804 debug.ScopeType.Global], exec_state);
805 CheckScopeChainPositions([{start: 55, end: 111}, {start: 27, end: 145}],
806 exec_state);
807 }
808 eval(code5);
809 EndTest();
810
811 BeginTest("Scope positions in lexical for each statement with lexical block");
812 var code6 = "function for_each_statement() { \n" +
813 " for (let i of [0]) { \n" +
814 " let j; \n" +
815 " debugger; \n" +
816 " } \n" +
817 "} \n" +
818 "for_each_statement(); \n";
819
820 listener_delegate = function(exec_state) {
821 CheckScopeChain([debug.ScopeType.Block,
822 debug.ScopeType.Block,
823 debug.ScopeType.Local,
824 debug.ScopeType.Module,
825 debug.ScopeType.Script,
826 debug.ScopeType.Global], exec_state);
827 CheckScopeChainPositions([{start: 57, end: 147},
828 {start: 55, end: 147},
829 {start: 27, end: 181}], exec_state);
830 }
831 eval(code6);
832 EndTest();
833
834 BeginTest("Scope positions in non-lexical for each statement");
835 var code7 = "function for_each_statement() { \n" +
836 " var i; \n" +
837 " for (i of [0]) { \n" +
838 " debugger; \n" +
839 " } \n" +
840 "} \n" +
841 "for_each_statement(); \n";
842
843 listener_delegate = function(exec_state) {
844 CheckScopeChain([debug.ScopeType.Local,
845 debug.ScopeType.Module,
846 debug.ScopeType.Script,
847 debug.ScopeType.Global], exec_state);
848 CheckScopeChainPositions([{start: 27, end: 181}], exec_state);
849 }
850 eval(code7);
851 EndTest();
852
853 BeginTest(
854 "Scope positions in non-lexical for each statement with lexical block");
855 var code8 = "function for_each_statement() { \n" +
856 " var i; \n" +
857 " for (i of [0]) { \n" +
858 " let j; \n" +
859 " debugger; \n" +
860 " } \n" +
861 "} \n" +
862 "for_each_statement(); \n";
863
864 listener_delegate = function(exec_state) {
865 CheckScopeChain([debug.ScopeType.Block,
866 debug.ScopeType.Local,
867 debug.ScopeType.Module,
868 debug.ScopeType.Script,
869 debug.ScopeType.Global], exec_state);
870 CheckScopeChainPositions([{start: 89, end: 183}, {start: 27, end: 217}],
871 exec_state);
872 }
873 eval(code8);
874 EndTest();
875
876 assertEquals(begin_test_count, break_count,
877 'one or more tests did not enter the debugger');
878 assertEquals(begin_test_count, end_test_count,
879 'one or more tests did not have its result checked');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698