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

Side by Side Diff: test/mjsunit/debug-scopes.js

Issue 2536573002: [debug] remove debug command processor from scope tests. (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
« no previous file with comments | « test/mjsunit/bugs/harmony/debug-blockscopes.js ('k') | test/mjsunit/es6/debug-blockscopes.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 assertScopeMirrorEquals(all_scopes[i], scope); 109 assertScopeMirrorEquals(all_scopes[i], scope);
110 110
111 // Check the global object when hitting the global scope. 111 // Check the global object when hitting the global scope.
112 if (scopes[i] == debug.ScopeType.Global) { 112 if (scopes[i] == debug.ScopeType.Global) {
113 // Objects don't have same class (one is "global", other is "Object", 113 // Objects don't have same class (one is "global", other is "Object",
114 // so just check the properties directly. 114 // so just check the properties directly.
115 assertPropertiesEqual(this, scope.scopeObject().value()); 115 assertPropertiesEqual(this, scope.scopeObject().value());
116 } 116 }
117 } 117 }
118 CheckFastAllScopes(scopes, exec_state); 118 CheckFastAllScopes(scopes, exec_state);
119
120 // Get the debug command processor.
121 var dcp = exec_state.debugCommandProcessor("unspecified_running_state");
122
123 // Send a scopes request and check the result.
124 var json;
125 var request_json = '{"seq":0,"type":"request","command":"scopes"}';
126 var response_json = dcp.processDebugJSONRequest(request_json);
127 var response = JSON.parse(response_json);
128 assertEquals(scopes.length, response.body.scopes.length);
129 for (var i = 0; i < scopes.length; i++) {
130 assertEquals(i, response.body.scopes[i].index);
131 assertEquals(scopes[i], response.body.scopes[i].type);
132 if (scopes[i] == debug.ScopeType.Local ||
133 scopes[i] == debug.ScopeType.Script ||
134 scopes[i] == debug.ScopeType.Closure) {
135 assertTrue(response.body.scopes[i].object.ref < 0);
136 } else {
137 assertTrue(response.body.scopes[i].object.ref >= 0);
138 }
139 var found = false;
140 for (var j = 0; j < response.refs.length && !found; j++) {
141 found = response.refs[j].handle == response.body.scopes[i].object.ref;
142 }
143 assertTrue(found, "Scope object " + response.body.scopes[i].object.ref + " n ot found");
144 }
145 } 119 }
146 120
147 121
148 // Check that the scope chain contains the expected names of scopes. 122 // Check that the scope chain contains the expected names of scopes.
149 function CheckScopeChainNames(names, exec_state) { 123 function CheckScopeChainNames(names, exec_state) {
150 var all_scopes = exec_state.frame().allScopes(); 124 var all_scopes = exec_state.frame().allScopes();
151 assertEquals(names.length, all_scopes.length, "FrameMirror.allScopes length"); 125 assertEquals(names.length, all_scopes.length, "FrameMirror.allScopes length");
152 for (var i = 0; i < names.length; i++) { 126 for (var i = 0; i < names.length; i++) {
153 var scope = exec_state.frame().scope(i); 127 var scope = exec_state.frame().scope(i);
154 assertTrue(scope.isScope()); 128 assertTrue(scope.isScope());
155 assertEquals(names[i], scope.details().name()) 129 assertEquals(names[i], scope.details().name())
156 } 130 }
157 } 131 }
158 132
159 133
160 // Check that the scope contains at least minimum_content. For functions just 134 // Check that the scope contains at least minimum_content. For functions just
161 // check that there is a function. 135 // check that there is a function.
162 function CheckScopeContent(minimum_content, number, exec_state) { 136 function CheckScopeContent(minimum_content, number, exec_state) {
163 var scope = exec_state.frame().scope(number); 137 var scope = exec_state.frame().scope(number);
164 var minimum_count = 0; 138 var minimum_count = 0;
165 for (var p in minimum_content) { 139 for (var p in minimum_content) {
166 var property_mirror = scope.scopeObject().property(p); 140 var property_mirror = scope.scopeObject().property(p);
167 assertFalse(property_mirror.isUndefined(), 'property ' + p + ' not found in scope'); 141 assertFalse(property_mirror.isUndefined(),
142 'property ' + p + ' not found in scope');
168 if (typeof(minimum_content[p]) === 'function') { 143 if (typeof(minimum_content[p]) === 'function') {
169 assertTrue(property_mirror.value().isFunction()); 144 assertTrue(property_mirror.value().isFunction());
170 } else { 145 } else {
171 assertEquals(minimum_content[p], property_mirror.value().value(), 'propert y ' + p + ' has unexpected value'); 146 assertEquals(minimum_content[p], property_mirror.value().value(),
147 'property ' + p + ' has unexpected value');
172 } 148 }
173 minimum_count++; 149 minimum_count++;
174 } 150 }
175 151
176 // 'arguments' and might be exposed in the local and closure scope. Just 152 // 'arguments' and might be exposed in the local and closure scope. Just
177 // ignore this. 153 // ignore this.
178 var scope_size = scope.scopeObject().properties().length; 154 var scope_size = scope.scopeObject().properties().length;
179 if (!scope.scopeObject().property('arguments').isUndefined()) { 155 if (!scope.scopeObject().property('arguments').isUndefined()) {
180 scope_size--; 156 scope_size--;
181 } 157 }
182 // Ditto for 'this'. 158 // Ditto for 'this'.
183 if (!scope.scopeObject().property('this').isUndefined()) { 159 if (!scope.scopeObject().property('this').isUndefined()) {
184 scope_size--; 160 scope_size--;
185 } 161 }
186 // Temporary variables introduced by the parser have not been materialized. 162 // Temporary variables introduced by the parser have not been materialized.
187 assertTrue(scope.scopeObject().property('').isUndefined()); 163 assertTrue(scope.scopeObject().property('').isUndefined());
188 164
189 if (scope_size < minimum_count) { 165 if (scope_size < minimum_count) {
190 print('Names found in scope:'); 166 print('Names found in scope:');
191 var names = scope.scopeObject().propertyNames(); 167 var names = scope.scopeObject().propertyNames();
192 for (var i = 0; i < names.length; i++) { 168 for (var i = 0; i < names.length; i++) {
193 print(names[i]); 169 print(names[i]);
194 } 170 }
195 } 171 }
196 assertTrue(scope_size >= minimum_count); 172 assertTrue(scope_size >= minimum_count);
197
198 // Get the debug command processor.
199 var dcp = exec_state.debugCommandProcessor("unspecified_running_state");
200
201 // Send a scope request for information on a single scope and check the
202 // result.
203 var request_json = '{"seq":0,"type":"request","command":"scope","arguments":{" number":';
204 request_json += scope.scopeIndex();
205 request_json += '}}';
206 var response_json = dcp.processDebugJSONRequest(request_json);
207 var response = JSON.parse(response_json);
208 assertEquals(scope.scopeType(), response.body.type);
209 assertEquals(number, response.body.index);
210 if (scope.scopeType() == debug.ScopeType.Local ||
211 scope.scopeType() == debug.ScopeType.Script ||
212 scope.scopeType() == debug.ScopeType.Closure) {
213 assertTrue(response.body.object.ref < 0);
214 } else {
215 assertTrue(response.body.object.ref >= 0);
216 }
217 var found = false;
218 for (var i = 0; i < response.refs.length && !found; i++) {
219 found = response.refs[i].handle == response.body.object.ref;
220 }
221 assertTrue(found, "Scope object " + response.body.object.ref + " not found");
222 } 173 }
223 174
224 // Check that the scopes have positions as expected. 175 // Check that the scopes have positions as expected.
225 function CheckScopeChainPositions(positions, exec_state) { 176 function CheckScopeChainPositions(positions, exec_state) {
226 var all_scopes = exec_state.frame().allScopes(); 177 var all_scopes = exec_state.frame().allScopes();
227 assertEquals(positions.length, all_scopes.length, "FrameMirror.allScopes lengt h"); 178 assertEquals(positions.length, all_scopes.length, "FrameMirror.allScopes lengt h");
228 for (var i = 0; i < positions.length; i++) { 179 for (var i = 0; i < positions.length; i++) {
229 var scope = exec_state.frame().scope(i); 180 var scope = exec_state.frame().scope(i);
230 assertTrue(scope.isScope()); 181 assertTrue(scope.isScope());
231 var position = positions[i]; 182 var position = positions[i];
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 } 418 }
468 419
469 listener_delegate = function(exec_state) { 420 listener_delegate = function(exec_state) {
470 CheckScopeChain([debug.ScopeType.With, 421 CheckScopeChain([debug.ScopeType.With,
471 debug.ScopeType.With, 422 debug.ScopeType.With,
472 debug.ScopeType.Local, 423 debug.ScopeType.Local,
473 debug.ScopeType.Script, 424 debug.ScopeType.Script,
474 debug.ScopeType.Global], exec_state); 425 debug.ScopeType.Global], exec_state);
475 CheckScopeContent(with_object, 0, exec_state); 426 CheckScopeContent(with_object, 0, exec_state);
476 CheckScopeContent(with_object, 1, exec_state); 427 CheckScopeContent(with_object, 1, exec_state);
477 assertEquals(exec_state.frame().scope(0).scopeObject(), exec_state.frame().sco pe(1).scopeObject()); 428 assertEquals(exec_state.frame().scope(0).scopeObject(),
429 exec_state.frame().scope(1).scopeObject());
478 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); 430 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value());
479 }; 431 };
480 with_5(); 432 with_5();
481 EndTest(); 433 EndTest();
482 434
483 435
484 // Nested with blocks using existing object in global code. 436 // Nested with blocks using existing object in global code.
485 BeginTest("With 6"); 437 BeginTest("With 6");
486 listener_delegate = function(exec_state) { 438 listener_delegate = function(exec_state) {
487 CheckScopeChain([debug.ScopeType.With, 439 CheckScopeChain([debug.ScopeType.With,
488 debug.ScopeType.With, 440 debug.ScopeType.With,
489 debug.ScopeType.Script, 441 debug.ScopeType.Script,
490 debug.ScopeType.Global], exec_state); 442 debug.ScopeType.Global], exec_state);
491 CheckScopeContent(with_object, 0, exec_state); 443 CheckScopeContent(with_object, 0, exec_state);
492 CheckScopeContent(with_object, 1, exec_state); 444 CheckScopeContent(with_object, 1, exec_state);
493 assertEquals(exec_state.frame().scope(0).scopeObject(), exec_state.frame().sco pe(1).scopeObject()); 445 assertEquals(exec_state.frame().scope(0).scopeObject(),
446 exec_state.frame().scope(1).scopeObject());
494 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); 447 assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value());
495 }; 448 };
496 449
497 var with_object = {c:3,d:4}; 450 var with_object = {c:3,d:4};
498 with(with_object) { 451 with(with_object) {
499 with(with_object) { 452 with(with_object) {
500 debugger; 453 debugger;
501 } 454 }
502 } 455 }
503 EndTest(); 456 EndTest();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 }; 488 };
536 return f; 489 return f;
537 } 490 }
538 491
539 listener_delegate = function(exec_state) { 492 listener_delegate = function(exec_state) {
540 CheckScopeChain([debug.ScopeType.Local, 493 CheckScopeChain([debug.ScopeType.Local,
541 debug.ScopeType.Closure, 494 debug.ScopeType.Closure,
542 debug.ScopeType.Script, 495 debug.ScopeType.Script,
543 debug.ScopeType.Global], exec_state); 496 debug.ScopeType.Global], exec_state);
544 CheckScopeContent({a:1}, 1, exec_state); 497 CheckScopeContent({a:1}, 1, exec_state);
545 CheckScopeChainNames(["f", "closure_1", undefined, undefined], exec_state) 498 CheckScopeChainNames(["f", "closure_1", undefined, undefined], exec_state);
546 }; 499 };
547 closure_1(1)(); 500 closure_1(1)();
548 EndTest(); 501 EndTest();
549 502
550 503
551 // Simple closure formed by returning an inner function referering the outer 504 // Simple closure formed by returning an inner function referering the outer
552 // functions arguments. Due to VM optimizations parts of the actual closure is 505 // functions arguments. Due to VM optimizations parts of the actual closure is
553 // missing from the debugger information. 506 // missing from the debugger information.
554 BeginTest("Closure 2"); 507 BeginTest("Closure 2");
555 508
556 function closure_2(a, b) { 509 function closure_2(a, b) {
557 var x = a + 2; 510 var x = a + 2;
558 var y = b + 2; 511 var y = b + 2;
559 function f() { 512 function f() {
560 debugger; 513 debugger;
561 return a + x; 514 return a + x;
562 }; 515 };
563 return f; 516 return f;
564 } 517 }
565 518
566 listener_delegate = function(exec_state) { 519 listener_delegate = function(exec_state) {
567 CheckScopeChain([debug.ScopeType.Local, 520 CheckScopeChain([debug.ScopeType.Local,
568 debug.ScopeType.Closure, 521 debug.ScopeType.Closure,
569 debug.ScopeType.Script, 522 debug.ScopeType.Script,
570 debug.ScopeType.Global], exec_state); 523 debug.ScopeType.Global], exec_state);
571 CheckScopeContent({a:1,x:3}, 1, exec_state); 524 CheckScopeContent({a:1,x:3}, 1, exec_state);
572 CheckScopeChainNames(["f", "closure_2", undefined, undefined], exec_state) 525 CheckScopeChainNames(["f", "closure_2", undefined, undefined], exec_state);
573 }; 526 };
574 closure_2(1, 2)(); 527 closure_2(1, 2)();
575 EndTest(); 528 EndTest();
576 529
577 530
578 // Simple closure formed by returning an inner function referering the outer 531 // Simple closure formed by returning an inner function referering the outer
579 // functions arguments. Using all arguments and locals from the outer function 532 // functions arguments. Using all arguments and locals from the outer function
580 // in the inner function makes these part of the debugger information on the 533 // in the inner function makes these part of the debugger information on the
581 // closure. 534 // closure.
582 BeginTest("Closure 3"); 535 BeginTest("Closure 3");
583 536
584 function closure_3(a, b) { 537 function closure_3(a, b) {
585 var x = a + 2; 538 var x = a + 2;
586 var y = b + 2; 539 var y = b + 2;
587 function f() { 540 function f() {
588 debugger; 541 debugger;
589 return a + b + x + y; 542 return a + b + x + y;
590 }; 543 };
591 return f; 544 return f;
592 } 545 }
593 546
594 listener_delegate = function(exec_state) { 547 listener_delegate = function(exec_state) {
595 CheckScopeChain([debug.ScopeType.Local, 548 CheckScopeChain([debug.ScopeType.Local,
596 debug.ScopeType.Closure, 549 debug.ScopeType.Closure,
597 debug.ScopeType.Script, 550 debug.ScopeType.Script,
598 debug.ScopeType.Global], exec_state); 551 debug.ScopeType.Global], exec_state);
599 CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state); 552 CheckScopeContent({a:1,b:2,x:3,y:4}, 1, exec_state);
600 CheckScopeChainNames(["f", "closure_3", undefined, undefined], exec_state) 553 CheckScopeChainNames(["f", "closure_3", undefined, undefined], exec_state);
601 }; 554 };
602 closure_3(1, 2)(); 555 closure_3(1, 2)();
603 EndTest(); 556 EndTest();
604 557
605 558
606 559
607 // Simple closure formed by returning an inner function referering the outer 560 // Simple closure formed by returning an inner function referering the outer
608 // functions arguments. Using all arguments and locals from the outer function 561 // functions arguments. Using all arguments and locals from the outer function
609 // in the inner function makes these part of the debugger information on the 562 // in the inner function makes these part of the debugger information on the
610 // closure. Use the inner function as well... 563 // closure. Use the inner function as well...
(...skipping 10 matching lines...) Expand all
621 }; 574 };
622 return f; 575 return f;
623 } 576 }
624 577
625 listener_delegate = function(exec_state) { 578 listener_delegate = function(exec_state) {
626 CheckScopeChain([debug.ScopeType.Local, 579 CheckScopeChain([debug.ScopeType.Local,
627 debug.ScopeType.Closure, 580 debug.ScopeType.Closure,
628 debug.ScopeType.Script, 581 debug.ScopeType.Script,
629 debug.ScopeType.Global], exec_state); 582 debug.ScopeType.Global], exec_state);
630 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); 583 CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state);
631 CheckScopeChainNames(["f", "closure_4", undefined, undefined], exec_state) 584 CheckScopeChainNames(["f", "closure_4", undefined, undefined], exec_state);
632 }; 585 };
633 closure_4(1, 2)(); 586 closure_4(1, 2)();
634 EndTest(); 587 EndTest();
635 588
636 589
637 590
638 // Simple closure formed by returning an inner function referering the outer 591 // Simple closure formed by returning an inner function referering the outer
639 // functions arguments. In the presence of eval all arguments and locals 592 // functions arguments. In the presence of eval all arguments and locals
640 // (including the inner function itself) from the outer function becomes part of 593 // (including the inner function itself) from the outer function becomes part of
641 // the debugger infformation on the closure. 594 // the debugger infformation on the closure.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 } 636 }
684 637
685 listener_delegate = function(exec_state) { 638 listener_delegate = function(exec_state) {
686 CheckScopeChain([debug.ScopeType.Local, 639 CheckScopeChain([debug.ScopeType.Local,
687 debug.ScopeType.Closure, 640 debug.ScopeType.Closure,
688 debug.ScopeType.Closure, 641 debug.ScopeType.Closure,
689 debug.ScopeType.Script, 642 debug.ScopeType.Script,
690 debug.ScopeType.Global], exec_state); 643 debug.ScopeType.Global], exec_state);
691 CheckScopeContent({a:1}, 1, exec_state); 644 CheckScopeContent({a:1}, 1, exec_state);
692 CheckScopeContent({f:function(){}}, 2, exec_state); 645 CheckScopeContent({f:function(){}}, 2, exec_state);
693 CheckScopeChainNames([undefined, "f", "closure_6", undefined, undefined], exec _state) 646 CheckScopeChainNames([undefined, "f", "closure_6", undefined, undefined],
647 exec_state);
694 }; 648 };
695 closure_6(1, 2)(); 649 closure_6(1, 2)();
696 EndTest(); 650 EndTest();
697 651
698 652
699 // Two closures. In the presence of eval all information is provided as the 653 // Two closures. In the presence of eval all information is provided as the
700 // compiler cannot determine which parts are used. 654 // compiler cannot determine which parts are used.
701 BeginTest("Closure 7"); 655 BeginTest("Closure 7");
702 function closure_7(a, b) { 656 function closure_7(a, b) {
703 var x = 3; 657 var x = 3;
(...skipping 16 matching lines...) Expand all
720 674
721 listener_delegate = function(exec_state) { 675 listener_delegate = function(exec_state) {
722 CheckScopeChain([debug.ScopeType.Local, 676 CheckScopeChain([debug.ScopeType.Local,
723 debug.ScopeType.Closure, 677 debug.ScopeType.Closure,
724 debug.ScopeType.Closure, 678 debug.ScopeType.Closure,
725 debug.ScopeType.Script, 679 debug.ScopeType.Script,
726 debug.ScopeType.Global], exec_state); 680 debug.ScopeType.Global], exec_state);
727 CheckScopeContent({}, 0, exec_state); 681 CheckScopeContent({}, 0, exec_state);
728 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state); 682 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state);
729 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 2, exec_state); 683 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 2, exec_state);
730 CheckScopeChainNames([undefined, "f", "closure_7", undefined, undefined], exec _state) 684 CheckScopeChainNames([undefined, "f", "closure_7", undefined, undefined],
685 exec_state);
731 }; 686 };
732 closure_7(1, 2)(); 687 closure_7(1, 2)();
733 EndTest(); 688 EndTest();
734 689
735 690
736 // Closure that may be optimized out. 691 // Closure that may be optimized out.
737 BeginTest("Closure 8"); 692 BeginTest("Closure 8");
738 function closure_8() { 693 function closure_8() {
739 (function inner(x) { 694 (function inner(x) {
740 debugger; 695 debugger;
741 })(2); 696 })(2);
742 } 697 }
743 698
744 listener_delegate = function(exec_state) { 699 listener_delegate = function(exec_state) {
745 CheckScopeChain([debug.ScopeType.Local, 700 CheckScopeChain([debug.ScopeType.Local,
746 debug.ScopeType.Script, 701 debug.ScopeType.Script,
747 debug.ScopeType.Global], exec_state); 702 debug.ScopeType.Global], exec_state);
748 CheckScopeContent({x: 2}, 0, exec_state); 703 CheckScopeContent({x: 2}, 0, exec_state);
749 CheckScopeChainNames(["inner", undefined, undefined], exec_state) 704 CheckScopeChainNames(["inner", undefined, undefined], exec_state);
750 }; 705 };
751 closure_8(); 706 closure_8();
752 EndTest(); 707 EndTest();
753 708
754 709
755 BeginTest("Closure 9"); 710 BeginTest("Closure 9");
756 function closure_9() { 711 function closure_9() {
757 eval("var y = 1;"); 712 eval("var y = 1;");
758 eval("var z = 1;"); 713 eval("var z = 1;");
759 (function inner(x) { 714 (function inner(x) {
760 y++; 715 y++;
761 z++; 716 z++;
762 debugger; 717 debugger;
763 })(2); 718 })(2);
764 } 719 }
765 720
766 listener_delegate = function(exec_state) { 721 listener_delegate = function(exec_state) {
767 CheckScopeChain([debug.ScopeType.Local, 722 CheckScopeChain([debug.ScopeType.Local,
768 debug.ScopeType.Closure, 723 debug.ScopeType.Closure,
769 debug.ScopeType.Script, 724 debug.ScopeType.Script,
770 debug.ScopeType.Global], exec_state); 725 debug.ScopeType.Global], exec_state);
771 CheckScopeChainNames(["inner", "closure_9", undefined, undefined], exec_state) 726 CheckScopeChainNames(["inner", "closure_9", undefined, undefined],
727 exec_state);
772 }; 728 };
773 closure_9(); 729 closure_9();
774 EndTest(); 730 EndTest();
775 731
776 732
777 // Test a mixture of scopes. 733 // Test a mixture of scopes.
778 BeginTest("The full monty"); 734 BeginTest("The full monty");
779 function the_full_monty(a, b) { 735 function the_full_monty(a, b) {
780 var x = 3; 736 var x = 3;
781 var y = 4; 737 var y = 4;
(...skipping 28 matching lines...) Expand all
810 debug.ScopeType.Closure, 766 debug.ScopeType.Closure,
811 debug.ScopeType.Closure, 767 debug.ScopeType.Closure,
812 debug.ScopeType.Script, 768 debug.ScopeType.Script,
813 debug.ScopeType.Global], exec_state); 769 debug.ScopeType.Global], exec_state);
814 CheckScopeContent({b:16}, 0, exec_state); 770 CheckScopeContent({b:16}, 0, exec_state);
815 CheckScopeContent({a:15}, 1, exec_state); 771 CheckScopeContent({a:15}, 1, exec_state);
816 CheckScopeContent({x:14}, 2, exec_state); 772 CheckScopeContent({x:14}, 2, exec_state);
817 CheckScopeContent({j:13}, 3, exec_state); 773 CheckScopeContent({j:13}, 3, exec_state);
818 CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state); 774 CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state);
819 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, exec_state); 775 CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, exec_state);
820 CheckScopeChainNames([undefined, undefined, undefined, "f", "f", "the_full_mon ty", undefined, undefined], exec_state) 776 CheckScopeChainNames([undefined, undefined, undefined, "f", "f",
777 "the_full_monty", undefined, undefined], exec_state);
821 }; 778 };
822 the_full_monty(1, 2)(); 779 the_full_monty(1, 2)();
823 EndTest(); 780 EndTest();
824 781
825 782
826 BeginTest("Closure inside With 1"); 783 BeginTest("Closure inside With 1");
827 function closure_in_with_1() { 784 function closure_in_with_1() {
828 with({x:1}) { 785 with({x:1}) {
829 (function inner(x) { 786 (function inner(x) {
830 debugger; 787 debugger;
(...skipping 26 matching lines...) Expand all
857 814
858 listener_delegate = function(exec_state) { 815 listener_delegate = function(exec_state) {
859 CheckScopeChain([debug.ScopeType.With, 816 CheckScopeChain([debug.ScopeType.With,
860 debug.ScopeType.Local, 817 debug.ScopeType.Local,
861 debug.ScopeType.With, 818 debug.ScopeType.With,
862 debug.ScopeType.Script, 819 debug.ScopeType.Script,
863 debug.ScopeType.Global], exec_state); 820 debug.ScopeType.Global], exec_state);
864 CheckScopeContent({x: 3}, 0, exec_state); 821 CheckScopeContent({x: 3}, 0, exec_state);
865 CheckScopeContent({x: 2}, 1, exec_state); 822 CheckScopeContent({x: 2}, 1, exec_state);
866 CheckScopeContent({x: 1}, 2, exec_state); 823 CheckScopeContent({x: 1}, 2, exec_state);
867 CheckScopeChainNames(["inner", "inner", "closure_in_with_2", undefined, undefi ned], exec_state) 824 CheckScopeChainNames(["inner", "inner", "closure_in_with_2",
825 undefined, undefined], exec_state);
868 }; 826 };
869 closure_in_with_2(); 827 closure_in_with_2();
870 EndTest(); 828 EndTest();
871 829
872 830
873 BeginTest("Closure inside With 3"); 831 BeginTest("Closure inside With 3");
874 function createClosure(a) { 832 function createClosure(a) {
875 var b = a + 1; 833 var b = a + 1;
876 return function closure() { 834 return function closure() {
877 var c = b; 835 var c = b;
(...skipping 10 matching lines...) Expand all
888 f(); 846 f();
889 } 847 }
890 848
891 listener_delegate = function(exec_state) { 849 listener_delegate = function(exec_state) {
892 CheckScopeChain([debug.ScopeType.With, 850 CheckScopeChain([debug.ScopeType.With,
893 debug.ScopeType.Local, 851 debug.ScopeType.Local,
894 debug.ScopeType.Closure, 852 debug.ScopeType.Closure,
895 debug.ScopeType.Closure, 853 debug.ScopeType.Closure,
896 debug.ScopeType.Script, 854 debug.ScopeType.Script,
897 debug.ScopeType.Global], exec_state); 855 debug.ScopeType.Global], exec_state);
898 CheckScopeChainNames(["inner", "inner", "closure", "createClosure", undefined, undefined], exec_state) 856 CheckScopeChainNames(["inner", "inner", "closure", "createClosure",
857 undefined, undefined], exec_state);
899 } 858 }
900 closure_in_with_3(); 859 closure_in_with_3();
901 EndTest(); 860 EndTest();
902 861
903 862
904 BeginTest("Closure inside With 4"); 863 BeginTest("Closure inside With 4");
905 listener_delegate = function(exec_state) { 864 listener_delegate = function(exec_state) {
906 CheckScopeChain([debug.ScopeType.Local, 865 CheckScopeChain([debug.ScopeType.Local,
907 debug.ScopeType.With, 866 debug.ScopeType.With,
908 debug.ScopeType.Script, 867 debug.ScopeType.Script,
909 debug.ScopeType.Global], exec_state); 868 debug.ScopeType.Global], exec_state);
910 CheckScopeContent({x: 2}, 0, exec_state); 869 CheckScopeContent({x: 2}, 0, exec_state);
911 CheckScopeContent({x: 1}, 1, exec_state); 870 CheckScopeContent({x: 1}, 1, exec_state);
912 CheckScopeChainNames([undefined, undefined, undefined, undefined], exec_state) 871 CheckScopeChainNames([undefined, undefined, undefined, undefined],
872 exec_state);
913 }; 873 };
914 874
915 with({x:1}) { 875 with({x:1}) {
916 (function(x) { 876 (function(x) {
917 debugger; 877 debugger;
918 })(2); 878 })(2);
919 } 879 }
920 EndTest(); 880 EndTest();
921 881
922 882
923 // Test global scope. 883 // Test global scope.
924 BeginTest("Global"); 884 BeginTest("Global");
925 listener_delegate = function(exec_state) { 885 listener_delegate = function(exec_state) {
926 CheckScopeChain([debug.ScopeType.Script, debug.ScopeType.Global], exec_state); 886 CheckScopeChain([debug.ScopeType.Script, debug.ScopeType.Global],
927 CheckScopeChainNames([undefined, undefined], exec_state) 887 exec_state);
888 CheckScopeChainNames([undefined, undefined], exec_state);
928 }; 889 };
929 debugger; 890 debugger;
930 EndTest(); 891 EndTest();
931 892
932 893
933 BeginTest("Catch block 1"); 894 BeginTest("Catch block 1");
934 function catch_block_1() { 895 function catch_block_1() {
935 try { 896 try {
936 throw 'Exception'; 897 throw 'Exception';
937 } catch (e) { 898 } catch (e) {
938 debugger; 899 debugger;
939 } 900 }
940 }; 901 };
941 902
942 903
943 listener_delegate = function(exec_state) { 904 listener_delegate = function(exec_state) {
944 CheckScopeChain([debug.ScopeType.Catch, 905 CheckScopeChain([debug.ScopeType.Catch,
945 debug.ScopeType.Local, 906 debug.ScopeType.Local,
946 debug.ScopeType.Script, 907 debug.ScopeType.Script,
947 debug.ScopeType.Global], exec_state); 908 debug.ScopeType.Global], exec_state);
948 CheckScopeContent({e:'Exception'}, 0, exec_state); 909 CheckScopeContent({e:'Exception'}, 0, exec_state);
949 CheckScopeChainNames(["catch_block_1", "catch_block_1", undefined, undefined], exec_state) 910 CheckScopeChainNames(["catch_block_1", "catch_block_1",
911 undefined, undefined], exec_state);
950 }; 912 };
951 catch_block_1(); 913 catch_block_1();
952 EndTest(); 914 EndTest();
953 915
954 916
955 BeginTest("Catch block 2"); 917 BeginTest("Catch block 2");
956 function catch_block_2() { 918 function catch_block_2() {
957 try { 919 try {
958 throw 'Exception'; 920 throw 'Exception';
959 } catch (e) { 921 } catch (e) {
960 with({n:10}) { 922 with({n:10}) {
961 debugger; 923 debugger;
962 } 924 }
963 } 925 }
964 }; 926 };
965 927
966 928
967 listener_delegate = function(exec_state) { 929 listener_delegate = function(exec_state) {
968 CheckScopeChain([debug.ScopeType.With, 930 CheckScopeChain([debug.ScopeType.With,
969 debug.ScopeType.Catch, 931 debug.ScopeType.Catch,
970 debug.ScopeType.Local, 932 debug.ScopeType.Local,
971 debug.ScopeType.Script, 933 debug.ScopeType.Script,
972 debug.ScopeType.Global], exec_state); 934 debug.ScopeType.Global], exec_state);
973 CheckScopeContent({n:10}, 0, exec_state); 935 CheckScopeContent({n:10}, 0, exec_state);
974 CheckScopeContent({e:'Exception'}, 1, exec_state); 936 CheckScopeContent({e:'Exception'}, 1, exec_state);
975 CheckScopeChainNames(["catch_block_2", "catch_block_2", "catch_block_2", undef ined, undefined], exec_state) 937 CheckScopeChainNames(["catch_block_2", "catch_block_2", "catch_block_2",
938 undefined, undefined], exec_state);
976 }; 939 };
977 catch_block_2(); 940 catch_block_2();
978 EndTest(); 941 EndTest();
979 942
980 943
981 BeginTest("Catch block 3"); 944 BeginTest("Catch block 3");
982 function catch_block_3() { 945 function catch_block_3() {
983 // Do eval to dynamically declare a local variable so that the context's 946 // Do eval to dynamically declare a local variable so that the context's
984 // extension slot is initialized with JSContextExtensionObject. 947 // extension slot is initialized with JSContextExtensionObject.
985 eval("var y = 78;"); 948 eval("var y = 78;");
986 try { 949 try {
987 throw 'Exception'; 950 throw 'Exception';
988 } catch (e) { 951 } catch (e) {
989 debugger; 952 debugger;
990 } 953 }
991 }; 954 };
992 955
993 956
994 listener_delegate = function(exec_state) { 957 listener_delegate = function(exec_state) {
995 CheckScopeChain([debug.ScopeType.Catch, 958 CheckScopeChain([debug.ScopeType.Catch,
996 debug.ScopeType.Local, 959 debug.ScopeType.Local,
997 debug.ScopeType.Script, 960 debug.ScopeType.Script,
998 debug.ScopeType.Global], exec_state); 961 debug.ScopeType.Global], exec_state);
999 CheckScopeContent({e:'Exception'}, 0, exec_state); 962 CheckScopeContent({e:'Exception'}, 0, exec_state);
1000 CheckScopeContent({y:78}, 1, exec_state); 963 CheckScopeContent({y:78}, 1, exec_state);
1001 CheckScopeChainNames(["catch_block_3", "catch_block_3", undefined, undefined], exec_state) 964 CheckScopeChainNames(["catch_block_3", "catch_block_3",
965 undefined, undefined], exec_state);
1002 }; 966 };
1003 catch_block_3(); 967 catch_block_3();
1004 EndTest(); 968 EndTest();
1005 969
1006 970
1007 BeginTest("Catch block 4"); 971 BeginTest("Catch block 4");
1008 function catch_block_4() { 972 function catch_block_4() {
1009 // 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
1010 // extension slot is initialized with JSContextExtensionObject. 974 // extension slot is initialized with JSContextExtensionObject.
1011 eval("var y = 98;"); 975 eval("var y = 98;");
1012 try { 976 try {
1013 throw 'Exception'; 977 throw 'Exception';
1014 } catch (e) { 978 } catch (e) {
1015 with({n:10}) { 979 with({n:10}) {
1016 debugger; 980 debugger;
1017 } 981 }
1018 } 982 }
1019 }; 983 };
1020 984
1021 listener_delegate = function(exec_state) { 985 listener_delegate = function(exec_state) {
1022 CheckScopeChain([debug.ScopeType.With, 986 CheckScopeChain([debug.ScopeType.With,
1023 debug.ScopeType.Catch, 987 debug.ScopeType.Catch,
1024 debug.ScopeType.Local, 988 debug.ScopeType.Local,
1025 debug.ScopeType.Script, 989 debug.ScopeType.Script,
1026 debug.ScopeType.Global], exec_state); 990 debug.ScopeType.Global], exec_state);
1027 CheckScopeContent({n:10}, 0, exec_state); 991 CheckScopeContent({n:10}, 0, exec_state);
1028 CheckScopeContent({e:'Exception'}, 1, exec_state); 992 CheckScopeContent({e:'Exception'}, 1, exec_state);
1029 CheckScopeContent({y:98}, 2, exec_state); 993 CheckScopeContent({y:98}, 2, exec_state);
1030 CheckScopeChainNames(["catch_block_4", "catch_block_4", "catch_block_4", undef ined, undefined], exec_state) 994 CheckScopeChainNames(["catch_block_4", "catch_block_4", "catch_block_4",
995 undefined, undefined], exec_state);
1031 }; 996 };
1032 catch_block_4(); 997 catch_block_4();
1033 EndTest(); 998 EndTest();
1034 999
1035 1000
1036 // Test catch in global scope. 1001 // Test catch in global scope.
1037 BeginTest("Catch block 5"); 1002 BeginTest("Catch block 5");
1038 listener_delegate = function(exec_state) { 1003 listener_delegate = function(exec_state) {
1039 CheckScopeChain([debug.ScopeType.Catch, 1004 CheckScopeChain([debug.ScopeType.Catch,
1040 debug.ScopeType.Script, 1005 debug.ScopeType.Script,
1041 debug.ScopeType.Global], exec_state); 1006 debug.ScopeType.Global], exec_state);
1042 CheckScopeContent({e:'Exception'}, 0, exec_state); 1007 CheckScopeContent({e:'Exception'}, 0, exec_state);
1043 CheckScopeChainNames([undefined, undefined, undefined], exec_state) 1008 CheckScopeChainNames([undefined, undefined, undefined], exec_state);
1044 }; 1009 };
1045 1010
1046 try { 1011 try {
1047 throw 'Exception'; 1012 throw 'Exception';
1048 } catch (e) { 1013 } catch (e) {
1049 debugger; 1014 debugger;
1050 } 1015 }
1051 1016
1052 EndTest(); 1017 EndTest();
1053 1018
1054 1019
1055 // Closure inside catch in global code. 1020 // Closure inside catch in global code.
1056 BeginTest("Catch block 6"); 1021 BeginTest("Catch block 6");
1057 listener_delegate = function(exec_state) { 1022 listener_delegate = function(exec_state) {
1058 CheckScopeChain([debug.ScopeType.Local, 1023 CheckScopeChain([debug.ScopeType.Local,
1059 debug.ScopeType.Catch, 1024 debug.ScopeType.Catch,
1060 debug.ScopeType.Script, 1025 debug.ScopeType.Script,
1061 debug.ScopeType.Global], exec_state); 1026 debug.ScopeType.Global], exec_state);
1062 CheckScopeContent({x: 2}, 0, exec_state); 1027 CheckScopeContent({x: 2}, 0, exec_state);
1063 CheckScopeContent({e:'Exception'}, 1, exec_state); 1028 CheckScopeContent({e:'Exception'}, 1, exec_state);
1064 CheckScopeChainNames([undefined, undefined, undefined, undefined], exec_state) 1029 CheckScopeChainNames([undefined, undefined, undefined, undefined],
1030 exec_state);
1065 }; 1031 };
1066 1032
1067 try { 1033 try {
1068 throw 'Exception'; 1034 throw 'Exception';
1069 } catch (e) { 1035 } catch (e) {
1070 (function(x) { 1036 (function(x) {
1071 debugger; 1037 debugger;
1072 })(2); 1038 })(2);
1073 } 1039 }
1074 EndTest(); 1040 EndTest();
(...skipping 10 matching lines...) Expand all
1085 } 1051 }
1086 }; 1052 };
1087 1053
1088 1054
1089 listener_delegate = function(exec_state) { 1055 listener_delegate = function(exec_state) {
1090 CheckScopeChain([debug.ScopeType.Catch, 1056 CheckScopeChain([debug.ScopeType.Catch,
1091 debug.ScopeType.Local, 1057 debug.ScopeType.Local,
1092 debug.ScopeType.Script, 1058 debug.ScopeType.Script,
1093 debug.ScopeType.Global], exec_state); 1059 debug.ScopeType.Global], exec_state);
1094 CheckScopeContent({e:'Exception'}, 0, exec_state); 1060 CheckScopeContent({e:'Exception'}, 0, exec_state);
1095 CheckScopeChainNames(["catch_block_7", "catch_block_7", undefined, undefined], exec_state) 1061 CheckScopeChainNames(["catch_block_7", "catch_block_7",
1062 undefined, undefined], exec_state);
1096 }; 1063 };
1097 catch_block_7(); 1064 catch_block_7();
1098 EndTest(); 1065 EndTest();
1099 1066
1100 1067
1101 BeginTest("Classes and methods 1"); 1068 BeginTest("Classes and methods 1");
1102 1069
1103 listener_delegate = function(exec_state) { 1070 listener_delegate = function(exec_state) {
1104 "use strict" 1071 "use strict"
1105 CheckScopeChain([debug.ScopeType.Local, 1072 CheckScopeChain([debug.ScopeType.Local,
1106 debug.ScopeType.Script, 1073 debug.ScopeType.Script,
1107 debug.ScopeType.Global], exec_state); 1074 debug.ScopeType.Global], exec_state);
1108 CheckScopeContent({}, 1, exec_state); 1075 CheckScopeContent({}, 1, exec_state);
1109 CheckScopeChainNames(["m", undefined, undefined], exec_state) 1076 CheckScopeChainNames(["m", undefined, undefined], exec_state);
1110 }; 1077 };
1111 1078
1112 (function() { 1079 (function() {
1113 "use strict"; 1080 "use strict";
1114 class C1 { 1081 class C1 {
1115 m() { 1082 m() {
1116 debugger; 1083 debugger;
1117 } 1084 }
1118 } 1085 }
1119 new C1().m(); 1086 new C1().m();
1120 })(); 1087 })();
1121 1088
1122 EndTest(); 1089 EndTest();
1123 1090
1124 BeginTest("Scope positions"); 1091 BeginTest("Scope positions");
1125 var code1 = "function f() { \n" + 1092 var code1 = "function f() { \n" +
1126 " var a = 1; \n" + 1093 " var a = 1; \n" +
1127 " function b() { \n" + 1094 " function b() { \n" +
1128 " debugger; \n" + 1095 " debugger; \n" +
1129 " return a + 1; \n" + 1096 " return a + 1; \n" +
1130 " } \n" + 1097 " } \n" +
1131 " b(); \n" + 1098 " b(); \n" +
1132 "} \n" + 1099 "} \n" +
1133 "f(); \n"; 1100 "f(); \n";
1134 1101
1135 listener_delegate = function(exec_state) { 1102 listener_delegate = function(exec_state) {
1136 CheckScopeChainPositions([{start: 58, end: 118}, {start: 10, end: 162}, {}, {} ], exec_state); 1103 CheckScopeChainPositions(
1104 [{start: 58, end: 118}, {start: 10, end: 162}, {}, {}], exec_state);
1137 } 1105 }
1138 eval(code1); 1106 eval(code1);
1139 EndTest(); 1107 EndTest();
1140 1108
1141 1109
1142 function catch_block_2() { 1110 function catch_block_2() {
1143 try { 1111 try {
1144 throw 'Exception'; 1112 throw 'Exception';
1145 } catch (e) { 1113 } catch (e) {
1146 with({n:10}) { 1114 with({n:10}) {
1147 debugger; 1115 debugger;
1148 } 1116 }
1149 } 1117 }
1150 }; 1118 };
1151 1119
1152 BeginTest("Scope positions in catch and 'with' statement"); 1120 BeginTest("Scope positions in catch and 'with' statement");
1153 var code2 = "function catch_block() { \n" + 1121 var code2 = "function catch_block() { \n" +
1154 " try { \n" + 1122 " try { \n" +
1155 " throw 'Exception'; \n" + 1123 " throw 'Exception'; \n" +
1156 " } catch (e) { \n" + 1124 " } catch (e) { \n" +
1157 " with({n : 10}) { \n" + 1125 " with({n : 10}) { \n" +
1158 " debugger; \n" + 1126 " debugger; \n" +
1159 " } \n" + 1127 " } \n" +
1160 " } \n" + 1128 " } \n" +
1161 "} \n" + 1129 "} \n" +
1162 "catch_block(); \n"; 1130 "catch_block(); \n";
1163 1131
1164 listener_delegate = function(exec_state) { 1132 listener_delegate = function(exec_state) {
1165 CheckScopeChainPositions([{start: 131, end: 173}, {start: 94, end: 199}, {star t: 20, end: 225}, {}, {}], exec_state); 1133 CheckScopeChainPositions([{start: 131, end: 173},
1134 {start: 94, end: 199},
1135 {start: 20, end: 225},
1136 {}, {}], exec_state);
1166 } 1137 }
1167 eval(code2); 1138 eval(code2);
1168 EndTest(); 1139 EndTest();
1169 1140
1170 BeginTest("Scope positions in for statement"); 1141 BeginTest("Scope positions in for statement");
1171 var code3 = "function for_statement() { \n" + 1142 var code3 = "function for_statement() { \n" +
1172 " for (let i = 0; i < 1; i++) { \n" + 1143 " for (let i = 0; i < 1; i++) { \n" +
1173 " debugger; \n" + 1144 " debugger; \n" +
1174 " } \n" + 1145 " } \n" +
1175 "} \n" + 1146 "} \n" +
1176 "for_statement(); \n"; 1147 "for_statement(); \n";
1177 1148
1178 listener_delegate = function(exec_state) { 1149 listener_delegate = function(exec_state) {
1179 CheckScopeChain([debug.ScopeType.Block, 1150 CheckScopeChain([debug.ScopeType.Block,
1180 debug.ScopeType.Local, 1151 debug.ScopeType.Local,
1181 debug.ScopeType.Script, 1152 debug.ScopeType.Script,
1182 debug.ScopeType.Global], exec_state); 1153 debug.ScopeType.Global], exec_state);
1183 CheckScopeChainPositions([{start: 52, end: 111}, {start: 22, end: 145}, {}, {} ], exec_state); 1154 CheckScopeChainPositions(
1155 [{start: 52, end: 111}, {start: 22, end: 145}, {}, {}], exec_state);
1184 } 1156 }
1185 eval(code3); 1157 eval(code3);
1186 EndTest(); 1158 EndTest();
1187 1159
1188 BeginTest("Scope positions in for statement with lexical block"); 1160 BeginTest("Scope positions in for statement with lexical block");
1189 var code4 = "function for_statement() { \n" + 1161 var code4 = "function for_statement() { \n" +
1190 " for (let i = 0; i < 1; i++) { \n" + 1162 " for (let i = 0; i < 1; i++) { \n" +
1191 " let j; \n" + 1163 " let j; \n" +
1192 " debugger; \n" + 1164 " debugger; \n" +
1193 " } \n" + 1165 " } \n" +
1194 "} \n" + 1166 "} \n" +
1195 "for_statement(); \n"; 1167 "for_statement(); \n";
1196 1168
1197 listener_delegate = function(exec_state) { 1169 listener_delegate = function(exec_state) {
1198 CheckScopeChain([debug.ScopeType.Block, 1170 CheckScopeChain([debug.ScopeType.Block,
1199 debug.ScopeType.Block, 1171 debug.ScopeType.Block,
1200 debug.ScopeType.Local, 1172 debug.ScopeType.Local,
1201 debug.ScopeType.Script, 1173 debug.ScopeType.Script,
1202 debug.ScopeType.Global], exec_state); 1174 debug.ScopeType.Global], exec_state);
1203 CheckScopeChainPositions([{start: 66, end: 147}, {start: 52, end: 147}, {start : 22, end: 181}, {}, {}], exec_state); 1175 CheckScopeChainPositions([{start: 66, end: 147},
1176 {start: 52, end: 147},
1177 {start: 22, end: 181},
1178 {}, {}], exec_state);
1204 } 1179 }
1205 eval(code4); 1180 eval(code4);
1206 EndTest(); 1181 EndTest();
1207 1182
1208 BeginTest("Scope positions in lexical for each statement"); 1183 BeginTest("Scope positions in lexical for each statement");
1209 var code5 = "function for_each_statement() { \n" + 1184 var code5 = "function for_each_statement() { \n" +
1210 " for (let i of [0]) { \n" + 1185 " for (let i of [0]) { \n" +
1211 " debugger; \n" + 1186 " debugger; \n" +
1212 " } \n" + 1187 " } \n" +
1213 "} \n" + 1188 "} \n" +
1214 "for_each_statement(); \n"; 1189 "for_each_statement(); \n";
1215 1190
1216 listener_delegate = function(exec_state) { 1191 listener_delegate = function(exec_state) {
1217 CheckScopeChain([debug.ScopeType.Block, 1192 CheckScopeChain([debug.ScopeType.Block,
1218 debug.ScopeType.Local, 1193 debug.ScopeType.Local,
1219 debug.ScopeType.Script, 1194 debug.ScopeType.Script,
1220 debug.ScopeType.Global], exec_state); 1195 debug.ScopeType.Global], exec_state);
1221 CheckScopeChainPositions([{start: 55, end: 111}, {start: 27, end: 145}, {}, {} ], exec_state); 1196 CheckScopeChainPositions(
1197 [{start: 55, end: 111}, {start: 27, end: 145}, {}, {}], exec_state);
1222 } 1198 }
1223 eval(code5); 1199 eval(code5);
1224 EndTest(); 1200 EndTest();
1225 1201
1226 BeginTest("Scope positions in lexical for each statement with lexical block"); 1202 BeginTest("Scope positions in lexical for each statement with lexical block");
1227 var code6 = "function for_each_statement() { \n" + 1203 var code6 = "function for_each_statement() { \n" +
1228 " for (let i of [0]) { \n" + 1204 " for (let i of [0]) { \n" +
1229 " let j; \n" + 1205 " let j; \n" +
1230 " debugger; \n" + 1206 " debugger; \n" +
1231 " } \n" + 1207 " } \n" +
1232 "} \n" + 1208 "} \n" +
1233 "for_each_statement(); \n"; 1209 "for_each_statement(); \n";
1234 1210
1235 listener_delegate = function(exec_state) { 1211 listener_delegate = function(exec_state) {
1236 CheckScopeChain([debug.ScopeType.Block, 1212 CheckScopeChain([debug.ScopeType.Block,
1237 debug.ScopeType.Block, 1213 debug.ScopeType.Block,
1238 debug.ScopeType.Local, 1214 debug.ScopeType.Local,
1239 debug.ScopeType.Script, 1215 debug.ScopeType.Script,
1240 debug.ScopeType.Global], exec_state); 1216 debug.ScopeType.Global], exec_state);
1241 CheckScopeChainPositions([{start: 57, end: 147}, {start: 55, end: 147}, {start : 27, end: 181}, {}, {}], exec_state); 1217 CheckScopeChainPositions([{start: 57, end: 147},
1218 {start: 55, end: 147},
1219 {start: 27, end: 181},
1220 {}, {}], exec_state);
1242 } 1221 }
1243 eval(code6); 1222 eval(code6);
1244 EndTest(); 1223 EndTest();
1245 1224
1246 BeginTest("Scope positions in non-lexical for each statement"); 1225 BeginTest("Scope positions in non-lexical for each statement");
1247 var code7 = "function for_each_statement() { \n" + 1226 var code7 = "function for_each_statement() { \n" +
1248 " var i; \n" + 1227 " var i; \n" +
1249 " for (i of [0]) { \n" + 1228 " for (i of [0]) { \n" +
1250 " debugger; \n" + 1229 " debugger; \n" +
1251 " } \n" + 1230 " } \n" +
1252 "} \n" + 1231 "} \n" +
1253 "for_each_statement(); \n"; 1232 "for_each_statement(); \n";
1254 1233
1255 listener_delegate = function(exec_state) { 1234 listener_delegate = function(exec_state) {
1256 CheckScopeChain([debug.ScopeType.Local, 1235 CheckScopeChain([debug.ScopeType.Local,
1257 debug.ScopeType.Script, 1236 debug.ScopeType.Script,
1258 debug.ScopeType.Global], exec_state); 1237 debug.ScopeType.Global], exec_state);
1259 CheckScopeChainPositions([{start: 27, end: 181}, {}, {}], exec_state); 1238 CheckScopeChainPositions([{start: 27, end: 181}, {}, {}], exec_state);
1260 } 1239 }
1261 eval(code7); 1240 eval(code7);
1262 EndTest(); 1241 EndTest();
1263 1242
1264 BeginTest("Scope positions in non-lexical for each statement with lexical block" ); 1243 BeginTest(
1244 "Scope positions in non-lexical for each statement with lexical block");
1265 var code8 = "function for_each_statement() { \n" + 1245 var code8 = "function for_each_statement() { \n" +
1266 " var i; \n" + 1246 " var i; \n" +
1267 " for (i of [0]) { \n" + 1247 " for (i of [0]) { \n" +
1268 " let j; \n" + 1248 " let j; \n" +
1269 " debugger; \n" + 1249 " debugger; \n" +
1270 " } \n" + 1250 " } \n" +
1271 "} \n" + 1251 "} \n" +
1272 "for_each_statement(); \n"; 1252 "for_each_statement(); \n";
1273 1253
1274 listener_delegate = function(exec_state) { 1254 listener_delegate = function(exec_state) {
1275 CheckScopeChain([debug.ScopeType.Block, 1255 CheckScopeChain([debug.ScopeType.Block,
1276 debug.ScopeType.Local, 1256 debug.ScopeType.Local,
1277 debug.ScopeType.Script, 1257 debug.ScopeType.Script,
1278 debug.ScopeType.Global], exec_state); 1258 debug.ScopeType.Global], exec_state);
1279 CheckScopeChainPositions([{start: 89, end: 183}, {start: 27, end: 217}, {}, {} ], exec_state); 1259 CheckScopeChainPositions(
1260 [{start: 89, end: 183}, {start: 27, end: 217}, {}, {}], exec_state);
1280 } 1261 }
1281 eval(code8); 1262 eval(code8);
1282 EndTest(); 1263 EndTest();
1283 1264
1284 assertEquals(begin_test_count, break_count, 1265 assertEquals(begin_test_count, break_count,
1285 'one or more tests did not enter the debugger'); 1266 'one or more tests did not enter the debugger');
1286 assertEquals(begin_test_count, end_test_count, 1267 assertEquals(begin_test_count, end_test_count,
1287 'one or more tests did not have its result checked'); 1268 'one or more tests did not have its result checked');
OLDNEW
« no previous file with comments | « test/mjsunit/bugs/harmony/debug-blockscopes.js ('k') | test/mjsunit/es6/debug-blockscopes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698