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

Side by Side Diff: test/mjsunit/es6/debug-blockscopes.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/debug-scopes.js ('k') | test/mjsunit/es6/generators-debug-scopes.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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 assertTrue(scope.isScope()); 88 assertTrue(scope.isScope());
89 assertEquals(scopes[i], scope.scopeType()); 89 assertEquals(scopes[i], scope.scopeType());
90 90
91 // Check the global object when hitting the global scope. 91 // Check the global object when hitting the global scope.
92 if (scopes[i] == debug.ScopeType.Global) { 92 if (scopes[i] == debug.ScopeType.Global) {
93 // Objects don't have same class (one is "global", other is "Object", 93 // Objects don't have same class (one is "global", other is "Object",
94 // so just check the properties directly. 94 // so just check the properties directly.
95 assertPropertiesEqual(global_object, scope.scopeObject().value()); 95 assertPropertiesEqual(global_object, scope.scopeObject().value());
96 } 96 }
97 } 97 }
98
99 // Get the debug command processor.
100 var dcp = exec_state.debugCommandProcessor("unspecified_running_state");
101
102 // Send a scopes request and check the result.
103 var json;
104 var request_json = '{"seq":0,"type":"request","command":"scopes"}';
105 var response_json = dcp.processDebugJSONRequest(request_json);
106 var response = JSON.parse(response_json);
107 assertEquals(scopes.length, response.body.scopes.length);
108 for (var i = 0; i < scopes.length; i++) {
109 assertEquals(i, response.body.scopes[i].index);
110 assertEquals(scopes[i], response.body.scopes[i].type);
111 if (scopes[i] == debug.ScopeType.Local ||
112 scopes[i] == debug.ScopeType.Script ||
113 scopes[i] == debug.ScopeType.Closure) {
114 assertTrue(response.body.scopes[i].object.ref < 0);
115 } else {
116 assertTrue(response.body.scopes[i].object.ref >= 0);
117 }
118 var found = false;
119 for (var j = 0; j < response.refs.length && !found; j++) {
120 found = response.refs[j].handle == response.body.scopes[i].object.ref;
121 }
122 assertTrue(found, "Scope object " + response.body.scopes[i].object.ref + " n ot found");
123 }
124 } 98 }
125 99
126 // 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
127 // that there is a function. 101 // that there is a function.
128 function CheckScopeContent(content, number, exec_state) { 102 function CheckScopeContent(content, number, exec_state) {
129 var scope = exec_state.frame().scope(number); 103 var scope = exec_state.frame().scope(number);
130 var count = 0; 104 var count = 0;
131 for (var p in content) { 105 for (var p in content) {
132 var property_mirror = scope.scopeObject().property(p); 106 var property_mirror = scope.scopeObject().property(p);
133 if (property_mirror.isUndefined()) { 107 if (property_mirror.isUndefined()) {
134 print('property ' + p + ' not found in scope'); 108 print('property ' + p + ' not found in scope');
135 } 109 }
136 assertFalse(property_mirror.isUndefined(), 'property ' + p + ' not found in scope'); 110 assertFalse(property_mirror.isUndefined(),
111 'property ' + p + ' not found in scope');
137 if (typeof(content[p]) === 'function') { 112 if (typeof(content[p]) === 'function') {
138 assertTrue(property_mirror.value().isFunction()); 113 assertTrue(property_mirror.value().isFunction());
139 } else { 114 } else {
140 assertEquals(content[p], property_mirror.value().value(), 'property ' + p + ' has unexpected value'); 115 assertEquals(content[p], property_mirror.value().value(),
116 'property ' + p + ' has unexpected value');
141 } 117 }
142 count++; 118 count++;
143 } 119 }
144 120
145 // 'arguments' and might be exposed in the local and closure scope. Just 121 // 'arguments' and might be exposed in the local and closure scope. Just
146 // ignore this. 122 // ignore this.
147 var scope_size = scope.scopeObject().properties().length; 123 var scope_size = scope.scopeObject().properties().length;
148 if (!scope.scopeObject().property('arguments').isUndefined()) { 124 if (!scope.scopeObject().property('arguments').isUndefined()) {
149 scope_size--; 125 scope_size--;
150 } 126 }
151 // Temporary variables introduced by the parser have not been materialized. 127 // Temporary variables introduced by the parser have not been materialized.
152 assertTrue(scope.scopeObject().property('').isUndefined()); 128 assertTrue(scope.scopeObject().property('').isUndefined());
153 129
154 if (count != scope_size) { 130 if (count != scope_size) {
155 print('Names found in scope:'); 131 print('Names found in scope:');
156 var names = scope.scopeObject().propertyNames(); 132 var names = scope.scopeObject().propertyNames();
157 for (var i = 0; i < names.length; i++) { 133 for (var i = 0; i < names.length; i++) {
158 print(names[i]); 134 print(names[i]);
159 } 135 }
160 } 136 }
161 assertEquals(count, scope_size); 137 assertEquals(count, scope_size);
162
163 // Get the debug command processor.
164 var dcp = exec_state.debugCommandProcessor("unspecified_running_state");
165
166 // Send a scope request for information on a single scope and check the
167 // result.
168 var request_json = '{"seq":0,"type":"request","command":"scope","arguments":{" number":';
169 request_json += scope.scopeIndex();
170 request_json += '}}';
171 var response_json = dcp.processDebugJSONRequest(request_json);
172 var response = JSON.parse(response_json);
173 assertEquals(scope.scopeType(), response.body.type);
174 assertEquals(number, response.body.index);
175 if (scope.scopeType() == debug.ScopeType.Local ||
176 scope.scopeType() == debug.ScopeType.Closure) {
177 assertTrue(response.body.object.ref < 0);
178 } else {
179 assertTrue(response.body.object.ref >= 0);
180 }
181 var found = false;
182 for (var i = 0; i < response.refs.length && !found; i++) {
183 found = response.refs[i].handle == response.body.object.ref;
184 }
185 assertTrue(found, "Scope object " + response.body.object.ref + " not found");
186 } 138 }
187 139
188 140
189 function assertEqualsUnlessOptimized(expected, value, f) { 141 function assertEqualsUnlessOptimized(expected, value, f) {
190 try { 142 try {
191 assertEquals(expected, value); 143 assertEquals(expected, value);
192 } catch (e) { 144 } catch (e) {
193 assertOptimized(f); 145 assertOptimized(f);
194 } 146 }
195 } 147 }
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 debugger; 482 debugger;
531 } 483 }
532 } 484 }
533 485
534 listener_delegate = function (exec_state) { 486 listener_delegate = function (exec_state) {
535 assertEqualsUnlessOptimized(0, exec_state.frame(0).evaluate("i").value()); 487 assertEqualsUnlessOptimized(0, exec_state.frame(0).evaluate("i").value());
536 assertEqualsUnlessOptimized(5, exec_state.frame(0).evaluate("j").value()); 488 assertEqualsUnlessOptimized(5, exec_state.frame(0).evaluate("j").value());
537 } 489 }
538 shadowing_2(); 490 shadowing_2();
539 EndTest(); 491 EndTest();
OLDNEW
« no previous file with comments | « test/mjsunit/debug-scopes.js ('k') | test/mjsunit/es6/generators-debug-scopes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698