OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // MODULE | 5 // MODULE |
6 // Flags: --expose-debug-as debug | 6 // Flags: --expose-debug-as debug |
7 | 7 |
8 | 8 |
9 var Debug = debug.Debug; | 9 var Debug = debug.Debug; |
10 | 10 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 var all_scopes = exec_state.frame().allScopes(); | 72 var all_scopes = exec_state.frame().allScopes(); |
73 assertEquals(scopes.length, exec_state.frame().scopeCount()); | 73 assertEquals(scopes.length, exec_state.frame().scopeCount()); |
74 assertEquals(scopes.length, all_scopes.length, "FrameMirror.allScopes length")
; | 74 assertEquals(scopes.length, all_scopes.length, "FrameMirror.allScopes length")
; |
75 for (var i = 0; i < scopes.length; i++) { | 75 for (var i = 0; i < scopes.length; i++) { |
76 var scope = exec_state.frame().scope(i); | 76 var scope = exec_state.frame().scope(i); |
77 assertTrue(scope.isScope()); | 77 assertTrue(scope.isScope()); |
78 assertEquals(scopes[i], scope.scopeType()); | 78 assertEquals(scopes[i], scope.scopeType()); |
79 assertScopeMirrorEquals(all_scopes[i], scope); | 79 assertScopeMirrorEquals(all_scopes[i], scope); |
80 } | 80 } |
81 CheckFastAllScopes(scopes, exec_state); | 81 CheckFastAllScopes(scopes, exec_state); |
82 | |
83 // Get the debug command processor. | |
84 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); | |
85 | |
86 // Send a scopes request and check the result. | |
87 var json; | |
88 var request_json = '{"seq":0,"type":"request","command":"scopes"}'; | |
89 var response_json = dcp.processDebugJSONRequest(request_json); | |
90 var response = JSON.parse(response_json); | |
91 assertEquals(scopes.length, response.body.scopes.length); | |
92 for (var i = 0; i < scopes.length; i++) { | |
93 assertEquals(i, response.body.scopes[i].index); | |
94 assertEquals(scopes[i], response.body.scopes[i].type); | |
95 if (scopes[i] == debug.ScopeType.Local || | |
96 scopes[i] == debug.ScopeType.Script || | |
97 scopes[i] == debug.ScopeType.Closure) { | |
98 assertTrue(response.body.scopes[i].object.ref < 0); | |
99 } else { | |
100 assertTrue(response.body.scopes[i].object.ref >= 0); | |
101 } | |
102 var found = false; | |
103 for (var j = 0; j < response.refs.length && !found; j++) { | |
104 found = response.refs[j].handle == response.body.scopes[i].object.ref; | |
105 } | |
106 assertTrue(found, "Scope object " + response.body.scopes[i].object.ref + " n
ot found"); | |
107 } | |
108 } | 82 } |
109 | 83 |
110 | 84 |
111 function CheckScopeDoesNotHave(properties, number, exec_state) { | 85 function CheckScopeDoesNotHave(properties, number, exec_state) { |
112 var scope = exec_state.frame().scope(number); | 86 var scope = exec_state.frame().scope(number); |
113 for (var p of properties) { | 87 for (var p of properties) { |
114 var property_mirror = scope.scopeObject().property(p); | 88 var property_mirror = scope.scopeObject().property(p); |
115 assertTrue(property_mirror.isUndefined(), 'property ' + p + ' found in scope
'); | 89 assertTrue(property_mirror.isUndefined(), 'property ' + p + ' found in scope
'); |
116 } | 90 } |
117 } | 91 } |
(...skipping 29 matching lines...) Expand all Loading... |
147 assertTrue(scope.scopeObject().property('').isUndefined()); | 121 assertTrue(scope.scopeObject().property('').isUndefined()); |
148 | 122 |
149 if (scope_size < minimum_count) { | 123 if (scope_size < minimum_count) { |
150 print('Names found in scope:'); | 124 print('Names found in scope:'); |
151 var names = scope.scopeObject().propertyNames(); | 125 var names = scope.scopeObject().propertyNames(); |
152 for (var i = 0; i < names.length; i++) { | 126 for (var i = 0; i < names.length; i++) { |
153 print(names[i]); | 127 print(names[i]); |
154 } | 128 } |
155 } | 129 } |
156 assertTrue(scope_size >= minimum_count); | 130 assertTrue(scope_size >= minimum_count); |
157 | |
158 // Get the debug command processor. | |
159 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); | |
160 | |
161 // Send a scope request for information on a single scope and check the | |
162 // result. | |
163 var request_json = '{"seq":0,"type":"request","command":"scope","arguments":{"
number":'; | |
164 request_json += scope.scopeIndex(); | |
165 request_json += '}}'; | |
166 var response_json = dcp.processDebugJSONRequest(request_json); | |
167 var response = JSON.parse(response_json); | |
168 assertEquals(scope.scopeType(), response.body.type); | |
169 assertEquals(number, response.body.index); | |
170 if (scope.scopeType() == debug.ScopeType.Local || | |
171 scope.scopeType() == debug.ScopeType.Script || | |
172 scope.scopeType() == debug.ScopeType.Closure) { | |
173 assertTrue(response.body.object.ref < 0); | |
174 } else { | |
175 assertTrue(response.body.object.ref >= 0); | |
176 } | |
177 var found = false; | |
178 for (var i = 0; i < response.refs.length && !found; i++) { | |
179 found = response.refs[i].handle == response.body.object.ref; | |
180 } | |
181 assertTrue(found, "Scope object " + response.body.object.ref + " not found"); | |
182 } | 131 } |
183 | 132 |
184 | 133 |
185 //////////////////////////////////////////////////////////////////////////////// | 134 //////////////////////////////////////////////////////////////////////////////// |
186 // Actual tests. | 135 // Actual tests. |
187 //////////////////////////////////////////////////////////////////////////////// | 136 //////////////////////////////////////////////////////////////////////////////// |
188 | 137 |
189 | 138 |
190 BeginTest(); | 139 BeginTest(); |
191 listener_delegate = function(exec_state) { | 140 listener_delegate = function(exec_state) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 listener_delegate = function(exec_state) { | 179 listener_delegate = function(exec_state) { |
231 CheckScopeChain([debug.ScopeType.Module, | 180 CheckScopeChain([debug.ScopeType.Module, |
232 debug.ScopeType.Script, | 181 debug.ScopeType.Script, |
233 debug.ScopeType.Global], exec_state); | 182 debug.ScopeType.Global], exec_state); |
234 CheckScopeContent( | 183 CheckScopeContent( |
235 {local_let: 11, local_var: 12, exported_let: 13, exported_var: 14, | 184 {local_let: 11, local_var: 12, exported_let: 13, exported_var: 14, |
236 imported_let: 13, imported_var: 14}, 0, exec_state); | 185 imported_let: 13, imported_var: 14}, 0, exec_state); |
237 }; | 186 }; |
238 debugger; | 187 debugger; |
239 EndTest(); | 188 EndTest(); |
OLD | NEW |