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

Side by Side Diff: test/debugger/debug/es6/debug-blockscopes.js

Issue 2566093002: [debug-wrapper] migrate some scope related tests (Closed)
Patch Set: address comments 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
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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Flags: --expose-debug-as debug --allow-natives-syntax --noanalyze-environment -liveness 28 // Flags: --noanalyze-environment-liveness
29 // The functions used for testing backtraces. They are at the top to make the 29 // The functions used for testing backtraces. They are at the top to make the
30 // testing of source line/column easier. 30 // testing of source line/column easier.
31 31
32 "use strict"; 32 "use strict";
33 33
34 // Get the Debug object exposed from the debug context global object.
35 var Debug = debug.Debug; 34 var Debug = debug.Debug;
36 35
37 var test_name; 36 var test_name;
38 var listener_delegate; 37 var listener_delegate;
39 var listener_called; 38 var listener_called;
40 var exception; 39 var exception;
41 var begin_test_count = 0; 40 var begin_test_count = 0;
42 var end_test_count = 0; 41 var end_test_count = 0;
43 var break_count = 0; 42 var break_count = 0;
43 var global_marker = 7;
44 44
45 45
46 // Debug event listener which delegates. 46 // Debug event listener which delegates.
47 function listener(event, exec_state, event_data, data) { 47 function listener(event, exec_state, event_data, data) {
48 try { 48 try {
49 if (event == Debug.DebugEvent.Break) { 49 if (event == Debug.DebugEvent.Break) {
50 break_count++; 50 break_count++;
51 listener_called = true; 51 listener_called = true;
52 listener_delegate(exec_state); 52 listener_delegate(exec_state);
53 } 53 }
(...skipping 12 matching lines...) Expand all
66 test_name = name; 66 test_name = name;
67 listener_delegate = null; 67 listener_delegate = null;
68 listener_called = false; 68 listener_called = false;
69 exception = null; 69 exception = null;
70 begin_test_count++; 70 begin_test_count++;
71 } 71 }
72 72
73 73
74 // Check result of a test. 74 // Check result of a test.
75 function EndTest() { 75 function EndTest() {
76 assertTrue(listener_called, "listerner not called for " + test_name); 76 assertTrue(listener_called, "listener not called for " + test_name);
77 assertNull(exception, test_name, exception); 77 assertNull(exception, test_name, exception);
78 end_test_count++; 78 end_test_count++;
79 } 79 }
80 80
81 var global_object = this; 81 var global_object = this;
82 82
83 // Check that the scope chain contains the expected types of scopes. 83 // Check that the scope chain contains the expected types of scopes.
84 function CheckScopeChain(scopes, exec_state) { 84 function CheckScopeChain(scopes, exec_state) {
85 assertEquals(scopes.length, exec_state.frame().scopeCount()); 85 assertEquals(scopes.length, exec_state.frame().scopeCount());
86 for (var i = 0; i < scopes.length; i++) { 86 for (var i = 0; i < scopes.length; i++) {
87 var scope = exec_state.frame().scope(i); 87 var scope = exec_state.frame().scope(i);
88 assertTrue(scope.isScope());
89 assertEquals(scopes[i], scope.scopeType()); 88 assertEquals(scopes[i], scope.scopeType());
90 89
91 // Check the global object when hitting the global scope. 90 // Check the global object when hitting the global scope.
92 if (scopes[i] == debug.ScopeType.Global) { 91 if (scopes[i] == debug.ScopeType.Global) {
93 // Objects don't have same class (one is "global", other is "Object", 92 // Objects don't have same class (one is "global", other is "Object",
94 // so just check the properties directly. 93 // so just check the properties directly.
95 assertPropertiesEqual(global_object, scope.scopeObject().value()); 94 assertEquals(global_object.global_marker,
95 scope.scopeObject().value().global_marker);
96 } 96 }
97 } 97 }
98 } 98 }
99 99
100 // Check that the content of the scope is as expected. For functions just check 100 // Check that the content of the scope is as expected. For functions just check
101 // that there is a function. 101 // that there is a function.
102 function CheckScopeContent(content, number, exec_state) { 102 function CheckScopeContent(content, number, exec_state) {
103 var scope = exec_state.frame().scope(number); 103 var scope = exec_state.frame().scope(number);
104 var count = 0; 104 var count = 0;
105 for (var p in content) { 105 for (var p in content) {
106 var property_mirror = scope.scopeObject().property(p); 106 var property_mirror = scope.scopeObject().property(p);
107 if (property_mirror.isUndefined()) { 107 if (property_mirror.isUndefined()) {
108 print('property ' + p + ' not found in scope'); 108 print('property ' + p + ' not found in scope');
109 } 109 }
110 assertFalse(property_mirror.isUndefined(), 110 assertFalse(property_mirror.isUndefined(),
111 'property ' + p + ' not found in scope'); 111 'property ' + p + ' not found in scope');
112 if (typeof(content[p]) === 'function') { 112 assertEquals(content[p], property_mirror.value().value(),
113 assertTrue(property_mirror.value().isFunction()); 113 'property ' + p + ' has unexpected value');
114 } else {
115 assertEquals(content[p], property_mirror.value().value(),
116 'property ' + p + ' has unexpected value');
117 }
118 count++; 114 count++;
119 } 115 }
120 116
121 // 'arguments' and might be exposed in the local and closure scope. Just 117 // 'arguments' and might be exposed in the local and closure scope. Just
122 // ignore this. 118 // ignore this.
123 var scope_size = scope.scopeObject().properties().length; 119 var scope_size = scope.scopeObject().properties().length;
124 if (!scope.scopeObject().property('arguments').isUndefined()) { 120 if (!scope.scopeObject().property('arguments').isUndefined()) {
125 scope_size--; 121 scope_size--;
126 } 122 }
127 // Temporary variables introduced by the parser have not been materialized. 123 // Temporary variables introduced by the parser have not been materialized.
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 debugger; 478 debugger;
483 } 479 }
484 } 480 }
485 481
486 listener_delegate = function (exec_state) { 482 listener_delegate = function (exec_state) {
487 assertEqualsUnlessOptimized(0, exec_state.frame(0).evaluate("i").value()); 483 assertEqualsUnlessOptimized(0, exec_state.frame(0).evaluate("i").value());
488 assertEqualsUnlessOptimized(5, exec_state.frame(0).evaluate("j").value()); 484 assertEqualsUnlessOptimized(5, exec_state.frame(0).evaluate("j").value());
489 } 485 }
490 shadowing_2(); 486 shadowing_2();
491 EndTest(); 487 EndTest();
OLDNEW
« no previous file with comments | « test/debugger/debug/debug-setbreakpoint.js ('k') | test/debugger/debug/es6/generators-debug-scopes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698